query_name
stringlengths
13
55
code_file_path
stringlengths
14
194
context_blocks
list
answer_spans
list
supporting_fact_spans
list
example_type
int8
0
1
single_hop
bool
2 classes
subtokenized_input_sequence
list
label_sequence
list
Except block handles 'BaseException'
smailq/gitolite-manager/gitolite_manager/gitolite.py
[ { "content": " def rmSSHKey(self, username, keyname):\n\n key_file_name = self.__get_ssh_key_path(username, keyname)\n\n try:\n os.remove(key_file_name)\n except:\n return False\n\n return True", "metadata": "root.Gitolite.rmSSHKey", "header": "['class', 'Gitolite', '(', 'object', ')', ':', '___EOS___']", "index": 69 } ]
[ { "span": "except:", "start_line": 75, "start_column": 4, "end_line": 75, "end_column": 11 } ]
[]
1
true
[ "[CLS]_", "Except", "_", "block_", "handles_", "'", "Base", "Except", "ion", "'_", "[SEP]_", "class_", "Git", "oli", "te_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "rm", "SSH", "Key_", "(_", "self_", ",_", "username_", ",_", "keyname_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "key", "\\u", "file", "\\u", "name_", "=_", "self_", "._", "\\u\\u", "get", "\\u", "ssh", "\\u", "key", "\\u", "path_", "(_", "username_", ",_", "keyname_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "os_", "._", "remove_", "(_", "key", "\\u", "file", "\\u", "name_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_" ]
[ 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 ]
Variable defined multiple times
nasa-gibs/onearth/src/scripts/SLDtoColorMap.py
[ { "content": "def parseSLD_v1_1_0(sourceXml, layerName, units, offset, factor, rgbOrder, format, densify) :\n \n gibsColorMaps = []\n \n xmldoc = minidom.parse(sourceXml)\n\n #for childNode in xmldoc.documentElement.childNodes :\n for nlNode in xmldoc.documentElement.getElementsByTagName(\"NamedLayer\") :\n \n nameNode = nlNode.getElementsByTagName(\"se:Name\")[0]\n\n\n if nameNode.firstChild.nodeValue != layerName:\n break\n \n \n for userStyleNode in nlNode.getElementsByTagName(\"UserStyle\"):\n\n # <xsd:element ref=\"sld:Name\" minOccurs=\"0\"/>\n # <xsd:element ref=\"sld:Title\" minOccurs=\"0\"/>\n\n\n for rasterSymNode in userStyleNode.getElementsByTagName(\"se:RasterSymbolizer\"):\n # <xsd:element ref=\"sld:Name\" minOccurs=\"0\"/>\n # <xsd:element ref=\"sld:Title\" minOccurs=\"0\"/>\n \n defaultOpacity = rasterSymNode.getElementsByTagName(\"se:Opacity\")[0].firstChild.nodeValue\n \n colorMapNode = rasterSymNode.getElementsByTagName(\"se:ColorMap\")[0]\n categorizeNode = rasterSymNode.getElementsByTagName(\"se:Categorize\")[0]\n \n # <se:Categorize fallbackValue=\"#78c818\">\n attrDict = dict(categorizeNode.attributes.items())\n \n \n # Add a colormap for the no data value based on the fallbackValue\n if 'fallbackValue' in attrDict :\n hexValue = \"\"\n \n for c in \"RGB\":\n s = (-2 * rgbOrder[::-1].find(c)) -2\n e = (-2 * rgbOrder[::-1].find(c))\n e = e if e != 0 else None\n hexValue = hexValue + attrDict['fallbackValue'][s:e]\n \n gibsCMapEntry = GIBS_ColorMapEntry()\n gibsCMapEntry.rgb = hexToRGB(hexValue)\n gibsCMapEntry.transparent = True\n gibsCMapEntry.label = \"No Data\"\n gibsCMapEntry.nodata = True\n gibsCMapEntry.ref = 1\n \n gibsCMap = GIBS_ColorMap()\n gibsCMap.cmEntries = []\n gibsCMap.cmEntries.append(gibsCMapEntry)\n gibsColorMaps.append(gibsCMap)\n \n \n \n # Process the SLD entries into the XML ColorMap\n gibsCMap = GIBS_ColorMap()\n \n prevValue = sys.maxint\n prev2Value = sys.maxint\n currValue = sys.maxint\n firstValue = sys.maxint\n prevRGB = [-1,-1,-1]\n prev2RGB = [-1,-1,-1]\n currRGB = [-1,-1,-1]\n firstRGB = [-1,-1,-1]\n currRef = 1\n\n # Loop through the <Value> and <Threshold> elements\n for catChildNode in [ n for n in categorizeNode.childNodes if n.nodeType == Node.ELEMENT_NODE ]:\n \n # <se:Value>#00ff00</se:Value>\n if catChildNode.nodeName == \"se:Value\":\n currRGB = hexToRGB(catChildNode.firstChild.nodeValue)\n \n # <se:Threshold>52</se:Threshold>\n if catChildNode.nodeName == \"se:Threshold\":\n currValue = float(catChildNode.firstChild.nodeValue)\n \n # If prevValue is sys.maxint, then this is the first Threshold. Add a colormap entry for (-INF,currValue)\n if prevValue == sys.maxint:\n gibsCMapEntry = GIBS_ColorMapEntry()\n gibsCMapEntry.transparent = (defaultOpacity == 0.0)\n gibsCMapEntry.rgb = currRGB\n gibsCMapEntry.label = \"&lt; \" + format.format(currValue) + (\"\" if not units else (\" \" + units))\n gibsCMapEntry.value = [\"-INF\", currValue]\n gibsCMapEntry.sourceValue = [\"-INF\", ((currValue - offset) / factor)]\n gibsCMapEntry.ref = currRef\n \n gibsCMap.cmEntries.append(gibsCMapEntry)\n gibsCMap.minLabel = \"&lt; \" + format.format(currValue) + (\"\" if not units else (\" \" + units))\n \n currRef = currRef + 1\n \n # If not densifying, then add a Colormap entry for [prevValue, currValue)\n elif not densify:\n gibsCMapEntry = GIBS_ColorMapEntry()\n gibsCMapEntry.transparent = (defaultOpacity == 0.0)\n gibsCMapEntry.rgb = currRGB\n gibsCMapEntry.label = format.format(prevValue) + \" - \" + format.format(currValue) + (\"\" if not units else (\" \" + units))\t\n gibsCMapEntry.value = [prevValue, currValue]\n gibsCMapEntry.sourceValue = [((prevValue - offset) / factor), ((currValue - offset) / factor)]\n gibsCMapEntry.ref = currRef\n \n gibsCMap.cmEntries.append(gibsCMapEntry)\n \n currRef = currRef + 1\n \n # If densifying...\n else:\n m = re.match(r\"([sro])([0-9]*)\", densify)\n\n # \"Step\" Densification\n # Generate extra colormap entries for intermediate data values with visually\n # imperceptibly different colors from the previous data value and RGB to the \n # current data value and RGB. \n if m.group(1) == \"s\":\n #print(\"step data \" + str(prevValue) + \" - \" + str(currValue))\n #print(\"step color \" + str(prevRGB) + \" - \" + str(currRGB))\n \n colorSteps = stepDensify(currRGB, int(m.group(2)), 1)\n #print(colorSteps)\n\n dataSteps = dataDensify(prevValue, currValue, int(m.group(2)))\n #print(dataSteps)\n \n for step in range(0, int(m.group(2))):\n #print(dataSteps[step])\n #print(colorSteps[step])\n \n gibsCMapEntry = GIBS_ColorMapEntry()\n gibsCMapEntry.transparent = (defaultOpacity == 0.0)\n gibsCMapEntry.rgb = colorSteps[step]\n gibsCMapEntry.label = format.format(prevValue) + \" - \" + format.format(dataSteps[step]) + (\"\" if not units else (\" \" + units))\t\n gibsCMapEntry.value = [prevValue, dataSteps[step]]\n gibsCMapEntry.sourceValue = [((prevValue - offset) / factor), ((dataSteps[step] - offset) / factor)]\n gibsCMapEntry.ref = currRef\n\n gibsCMap.cmEntries.append(gibsCMapEntry)\n \n prevValue = dataSteps[step]\n \n currRef = currRef + 1\n \n # \"Ramp\" Densification\n # Generate extra colormap entries for intermediate data values with visibly different colors\n # from the previous RGB to the current RGB, but using the previous data range. This data\n # range lags behind the RGB range because we don't know which color to ramp to due to how the \n # <Threshold> values are read in the XML parsing.\n elif m.group(1) == \"r\" and prev2Value != sys.maxint: \n #print(\"ramp data \" + str(prev2Value) + \" - \" + str(prevValue))\n #print(\"ramp color \" + str(prevRGB) + \" - \" + str(currRGB))\n \n colorSteps = rampDensify(prevRGB, currRGB, int(m.group(2)) + 1)\n #print(colorSteps)\n\n dataSteps = dataDensify(prev2Value, prevValue, int(m.group(2)))\n #print(dataSteps)\n \n prevValue = prev2Value\n \n for step in range(0, int(m.group(2))):\n #print(dataSteps[step])\n #print(colorSteps[step])\n \n gibsCMapEntry = GIBS_ColorMapEntry()\n gibsCMapEntry.transparent = (defaultOpacity == 0.0)\n gibsCMapEntry.rgb = colorSteps[step]\n gibsCMapEntry.label = format.format(prevValue) + \" - \" + format.format(dataSteps[step]) + (\"\" if not units else (\" \" + units))\t\n gibsCMapEntry.value = [prevValue, dataSteps[step]]\n gibsCMapEntry.sourceValue = [((prevValue - offset) / factor), ((dataSteps[step] - offset) / factor)]\n gibsCMapEntry.ref = currRef\n\n gibsCMap.cmEntries.append(gibsCMapEntry)\n \n prevValue = dataSteps[step]\n \n currRef = currRef + 1\n\n # \"Override\" Densification\n # Capture the data value and RGB for the first entry for the first time through\n # and then just ignore it after that \n elif m.group(1) == \"o\" and firstValue == sys.maxint: \n firstValue = prevValue\n firstRGB = currRGB\n \n prev2Value = prevValue\n prevValue = currValue\n\n prev2RGB = prevRGB\n prevRGB = currRGB\n \n # End: Loop through the <Value> and <Threshold> elements\n # Now process the final color entry\n \n if densify:\n m = re.match(r\"([sro])([0-9]*)\", densify)\n\n # \"Ramp\" Densification\n # Because of the lagging <Threshold> parsing, we now need to add the last ramped\n # section of the colormap.\n if m.group(1) == \"r\":\n #print(\"ramp data \" + str(prev2Value) + \" - \" + str(prevValue))\n #print(\"ramp color \" + str(prevRGB) + \" - \" + str(currRGB))\n \n colorSteps = rampDensify(prevRGB, currRGB, int(m.group(2)) + 1)\n #print(colorSteps)\n\n dataSteps = dataDensify(prev2Value, prevValue, int(m.group(2)))\n #print(dataSteps)\n \n prevValue = prev2Value\n \n for step in range(0, int(m.group(2))):\n #print(dataSteps[step])\n #print(colorSteps[step])\n \n gibsCMapEntry = GIBS_ColorMapEntry()\n gibsCMapEntry.transparent = (defaultOpacity == 0.0)\n gibsCMapEntry.rgb = colorSteps[step]\n gibsCMapEntry.label = format.format(prevValue) + \" - \" + format.format(dataSteps[step]) + (\"\" if not units else (\" \" + units))\t\n gibsCMapEntry.value = [prevValue, dataSteps[step]]\n gibsCMapEntry.sourceValue = [((prevValue - offset) / factor), ((dataSteps[step] - offset) / factor)]\n gibsCMapEntry.ref = currRef\n\n gibsCMap.cmEntries.append(gibsCMapEntry)\n \n prevValue = dataSteps[step]\n \n currRef = currRef + 1\n \n # \"Override\" Densification\n # Create a ramp over the entire data range using the start and finish RGB values\n if m.group(1) == \"o\":\n #print(\"ramp data \" + str(firstValue) + \" - \" + str(prevValue))\n #print(\"ramp color \" + str(firstRGB) + \" - \" + str(currRGB))\n \n colorSteps = rampDensify(firstRGB, currRGB, int(m.group(2)) + 1)\n #print(colorSteps)\n\n dataSteps = dataDensify(firstValue, prevValue, int(m.group(2)))\n #print(dataSteps)\n \n prevValue = firstValue\n \n for step in range(0, int(m.group(2))):\n #print(dataSteps[step])\n #print(colorSteps[step])\n \n gibsCMapEntry = GIBS_ColorMapEntry()\n gibsCMapEntry.transparent = (defaultOpacity == 0.0)\n gibsCMapEntry.rgb = colorSteps[step]\n gibsCMapEntry.label = format.format(prevValue) + \" - \" + format.format(dataSteps[step]) + (\"\" if not units else (\" \" + units))\t\n gibsCMapEntry.value = [prevValue, dataSteps[step]]\n gibsCMapEntry.sourceValue = [((prevValue - offset) / factor), ((dataSteps[step] - offset) / factor)]\n gibsCMapEntry.ref = currRef\n\n gibsCMap.cmEntries.append(gibsCMapEntry)\n \n prevValue = dataSteps[step]\n currRef = currRef + 1\n \n\n # Add the final Colormap Entry for the [currValue, +INF) data range\n gibsCMapEntry = GIBS_ColorMapEntry()\n gibsCMapEntry.rgb = currRGB\n gibsCMapEntry.transparent = (defaultOpacity == 0.0)\n gibsCMapEntry.label = \"&gt;= \" + format.format(prevValue) + (\"\" if not units else (\" \" + units))\t\n gibsCMapEntry.value = [prevValue, \"+INF\"]\n gibsCMapEntry.sourceValue = [((prevValue - offset) / factor), \"+INF\"]\n gibsCMapEntry.ref = currRef\n \n gibsCMap.cmEntries.append(gibsCMapEntry)\n \n gibsCMap.maxLabel = \"&gt;= \" + format.format(prevValue) + (\"\" if not units else (\" \" + units))\t\n gibsCMap.showUnits = True\t\n gibsCMap.showLegend = True\n \n \tgibsColorMaps.append(gibsCMap)\n \t\n return gibsColorMaps", "metadata": "root.parseSLD_v1_1_0", "header": "['module', '___EOS___']", "index": 291 }, { "content": "def generateColorMap(gibsColorMaps, units, format):\n\n print(\"<?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?>\")\n print(\"<ColorMaps>\")\n \n for colorMap in gibsColorMaps:\n\n # <ColorMap title=\"Sea Ice Concentration\" units=\"%\">\n print(\" <ColorMap\" + \n ((\" units=\\\"\" + units + \"\\\"\") if colorMap.showUnits and units else \"\") + \">\")\n\n # <Entries minLabel=\"0 %\" maxLabel=\"100 %\"> \n print(\" <Entries\" + \n (\"\" if not colorMap.minLabel else (\" minLabel=\\\"\" + colorMap.minLabel + \"\\\" \")) + \n (\"\" if not colorMap.maxLabel else (\" maxLabel=\\\"\" + colorMap.maxLabel + \"\\\"\")) + \t\">\")\n \n for cMapEntry in colorMap.cmEntries:\n # <ColorMapEntry rgb=\"9,9,255\" transparent=\"false\" sourceValue=\"[9,10)\" value=\"[9,10)\" label=\"3.6 %\" ref=\"1\"/>\n \n rgb = str(cMapEntry.rgb[0]) + \",\" + str(cMapEntry.rgb[1]) + \",\" + str(cMapEntry.rgb[2])\n \n if cMapEntry.value: \n if len(cMapEntry.value) == 1:\n value = \"[\" + (cMapEntry.value[0] if isinstance(cMapEntry.value[0], str) else format.format(cMapEntry.value[0])) + \"]\"\n else:\n value = \"[\" + (cMapEntry.value[0] if isinstance(cMapEntry.value[0], str) else format.format(cMapEntry.value[0])) + \",\" + \\\n (cMapEntry.value[1] if isinstance(cMapEntry.value[1], str) else format.format(cMapEntry.value[1])) + \")\"\n \n if cMapEntry.sourceValue: \n if len(cMapEntry.sourceValue) == 1:\n sourceValue = \"[\" + (cMapEntry.sourceValue[0] if isinstance(cMapEntry.sourceValue[0], str) else format.format(cMapEntry.sourceValue[0])) + \"]\"\n else:\n sourceValue = \"[\" + (cMapEntry.sourceValue[0] if isinstance(cMapEntry.sourceValue[0], str) else format.format(cMapEntry.sourceValue[0])) + \",\" + \\\n (cMapEntry.sourceValue[1] if isinstance(cMapEntry.sourceValue[1], str) else format.format(cMapEntry.sourceValue[1])) + \")\"\n\n print(\" <ColorMapEntry rgb=\\\"\" + rgb + \"\\\" \" + \n \"transparent=\\\"\" + (\"true\" if cMapEntry.transparent else \"false\") + \"\\\" \" + \n (\"\" if not cMapEntry.sourceValue else (\"sourceValue=\\\"\" + value + \"\\\" \")) + \n (\"\" if not cMapEntry.value else (\"value=\\\"\" + value + \"\\\" \")) + \n \"label=\\\"\" + cMapEntry.label + \"\\\" \" + \n (\"\" if not cMapEntry.nodata else (\"nodata=\\\"true\\\" \")) +\n (\"\" if not colorMap.showLegend else (\"ref=\\\"\" + str(cMapEntry.ref) + \"\\\" \")) + \n \"/>\")\n\n print(\" </Entries>\")\n \n \n if colorMap.showLegend:\n # <Entries minLabel=\"0 %\" maxLabel=\"100 %\"> \n print(\" <Legend type=\\\"continuous\\\" \" + \n (\"\" if not colorMap.minLabel else (\" minLabel=\\\"\" + colorMap.minLabel + \"\\\" \")) + \n (\"\" if not colorMap.maxLabel else (\" maxLabel=\\\"\" + colorMap.maxLabel + \"\\\"\")) + \t\">\")\n \n \n prevRef = -1\n \n for cMapEntry in colorMap.cmEntries:\n \n if cMapEntry.ref != prevRef:\n rgb = str(cMapEntry.rgb[0]) + \",\" + str(cMapEntry.rgb[1]) + \",\" + str(cMapEntry.rgb[2])\n \n if cMapEntry.value: \n if len(cMapEntry.value) == 1:\n value = \"[\" + (cMapEntry.value[0] if isinstance(cMapEntry.value[0], str) else format.format(cMapEntry.value[0])) + \"]\"\n else:\n value = \"[\" + (cMapEntry.value[0] if isinstance(cMapEntry.value[0], str) else format.format(cMapEntry.value[0])) + \",\" + \\\n (cMapEntry.value[1] if isinstance(cMapEntry.value[1], str) else format.format(cMapEntry.value[1])) + \")\"\n \n print(\" <LegendEntry rgb=\\\"\" + rgb + \"\\\" \" + \n (\"\" if not colorMap.showLegend else (\"id=\\\"\" + str(cMapEntry.ref) + \"\\\" \")) + \"/>\")\n \n \n prevRef = cMapEntry.ref\n\n print(\" </Legend>\")\n \n print(\" </ColorMap>\")\n \n print(\"</ColorMaps>\")", "metadata": "root.generateColorMap", "header": "['module', '___EOS___']", "index": 581 } ]
[ { "span": "currValue ", "start_line": 355, "start_column": 16, "end_line": 355, "end_column": 25 }, { "span": "prev2RGB ", "start_line": 358, "start_column": 16, "end_line": 358, "end_column": 24 }, { "span": "prev2RGB ", "start_line": 484, "start_column": 24, "end_line": 484, "end_column": 32 }, { "span": "sourceValue ", "start_line": 611, "start_column": 20, "end_line": 611, "end_column": 31 }, { "span": "sourceValue ", "start_line": 613, "start_column": 20, "end_line": 613, "end_column": 31 } ]
[ { "span": "currValue ", "start_line": 372, "start_column": 24, "end_line": 372, "end_column": 33 } ]
1
true
[ "[CLS]_", "Variable_", "defined_", "multiple_", "times_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "parse", "SL", "D", "\\u", "v1", "\\u", "1", "\\u", "0_", "(_", "source", "Xml_", ",_", "layer", "Name_", ",_", "units_", ",_", "offset_", ",_", "factor_", ",_", "rgb", "Order_", ",_", "format_", ",_", "dens", "ify_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "gib", "s", "Color", "Maps_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "xmld", "oc_", "=_", "minidom_", "._", "parse_", "(_", "source", "Xml_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", "for", " ", "child", "Node", " ", "in", " ", "xmld", "oc", ".", "document", "Element", ".", "child", "Node", "s", " ", ":_", "\\u\\u\\uNL\\u\\u\\u_", "for_", "nl", "Node_", "in_", "xmld", "oc_", "._", "document", "Element_", "._", "get", "Element", "s", "By", "Ta", "g", "Name_", "(_", "\"", "Name", "d", "Layer", "\"_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "name", "Node_", "=_", "nl", "Node_", "._", "get", "Element", "s", "By", "Ta", "g", "Name_", "(_", "\"", "se", ":", "Name", "\"_", ")_", "[_", "0_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "name", "Node_", "._", "first", "Child_", "._", "node", "Value_", "!=_", "layer", "Name_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "break_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "for_", "user", "Style", "Node_", "in_", "nl", "Node_", "._", "get", "Element", "s", "By", "Ta", "g", "Name_", "(_", "\"", "User", "Style", "\"_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "<", "xsd", ":", "element", " ", "ref", "=\"", "sld", ":", "Name", "\"", " ", "min", "Occur", "s", "=\"", "0", "\"/>", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "<", "xsd", ":", "element", " ", "ref", "=\"", "sld", ":", "Tit", "le", "\"", " ", "min", "Occur", "s", "=\"", "0", "\"/>", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "for_", "rast", "er", "Sym", "Node_", "in_", "user", "Style", "Node_", "._", "get", "Element", "s", "By", "Ta", "g", "Name_", "(_", "\"", "se", ":", "Ras", "ter", "Symboli", "zer", "\"_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "<", "xsd", ":", "element", " ", "ref", "=\"", "sld", ":", "Name", "\"", " ", "min", "Occur", "s", "=\"", "0", "\"/>", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "<", "xsd", ":", "element", " ", "ref", "=\"", "sld", ":", "Tit", "le", "\"", " ", "min", "Occur", "s", "=\"", "0", "\"/>", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "default", "Opa", "city_", "=_", "rast", "er", "Sym", "Node_", "._", "get", "Element", "s", "By", "Ta", "g", "Name_", "(_", "\"", "se", ":", "Opa", "city", "\"_", ")_", "[_", "0_", "]_", "._", "first", "Child_", "._", "node", "Value_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "color", "Map", "Node_", "=_", "rast", "er", "Sym", "Node_", "._", "get", "Element", "s", "By", "Ta", "g", "Name_", "(_", "\"", "se", ":", "Color", "Map", "\"_", ")_", "[_", "0_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "categoriz", "e", "Node_", "=_", "rast", "er", "Sym", "Node_", "._", "get", "Element", "s", "By", "Ta", "g", "Name_", "(_", "\"", "se", ":", "Categori", "ze", "\"_", ")_", "[_", "0_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "<", "se", ":", "Categori", "ze", " ", "fall", "back", "Value", "=\"", "#", "7", "8c", "818", "\">", "_", "\\u\\u\\uNL\\u\\u\\u_", "attr", "Dict_", "=_", "dict_", "(_", "categoriz", "e", "Node_", "._", "attributes_", "._", "items_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Add", " ", "a", " ", "colormap", " ", "for", " ", "the", " ", "no", " ", "data", " ", "value", " ", "based", " ", "on", " ", "the", " ", "fall", "back", "Value_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "'", "fall", "back", "Value", "'_", "in_", "attr", "Dict_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "hex", "Value_", "=_", "\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "for_", "c_", "in_", "\"", "RGB", "\"_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "s_", "=_", "(_", "-_", "2_", "*_", "rgb", "Order_", "[_", ":_", ":_", "-_", "1_", "]_", "._", "find_", "(_", "c_", ")_", ")_", "-_", "2_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "e_", "=_", "(_", "-_", "2_", "*_", "rgb", "Order_", "[_", ":_", ":_", "-_", "1_", "]_", "._", "find_", "(_", "c_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "e_", "=_", "e_", "if_", "e_", "!=_", "0_", "else_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "hex", "Value_", "=_", "hex", "Value_", "+_", "attr", "Dict_", "[_", "'", "fall", "back", "Value", "'_", "]_", "[_", "s_", ":_", "e_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "gib", "s", "CM", "ap", "Entry_", "=_", "GI", "BS", "\\u", "Color", "Map", "Entry_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "gib", "s", "CM", "ap", "Entry_", "._", "rgb_", "=_", "hex", "To", "RGB_", "(_", "hex", "Value_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "gib", "s", "CM", "ap", "Entry_", "._", "transparent_", "=_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "gib", "s", "CM", "ap", "Entry_", "._", "label_", "=_", "\"", "No", " ", "Data", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "gib", "s", "CM", "ap", "Entry_", "._", "nodata", "_", "=_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "gib", "s", "CM", "ap", "Entry_", "._", "ref_", "=_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "gib", "s", "CM", "ap_", "=_", "GI", "BS", "\\u", "Color", "Map_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "gib", "s", "CM", "ap_", "._", "cm", "Entries_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "gib", "s", "CM", "ap_", "._", "cm", "Entries_", "._", "append_", "(_", "gib", "s", "CM", "ap", "Entry_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "gib", "s", "Color", "Maps_", "._", "append_", "(_", "gib", "s", "CM", "ap_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Process", " ", "the", " ", "SL", "D", " ", "entri", "es", " ", "int", "o", " ", "the", " ", "XML", " ", "Color", "Map_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "gib", "s", "CM", "ap_", "=_", "GI", "BS", "\\u", "Color", "Map_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "prev", "Value_", "=_", "sys_", "._", "maxint_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "prev", "2", "Value_", "=_", "sys_", "._", "maxint_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "curr", "Value_", "=_", "sys_", "._", "maxint_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "first", "Value_", "=_", "sys_", "._", "maxint_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "prev", "RGB_", "=_", "[_", "-_", "1_", ",_", "-_", "1_", ",_", "-_", "1_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "prev", "2", "RGB_", "=_", "[_", "-_", "1_", ",_", "-_", "1_", ",_", "-_", "1_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "curr", "RGB_", "=_", "[_", "-_", "1_", ",_", "-_", "1_", ",_", "-_", "1_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "first", "RGB_", "=_", "[_", "-_", "1_", ",_", "-_", "1_", ",_", "-_", "1_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "curr", "Ref_", "=_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Loop", " ", "through", " ", "the", " ", "<", "Value", ">", " ", "and", " ", "<", "Thresh", "old", ">", " ", "elements_", "\\u\\u\\uNL\\u\\u\\u_", "for_", "cat", "Chil", "d", "Node_", "in_", "[_", "n_", "for_", "n_", "in_", "categoriz", "e", "Node_", "._", "child", "Nodes_", "if_", "n_", "._", "node", "Type_", "==_", "Node_", "._", "ELEMENT", "\\u", "NODE_", "]_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "<", "se", ":", "Value", ">", "#", "00", "ff", "00", "</", "se", ":", "Value", ">_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "if_", "cat", "Chil", "d", "Node_", "._", "node", "Name_", "==_", "\"", "se", ":", "Value", "\"_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "curr", "RGB_", "=_", "hex", "To", "RGB_", "(_", "cat", "Chil", "d", "Node_", "._", "first", "Child_", "._", "node", "Value_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "<", "se", ":", "Thresh", "old", ">", "5", "2", "</", "se", ":", "Thresh", "old", ">_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "cat", "Chil", "d", "Node_", "._", "node", "Name_", "==_", "\"", "se", ":", "Thresh", "old", "\"_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "curr", "Value_", "=_", "float_", "(_", "cat", "Chil", "d", "Node_", "._", "first", "Child_", "._", "node", "Value_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "If", " ", "prev", "Value", " ", "is", " ", "sys", ".", "maxi", "nt", ",", " ", "then", " ", "this", " ", "is", " ", "the", " ", "first", " ", "Thresh", "old", ".", " ", "Add", " ", "a", " ", "colormap", " ", "entry", " ", "for", " ", "(-", "INF", ",", "curr", "Value", ")_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "prev", "Value_", "==_", "sys_", "._", "maxint_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "gib", "s", "CM", "ap", "Entry_", "=_", "GI", "BS", "\\u", "Color", "Map", "Entry_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "gib", "s", "CM", "ap", "Entry_", "._", "transparent_", "=_", "(_", "default", "Opa", "city_", "==_", "0.0_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "gib", "s", "CM", "ap", "Entry_", "._", "rgb_", "=_", "curr", "RGB_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "gib", "s", "CM", "ap", "Entry_", "._", "label_", "=_", "\"&", "lt", ";", " ", "\"_", "+_", "format_", "._", "format_", "(_", "curr", "Value_", ")_", "+_", "(_", "\"\"_", "if_", "not_", "units_", "else_", "(_", "\"", " ", "\"_", "+_", "units_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "gib", "s", "CM", "ap", "Entry_", "._", "value_", "=_", "[_", "\"-", "INF", "\"_", ",_", "curr", "Value_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "gib", "s", "CM", "ap", "Entry_", "._", "source", "Value_", "=_", "[_", "\"-", "INF", "\"_", ",_", "(_", "(_", "curr", "Value_", "-_", "offset_", ")_", "/_", "factor_", ")_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "gib", "s", "CM", "ap", "Entry_", "._", "ref_", "=_", "curr", "Ref_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "gib", "s", "CM", "ap_", "._", "cm", "Entries_", "._", "append_", "(_", "gib", "s", "CM", "ap", "Entry_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "gib", "s", "CM", "ap_", "._", "min", "Label_", "=_", "\"&", "lt", ";", " ", "\"_", "+_", "format_", "._", "format_", "(_", "curr", "Value_", ")_", "+_", "(_", "\"\"_", "if_", "not_", "units_", "else_", "(_", "\"", " ", "\"_", "+_", "units_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "curr", "Ref_", "=_", "curr", "Ref_", "+_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "If", " ", "not", " ", "dens", "if", "ying", ",", " ", "then", " ", "add", " ", "a", " ", "Color", "map", " ", "entry", " ", "for", " ", "[", "prev", "Value", ",", " ", "curr", "Value", ")_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "not_", "dens", "ify_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "gib", "s", "CM", "ap", "Entry_", "=_", "GI", "BS", "\\u", "Color", "Map", "Entry_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "gib", "s", "CM", "ap", "Entry_", "._", "transparent_", "=_", "(_", "default", "Opa", "city_", "==_", "0.0_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "gib", "s", "CM", "ap", "Entry_", "._", "rgb_", "=_", "curr", "RGB_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "gib", "s", "CM", "ap", "Entry_", "._", "label_", "=_", "format_", "._", "format_", "(_", "prev", "Value_", ")_", "+_", "\"", " ", "-", " ", "\"_", "+_", "format_", "._", "format_", "(_", "curr", "Value_", ")_", "+_", "(_", "\"\"_", "if_", "not_", "units_", "else_", "(_", "\"", " ", "\"_", "+_", "units_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "gib", "s", "CM", "ap", "Entry_", "._", "value_", "=_", "[_", "prev", "Value_", ",_", "curr", "Value_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "gib", "s", "CM", "ap", "Entry_", "._", "source", "Value_", "=_", "[_", "(_", "(_", "prev", "Value_", "-_", "offset_", ")_", "/_", "factor_", ")_", ",_", "(_", "(_", "curr", "Value_", "-_", "offset_", ")_", "/_", "factor_", ")_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "gib", "s", "CM", "ap", "Entry_", "._", "ref_", "=_", "curr", "Ref_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "gib", "s", "CM", "ap_", "._", "cm", "Entries_", "._", "append_", "(_", "gib", "s", "CM", "ap", "Entry_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "curr", "Ref_", "=_", "curr", "Ref_", "+_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "If", " ", "dens", "if", "ying", "..._", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "m_", "=_", "re_", "._", "match_", "(_", "r", "\"([", "sr", "o", "])(", "[", "0", "-", "9", "]*)", "\"_", ",_", "dens", "ify_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "\"", "Step", "\"", " ", "Den", "sif", "ication", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Generate", " ", "extra", " ", "colormap", " ", "entri", "es", " ", "for", " ", "intermediate", " ", "data", " ", "values", " ", "with", " ", "visu", "ally", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "imper", "cept", "ibl", "y", " ", "different", " ", "colors", " ", "from", " ", "the", " ", "previ", "ous", " ", "data", " ", "value", " ", "and", " ", "RGB", " ", "to", " ", "the", " _", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "current", " ", "data", " ", "value", " ", "and", " ", "RGB", ".", " _", "\\u\\u\\uNL\\u\\u\\u_", "if_", "m_", "._", "group_", "(_", "1_", ")_", "==_", "\"", "s", "\"_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", "print", "(\"", "step", " ", "data", " ", "\"", " ", "+", " ", "str", "(", "prev", "Value", ")", " ", "+", " ", "\"", " ", "-", " ", "\"", " ", "+", " ", "str", "(", "curr", "Value", "))", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", "print", "(\"", "step", " ", "color", " ", "\"", " ", "+", " ", "str", "(", "prev", "RGB", ")", " ", "+", " ", "\"", " ", "-", " ", "\"", " ", "+", " ", "str", "(", "curr", "RGB", "))", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "color", "Steps_", "=_", "step", "Den", "sif", "y_", "(_", "curr", "RGB_", ",_", "int_", "(_", "m_", "._", "group_", "(_", "2_", ")_", ")_", ",_", "1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", "print", "(", "color", "Step", "s", ")_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "data", "Steps_", "=_", "data", "Den", "sif", "y_", "(_", "prev", "Value_", ",_", "curr", "Value_", ",_", "int_", "(_", "m_", "._", "group_", "(_", "2_", ")_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", "print", "(", "data", "Step", "s", ")_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "for_", "step_", "in_", "range_", "(_", "0_", ",_", "int_", "(_", "m_", "._", "group_", "(_", "2_", ")_", ")_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", "print", "(", "data", "Step", "s", "[", "step", "])", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", "print", "(", "color", "Step", "s", "[", "step", "])", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "gib", "s", "CM", "ap", "Entry_", "=_", "GI", "BS", "\\u", "Color", "Map", "Entry_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "gib", "s", "CM", "ap", "Entry_", "._", "transparent_", "=_", "(_", "default", "Opa", "city_", "==_", "0.0_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "gib", "s", "CM", "ap", "Entry_", "._", "rgb_", "=_", "color", "Steps_", "[_", "step_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "gib", "s", "CM", "ap", "Entry_", "._", "label_", "=_", "format_", "._", "format_", "(_", "prev", "Value_", ")_", "+_", "\"", " ", "-", " ", "\"_", "+_", "format_", "._", "format_", "(_", "data", "Steps_", "[_", "step_", "]_", ")_", "+_", "(_", "\"\"_", "if_", "not_", "units_", "else_", "(_", "\"", " ", "\"_", "+_", "units_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "gib", "s", "CM", "ap", "Entry_", "._", "value_", "=_", "[_", "prev", "Value_", ",_", "data", "Steps_", "[_", "step_", "]_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "gib", "s", "CM", "ap", "Entry_", "._", "source", "Value_", "=_", "[_", "(_", "(_", "prev", "Value_", "-_", "offset_", ")_", "/_", "factor_", ")_", ",_", "(_", "(_", "data", "Steps_", "[_", "step_", "]_", "-_", "offset_", ")_", "/_", "factor_", ")_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "gib", "s", "CM", "ap", "Entry_", "._", "ref_", "=_", "curr", "Ref_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "gib", "s", "CM", "ap_", "._", "cm", "Entries_", "._", "append_", "(_", "gib", "s", "CM", "ap", "Entry_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "prev", "Value_", "=_", "data", "Steps_", "[_", "step_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "curr", "Ref_", "=_", "curr", "Ref_", "+_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "\"", "Ramp", "\"", " ", "Den", "sif", "ication", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Generate", " ", "extra", " ", "colormap", " ", "entri", "es", " ", "for", " ", "intermediate", " ", "data", " ", "values", " ", "with", " ", "visi", "bly", " ", "different", " ", "colors_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "from", " ", "the", " ", "previ", "ous", " ", "RGB", " ", "to", " ", "the", " ", "current", " ", "RGB", ",", " ", "but", " ", "usi", "ng", " ", "the", " ", "previ", "ous", " ", "data", " ", "range", ".", " ", " ", "Thi", "s", " ", "data_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "range", " ", "lags", " ", "beh", "ind", " ", "the", " ", "RGB", " ", "range", " ", "bec", "aus", "e", " ", "we", " ", "don", "'", "t", " ", "know", " ", "whi", "ch", " ", "color", " ", "to", " ", "ramp", " ", "to", " ", "due", " ", "to", " ", "how", " ", "the", " _", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "<", "Thresh", "old", ">", " ", "values", " ", "are", " ", "read", " ", "in", " ", "the", " ", "XML", " ", "pars", "ing", "._", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "m_", "._", "group_", "(_", "1_", ")_", "==_", "\"", "r", "\"_", "and_", "prev", "2", "Value_", "!=_", "sys_", "._", "maxint_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", "print", "(\"", "ramp", " ", "data", " ", "\"", " ", "+", " ", "str", "(", "prev", "2", "Value", ")", " ", "+", " ", "\"", " ", "-", " ", "\"", " ", "+", " ", "str", "(", "prev", "Value", "))", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", "print", "(\"", "ramp", " ", "color", " ", "\"", " ", "+", " ", "str", "(", "prev", "RGB", ")", " ", "+", " ", "\"", " ", "-", " ", "\"", " ", "+", " ", "str", "(", "curr", "RGB", "))", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "color", "Steps_", "=_", "ramp", "Den", "sif", "y_", "(_", "prev", "RGB_", ",_", "curr", "RGB_", ",_", "int_", "(_", "m_", "._", "group_", "(_", "2_", ")_", ")_", "+_", "1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", "print", "(", "color", "Step", "s", ")_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "data", "Steps_", "=_", "data", "Den", "sif", "y_", "(_", "prev", "2", "Value_", ",_", "prev", "Value_", ",_", "int_", "(_", "m_", "._", "group_", "(_", "2_", ")_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", "print", "(", "data", "Step", "s", ")_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "prev", "Value_", "=_", "prev", "2", "Value_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "for_", "step_", "in_", "range_", "(_", "0_", ",_", "int_", "(_", "m_", "._", "group_", "(_", "2_", ")_", ")_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", "print", "(", "data", "Step", "s", "[", "step", "])", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", "print", "(", "color", "Step", "s", "[", "step", "])", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "gib", "s", "CM", "ap", "Entry_", "=_", "GI", "BS", "\\u", "Color", "Map", "Entry_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "gib", "s", "CM", "ap", "Entry_", "._", "transparent_", "=_", "(_", "default", "Opa", "city_", "==_", "0.0_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "gib", "s", "CM", "ap", "Entry_", "._", "rgb_", "=_", "color", "Steps_", "[_", "step_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "gib", "s", "CM", "ap", "Entry_", "._", "label_", "=_", "format_", "._", "format_", "(_", "prev", "Value_", ")_", "+_", "\"", " ", "-", " ", "\"_", "+_", "format_", "._", "format_", "(_", "data", "Steps_", "[_", "step_", "]_", ")_", "+_", "(_", "\"\"_", "if_", "not_", "units_", "else_", "(_", "\"", " ", "\"_", "+_", "units_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "gib", "s", "CM", "ap", "Entry_", "._", "value_", "=_", "[_", "prev", "Value_", ",_", "data", "Steps_", "[_", "step_", "]_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "gib", "s", "CM", "ap", "Entry_", "._", "source", "Value_", "=_", "[_", "(_", "(_", "prev", "Value_", "-_", "offset_", ")_", "/_", "factor_", ")_", ",_", "(_", "(_", "data", "Steps_", "[_", "step_", "]_", "-_", "offset_", ")_", "/_", "factor_", ")_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "gib", "s", "CM", "ap", "Entry_", "._", "ref_", "=_", "curr", "Ref_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "gib", "s", "CM", "ap_", "._", "cm", "Entries_", "._", "append_", "(_", "gib", "s", "CM", "ap", "Entry_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "prev", "Value_", "=_", "data", "Steps_", "[_", "step_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "curr", "Ref_", "=_", "curr", "Ref_", "+_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "\"", "Override", "\"", " ", "Den", "sif", "ication", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Captur", "e", " ", "the", " ", "data", " ", "value", " ", "and", " ", "RGB", " ", "for", " ", "the", " ", "first", " ", "entry", " ", "for", " ", "the", " ", "first", " ", "time", " ", "through_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "and", " ", "then", " ", "just", " ", "ignore", " ", "it", " ", "after", " ", "tha", "t", " _", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "m_", "._", "group_", "(_", "1_", ")_", "==_", "\"", "o", "\"_", "and_", "first", "Value_", "==_", "sys_", "._", "maxint_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "first", "Value_", "=_", "prev", "Value_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "first", "RGB_", "=_", "curr", "RGB_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "prev", "2", "Value_", "=_", "prev", "Value_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "prev", "Value_", "=_", "curr", "Value_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "prev", "2", "RGB_", "=_", "prev", "RGB_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "prev", "RGB_", "=_", "curr", "RGB_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "End", ":", " ", "Loop", " ", "through", " ", "the", " ", "<", "Value", ">", " ", "and", " ", "<", "Thresh", "old", ">", " ", "elements_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "No", "w", " ", "process", " ", "the", " ", "final", " ", "color", " ", "entry_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "dens", "ify_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "m_", "=_", "re_", "._", "match_", "(_", "r", "\"([", "sr", "o", "])(", "[", "0", "-", "9", "]*)", "\"_", ",_", "dens", "ify_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "\"", "Ramp", "\"", " ", "Den", "sif", "ication", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Be", "caus", "e", " ", "of", " ", "the", " ", "lag", "ging", " ", "<", "Thresh", "old", ">", " ", "pars", "ing", ",", " ", "we", " ", "now", " ", "need", " ", "to", " ", "add", " ", "the", " ", "last", " ", "ramp", "ed_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "section", " ", "of", " ", "the", " ", "colormap", "._", "\\u\\u\\uNL\\u\\u\\u_", "if_", "m_", "._", "group_", "(_", "1_", ")_", "==_", "\"", "r", "\"_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", "print", "(\"", "ramp", " ", "data", " ", "\"", " ", "+", " ", "str", "(", "prev", "2", "Value", ")", " ", "+", " ", "\"", " ", "-", " ", "\"", " ", "+", " ", "str", "(", "prev", "Value", "))", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", "print", "(\"", "ramp", " ", "color", " ", "\"", " ", "+", " ", "str", "(", "prev", "RGB", ")", " ", "+", " ", "\"", " ", "-", " ", "\"", " ", "+", " ", "str", "(", "curr", "RGB", "))", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "color", "Steps_", "=_", "ramp", "Den", "sif", "y_", "(_", "prev", "RGB_", ",_", "curr", "RGB_", ",_", "int_", "(_", "m_", "._", "group_", "(_", "2_", ")_", ")_", "+_", "1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", "print", "(", "color", "Step", "s", ")_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "data", "Steps_", "=_", "data", "Den", "sif", "y_", "(_", "prev", "2", "Value_", ",_", "prev", "Value_", ",_", "int_", "(_", "m_", "._", "group_", "(_", "2_", ")_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", "print", "(", "data", "Step", "s", ")_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "prev", "Value_", "=_", "prev", "2", "Value_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "for_", "step_", "in_", "range_", "(_", "0_", ",_", "int_", "(_", "m_", "._", "group_", "(_", "2_", ")_", ")_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", "print", "(", "data", "Step", "s", "[", "step", "])", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", "print", "(", "color", "Step", "s", "[", "step", "])", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "gib", "s", "CM", "ap", "Entry_", "=_", "GI", "BS", "\\u", "Color", "Map", "Entry_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "gib", "s", "CM", "ap", "Entry_", "._", "transparent_", "=_", "(_", "default", "Opa", "city_", "==_", "0.0_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "gib", "s", "CM", "ap", "Entry_", "._", "rgb_", "=_", "color", "Steps_", "[_", "step_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "gib", "s", "CM", "ap", "Entry_", "._", "label_", "=_", "format_", "._", "format_", "(_", "prev", "Value_", ")_", "+_", "\"", " ", "-", " ", "\"_", "+_", "format_", "._", "format_", "(_", "data", "Steps_", "[_", "step_", "]_", ")_", "+_", "(_", "\"\"_", "if_", "not_", "units_", "else_", "(_", "\"", " ", "\"_", "+_", "units_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "gib", "s", "CM", "ap", "Entry_", "._", "value_", "=_", "[_", "prev", "Value_", ",_", "data", "Steps_", "[_", "step_", "]_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "gib", "s", "CM", "ap", "Entry_", "._", "source", "Value_", "=_", "[_", "(_", "(_", "prev", "Value_", "-_", "offset_", ")_", "/_", "factor_", ")_", ",_", "(_", "(_", "data", "Steps_", "[_", "step_", "]_", "-_", "offset_", ")_", "/_", "factor_", ")_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "gib", "s", "CM", "ap", "Entry_", "._", "ref_", "=_", "curr", "Ref_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "gib", "s", "CM", "ap_", "._", "cm", "Entries_", "._", "append_", "(_", "gib", "s", "CM", "ap", "Entry_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "prev", "Value_", "=_", "data", "Steps_", "[_", "step_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "curr", "Ref_", "=_", "curr", "Ref_", "+_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "\"", "Override", "\"", " ", "Den", "sif", "ication", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Creat", "e", " ", "a", " ", "ramp", " ", "over", " ", "the", " ", "entire", " ", "data", " ", "range", " ", "usi", "ng", " ", "the", " ", "start", " ", "and", " ", "finish", " ", "RGB", " ", "values_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "m_", "._", "group_", "(_", "1_", ")_", "==_", "\"", "o", "\"_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", "print", "(\"", "ramp", " ", "data", " ", "\"", " ", "+", " ", "str", "(", "first", "Value", ")", " ", "+", " ", "\"", " ", "-", " ", "\"", " ", "+", " ", "str", "(", "prev", "Value", "))", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", "print", "(\"", "ramp", " ", "color", " ", "\"", " ", "+", " ", "str", "(", "first", "RGB", ")", " ", "+", " ", "\"", " ", "-", " ", "\"", " ", "+", " ", "str", "(", "curr", "RGB", "))", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "color", "Steps_", "=_", "ramp", "Den", "sif", "y_", "(_", "first", "RGB_", ",_", "curr", "RGB_", ",_", "int_", "(_", "m_", "._", "group_", "(_", "2_", ")_", ")_", "+_", "1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", "print", "(", "color", "Step", "s", ")_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "data", "Steps_", "=_", "data", "Den", "sif", "y_", "(_", "first", "Value_", ",_", "prev", "Value_", ",_", "int_", "(_", "m_", "._", "group_", "(_", "2_", ")_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", "print", "(", "data", "Step", "s", ")_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "prev", "Value_", "=_", "first", "Value_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "for_", "step_", "in_", "range_", "(_", "0_", ",_", "int_", "(_", "m_", "._", "group_", "(_", "2_", ")_", ")_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", "print", "(", "data", "Step", "s", "[", "step", "])", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", "print", "(", "color", "Step", "s", "[", "step", "])", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "gib", "s", "CM", "ap", "Entry_", "=_", "GI", "BS", "\\u", "Color", "Map", "Entry_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "gib", "s", "CM", "ap", "Entry_", "._", "transparent_", "=_", "(_", "default", "Opa", "city_", "==_", "0.0_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "gib", "s", "CM", "ap", "Entry_", "._", "rgb_", "=_", "color", "Steps_", "[_", "step_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "gib", "s", "CM", "ap", "Entry_", "._", "label_", "=_", "format_", "._", "format_", "(_", "prev", "Value_", ")_", "+_", "\"", " ", "-", " ", "\"_", "+_", "format_", "._", "format_", "(_", "data", "Steps_", "[_", "step_", "]_", ")_", "+_", "(_", "\"\"_", "if_", "not_", "units_", "else_", "(_", "\"", " ", "\"_", "+_", "units_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "gib", "s", "CM", "ap", "Entry_", "._", "value_", "=_", "[_", "prev", "Value_", ",_", "data", "Steps_", "[_", "step_", "]_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "gib", "s", "CM", "ap", "Entry_", "._", "source", "Value_", "=_", "[_", "(_", "(_", "prev", "Value_", "-_", "offset_", ")_", "/_", "factor_", ")_", ",_", "(_", "(_", "data", "Steps_", "[_", "step_", "]_", "-_", "offset_", ")_", "/_", "factor_", ")_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "gib", "s", "CM", "ap", "Entry_", "._", "ref_", "=_", "curr", "Ref_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "gib", "s", "CM", "ap_", "._", "cm", "Entries_", "._", "append_", "(_", "gib", "s", "CM", "ap", "Entry_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "prev", "Value_", "=_", "data", "Steps_", "[_", "step_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "curr", "Ref_", "=_", "curr", "Ref_", "+_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Add", " ", "the", " ", "final", " ", "Color", "map", " ", "Entr", "y", " ", "for", " ", "the", " ", "[", "curr", "Value", ",", " ", "+", "INF", ")", " ", "data", " ", "range_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "gib", "s", "CM", "ap", "Entry_", "=_", "GI", "BS", "\\u", "Color", "Map", "Entry_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "gib", "s", "CM", "ap", "Entry_", "._", "rgb_", "=_", "curr", "RGB_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "gib", "s", "CM", "ap", "Entry_", "._", "transparent_", "=_", "(_", "default", "Opa", "city_", "==_", "0.0_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "gib", "s", "CM", "ap", "Entry_", "._", "label_", "=_", "\"&", "gt", ";", "=", " ", "\"_", "+_", "format_", "._", "format_", "(_", "prev", "Value_", ")_", "+_", "(_", "\"\"_", "if_", "not_", "units_", "else_", "(_", "\"", " ", "\"_", "+_", "units_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "gib", "s", "CM", "ap", "Entry_", "._", "value_", "=_", "[_", "prev", "Value_", ",_", "\"+", "INF", "\"_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "gib", "s", "CM", "ap", "Entry_", "._", "source", "Value_", "=_", "[_", "(_", "(_", "prev", "Value_", "-_", "offset_", ")_", "/_", "factor_", ")_", ",_", "\"+", "INF", "\"_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "gib", "s", "CM", "ap", "Entry_", "._", "ref_", "=_", "curr", "Ref_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "gib", "s", "CM", "ap_", "._", "cm", "Entries_", "._", "append_", "(_", "gib", "s", "CM", "ap", "Entry_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "gib", "s", "CM", "ap_", "._", "max", "Label_", "=_", "\"&", "gt", ";", "=", " ", "\"_", "+_", "format_", "._", "format_", "(_", "prev", "Value_", ")_", "+_", "(_", "\"\"_", "if_", "not_", "units_", "else_", "(_", "\"", " ", "\"_", "+_", "units_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "gib", "s", "CM", "ap_", "._", "show", "Units_", "=_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "gib", "s", "CM", "ap_", "._", "show", "Legend", "_", "=_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "gib", "s", "Color", "Maps_", "._", "append_", "(_", "gib", "s", "CM", "ap_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "gib", "s", "Color", "Maps_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "generat", "e", "Color", "Map_", "(_", "gib", "s", "Color", "Maps_", ",_", "units_", ",_", "format_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "print_", "(_", "\"<", "?", "xml", " ", "version", "=\\\\\"", "1.0", "\\\\\"", " ", "encoding", "=\\\\\"", "UT", "F", "-", "8", "\\\\\"", "?>", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "print_", "(_", "\"<", "Color", "Map", "s", ">\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "for_", "color", "Map_", "in_", "gib", "s", "Color", "Maps_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "<", "Color", "Map", " ", "title", "=\"", "Sea", " ", "Ice", " ", "Conce", "ntra", "tion", "\"", " ", "unit", "s", "=\"", "%", "\">", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "print_", "(_", "\"", " ", " ", "<", "Color", "Map", "\"_", "+_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "(_", "\"", " ", "unit", "s", "=\\\\\"", "\"_", "+_", "units_", "+_", "\"\\\\\"\"_", ")_", "if_", "color", "Map_", "._", "show", "Units_", "and_", "units_", "else_", "\"\"_", ")_", "+_", "\">\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "<", "Entr", "ies", " ", "min", "Label", "=\"", "0", " ", "%", "\"", " ", "max", "Label", "=\"", "100", " ", "%", "\">", " _", "\\u\\u\\uNL\\u\\u\\u_", "print_", "(_", "\"", " ", " ", " ", " ", "<", "Entr", "ies", "\"_", "+_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "\"\"_", "if_", "not_", "color", "Map_", "._", "min", "Label_", "else_", "(_", "\"", " ", "min", "Label", "=\\\\\"", "\"_", "+_", "color", "Map_", "._", "min", "Label_", "+_", "\"\\\\\"", " ", "\"_", ")_", ")_", "+_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "\"\"_", "if_", "not_", "color", "Map_", "._", "max", "Label_", "else_", "(_", "\"", " ", "max", "Label", "=\\\\\"", "\"_", "+_", "color", "Map_", "._", "max", "Label_", "+_", "\"\\\\\"\"_", ")_", ")_", "+_", "\">\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "for_", "c", "Map", "Entry_", "in_", "color", "Map_", "._", "cm", "Entries_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "<", "Color", "Map", "Entr", "y", " ", "rgb", "=\"", "9", ",", "9", ",", "255", "\"", " ", "transp", "arent", "=\"", "fal", "se", "\"", " ", "source", "Value", "=\"", "[", "9", ",", "10", ")\"", " ", "value", "=\"", "[", "9", ",", "10", ")\"", " ", "label", "=\"", "3.6", " ", "%", "\"", " ", "ref", "=\"", "1", "\"/>", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "rgb_", "=_", "str_", "(_", "c", "Map", "Entry_", "._", "rgb_", "[_", "0_", "]_", ")_", "+_", "\",\"_", "+_", "str_", "(_", "c", "Map", "Entry_", "._", "rgb_", "[_", "1_", "]_", ")_", "+_", "\",\"_", "+_", "str_", "(_", "c", "Map", "Entry_", "._", "rgb_", "[_", "2_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "c", "Map", "Entry_", "._", "value_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "len_", "(_", "c", "Map", "Entry_", "._", "value_", ")_", "==_", "1_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "value_", "=_", "\"[\"_", "+_", "(_", "c", "Map", "Entry_", "._", "value_", "[_", "0_", "]_", "if_", "isinstance_", "(_", "c", "Map", "Entry_", "._", "value_", "[_", "0_", "]_", ",_", "str_", ")_", "else_", "format_", "._", "format_", "(_", "c", "Map", "Entry_", "._", "value_", "[_", "0_", "]_", ")_", ")_", "+_", "\"]\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "value_", "=_", "\"[\"_", "+_", "(_", "c", "Map", "Entry_", "._", "value_", "[_", "0_", "]_", "if_", "isinstance_", "(_", "c", "Map", "Entry_", "._", "value_", "[_", "0_", "]_", ",_", "str_", ")_", "else_", "format_", "._", "format_", "(_", "c", "Map", "Entry_", "._", "value_", "[_", "0_", "]_", ")_", ")_", "+_", "\",\"_", "+_", "(_", "c", "Map", "Entry_", "._", "value_", "[_", "1_", "]_", "if_", "isinstance_", "(_", "c", "Map", "Entry_", "._", "value_", "[_", "1_", "]_", ",_", "str_", ")_", "else_", "format_", "._", "format_", "(_", "c", "Map", "Entry_", "._", "value_", "[_", "1_", "]_", ")_", ")_", "+_", "\")\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "c", "Map", "Entry_", "._", "source", "Value_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "len_", "(_", "c", "Map", "Entry_", "._", "source", "Value_", ")_", "==_", "1_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "source", "Value_", "=_", "\"[\"_", "+_", "(_", "c", "Map", "Entry_", "._", "source", "Value_", "[_", "0_", "]_", "if_", "isinstance_", "(_", "c", "Map", "Entry_", "._", "source", "Value_", "[_", "0_", "]_", ",_", "str_", ")_", "else_", "format_", "._", "format_", "(_", "c", "Map", "Entry_", "._", "source", "Value_", "[_", "0_", "]_", ")_", ")_", "+_", "\"]\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "source", "Value_", "=_", "\"[\"_", "+_", "(_", "c", "Map", "Entry_", "._", "source", "Value_", "[_", "0_", "]_", "if_", "isinstance_", "(_", "c", "Map", "Entry_", "._", "source", "Value_", "[_", "0_", "]_", ",_", "str_", ")_", "else_", "format_", "._", "format_", "(_", "c", "Map", "Entry_", "._", "source", "Value_", "[_", "0_", "]_", ")_", ")_", "+_", "\",\"_", "+_", "(_", "c", "Map", "Entry_", "._", "source", "Value_", "[_", "1_", "]_", "if_", "isinstance_", "(_", "c", "Map", "Entry_", "._", "source", "Value_", "[_", "1_", "]_", ",_", "str_", ")_", "else_", "format_", "._", "format_", "(_", "c", "Map", "Entry_", "._", "source", "Value_", "[_", "1_", "]_", ")_", ")_", "+_", "\")\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "print_", "(_", "\"", " ", " ", "<", "Color", "Map", "Entr", "y", " ", "rgb", "=\\\\\"", "\"_", "+_", "rgb_", "+_", "\"\\\\\"", " ", "\"_", "+_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "transp", "arent", "=\\\\\"", "\"_", "+_", "(_", "\"", "true", "\"_", "if_", "c", "Map", "Entry_", "._", "transparent_", "else_", "\"", "fal", "se", "\"_", ")_", "+_", "\"\\\\\"", " ", "\"_", "+_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "\"\"_", "if_", "not_", "c", "Map", "Entry_", "._", "source", "Value_", "else_", "(_", "\"", "source", "Value", "=\\\\\"", "\"_", "+_", "value_", "+_", "\"\\\\\"", " ", "\"_", ")_", ")_", "+_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "\"\"_", "if_", "not_", "c", "Map", "Entry_", "._", "value_", "else_", "(_", "\"", "value", "=\\\\\"", "\"_", "+_", "value_", "+_", "\"\\\\\"", " ", "\"_", ")_", ")_", "+_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "label", "=\\\\\"", "\"_", "+_", "c", "Map", "Entry_", "._", "label_", "+_", "\"\\\\\"", " ", "\"_", "+_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "\"\"_", "if_", "not_", "c", "Map", "Entry_", "._", "nodata", "_", "else_", "(_", "\"", "nodata", "=\\\\\"", "true", "\\\\\"", " ", "\"_", ")_", ")_", "+_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "\"\"_", "if_", "not_", "color", "Map_", "._", "show", "Legend", "_", "else_", "(_", "\"", "ref", "=\\\\\"", "\"_", "+_", "str_", "(_", "c", "Map", "Entry_", "._", "ref_", ")_", "+_", "\"\\\\\"", " ", "\"_", ")_", ")_", "+_", "\\u\\u\\uNL\\u\\u\\u_", "\"/>", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "print_", "(_", "\"", " ", " ", " ", " ", "</", "Entr", "ies", ">\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "color", "Map_", "._", "show", "Legend", "_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "<", "Entr", "ies", " ", "min", "Label", "=\"", "0", " ", "%", "\"", " ", "max", "Label", "=\"", "100", " ", "%", "\">", " _", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "print_", "(_", "\"", " ", " ", " ", " ", "<", "Legend", " ", "type", "=\\\\\"", "continuous", "\\\\\"", " ", "\"_", "+_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "\"\"_", "if_", "not_", "color", "Map_", "._", "min", "Label_", "else_", "(_", "\"", " ", "min", "Label", "=\\\\\"", "\"_", "+_", "color", "Map_", "._", "min", "Label_", "+_", "\"\\\\\"", " ", "\"_", ")_", ")_", "+_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "\"\"_", "if_", "not_", "color", "Map_", "._", "max", "Label_", "else_", "(_", "\"", " ", "max", "Label", "=\\\\\"", "\"_", "+_", "color", "Map_", "._", "max", "Label_", "+_", "\"\\\\\"\"_", ")_", ")_", "+_", "\">\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "prev", "Ref_", "=_", "-_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "for_", "c", "Map", "Entry_", "in_", "color", "Map_", "._", "cm", "Entries_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "c", "Map", "Entry_", "._", "ref_", "!=_", "prev", "Ref_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "rgb_", "=_", "str_", "(_", "c", "Map", "Entry_", "._", "rgb_", "[_", "0_", "]_", ")_", "+_", "\",\"_", "+_", "str_", "(_", "c", "Map", "Entry_", "._", "rgb_", "[_", "1_", "]_", ")_", "+_", "\",\"_", "+_", "str_", "(_", "c", "Map", "Entry_", "._", "rgb_", "[_", "2_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "c", "Map", "Entry_", "._", "value_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "if_", "len_", "(_", "c", "Map", "Entry_", "._", "value_", ")_", "==_", "1_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "value_", "=_", "\"[\"_", "+_", "(_", "c", "Map", "Entry_", "._", "value_", "[_", "0_", "]_", "if_", "isinstance_", "(_", "c", "Map", "Entry_", "._", "value_", "[_", "0_", "]_", ",_", "str_", ")_", "else_", "format_", "._", "format_", "(_", "c", "Map", "Entry_", "._", "value_", "[_", "0_", "]_", ")_", ")_", "+_", "\"]\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "value_", "=_", "\"[\"_", "+_", "(_", "c", "Map", "Entry_", "._", "value_", "[_", "0_", "]_", "if_", "isinstance_", "(_", "c", "Map", "Entry_", "._", "value_", "[_", "0_", "]_", ",_", "str_", ")_", "else_", "format_", "._", "format_", "(_", "c", "Map", "Entry_", "._", "value_", "[_", "0_", "]_", ")_", ")_", "+_", "\",\"_", "+_", "(_", "c", "Map", "Entry_", "._", "value_", "[_", "1_", "]_", "if_", "isinstance_", "(_", "c", "Map", "Entry_", "._", "value_", "[_", "1_", "]_", ",_", "str_", ")_", "else_", "format_", "._", "format_", "(_", "c", "Map", "Entry_", "._", "value_", "[_", "1_", "]_", ")_", ")_", "+_", "\")\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "print_", "(_", "\"", " ", " ", "<", "Legend", "Entr", "y", " ", "rgb", "=\\\\\"", "\"_", "+_", "rgb_", "+_", "\"\\\\\"", " ", "\"_", "+_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "\"\"_", "if_", "not_", "color", "Map_", "._", "show", "Legend", "_", "else_", "(_", "\"", "id", "=\\\\\"", "\"_", "+_", "str_", "(_", "c", "Map", "Entry_", "._", "ref_", ")_", "+_", "\"\\\\\"", " ", "\"_", ")_", ")_", "+_", "\"/>", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "prev", "Ref_", "=_", "c", "Map", "Entry_", "._", "ref_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "print_", "(_", "\"", " ", " ", " ", " ", "</", "Legend", ">\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "print_", "(_", "\"", " ", " ", "</", "Color", "Map", ">\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "print_", "(_", "\"<", "/", "Color", "Map", "s", ">\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_" ]
[ 4, 4, 4, 4, 4, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 ]
Except block handles 'BaseException'
QuantSoftware/QuantSoftwareToolkit/Legacy/epydoc-3.0.1/epydoc/docwriter/html_colorize.py
[ { "content": "#\n# epydoc.html: HTML colorizers\n# Edward Loper\n#\n# Created [10/16/02 09:49 PM]\n# $Id: html_colorize.py 1674 2008-01-29 06:03:36Z edloper $\n#\n\n\"\"\"\nFunctions to produce colorized HTML code for various objects.\nCurrently, C{html_colorize} defines functions to colorize\nPython source code.\n\"\"\"\n__docformat__ = 'epytext en'\n\nimport re, codecs\nfrom epydoc import log\nfrom epydoc.util import py_src_filename\nfrom epydoc.apidoc import *\nimport tokenize, token, cgi, keyword\ntry: from cStringIO import StringIO\nexcept: from StringIO import StringIO\n\n######################################################################\n## Python source colorizer\n######################################################################\n\"\"\"\nGoals:\n - colorize tokens appropriately (using css)\n - optionally add line numbers\n - \n\"\"\"\n\n#: Javascript code for the PythonSourceColorizer\nPYSRC_JAVASCRIPTS = '''\\\nfunction expand(id) {\n var elt = document.getElementById(id+\"-expanded\");\n if (elt) elt.style.display = \"block\";\n var elt = document.getElementById(id+\"-expanded-linenums\");\n if (elt) elt.style.display = \"block\";\n var elt = document.getElementById(id+\"-collapsed\");\n if (elt) { elt.innerHTML = \"\"; elt.style.display = \"none\"; }\n var elt = document.getElementById(id+\"-collapsed-linenums\");\n if (elt) { elt.innerHTML = \"\"; elt.style.display = \"none\"; }\n var elt = document.getElementById(id+\"-toggle\");\n if (elt) { elt.innerHTML = \"-\"; }\n}\n\nfunction collapse(id) {\n var elt = document.getElementById(id+\"-expanded\");\n if (elt) elt.style.display = \"none\";\n var elt = document.getElementById(id+\"-expanded-linenums\");\n if (elt) elt.style.display = \"none\";\n var elt = document.getElementById(id+\"-collapsed-linenums\");\n if (elt) { elt.innerHTML = \"<br />\"; elt.style.display=\"block\"; }\n var elt = document.getElementById(id+\"-toggle\");\n if (elt) { elt.innerHTML = \"+\"; }\n var elt = document.getElementById(id+\"-collapsed\");\n if (elt) {\n elt.style.display = \"block\";\n \n var indent = elt.getAttribute(\"indent\");\n var pad = elt.getAttribute(\"pad\");\n var s = \"<tt class=\\'py-lineno\\'>\";\n for (var i=0; i<pad.length; i++) { s += \"&nbsp;\" }\n s += \"</tt>\";\n s += \"&nbsp;&nbsp;<tt class=\\'py-line\\'>\";\n for (var i=0; i<indent.length; i++) { s += \"&nbsp;\" }\n s += \"<a href=\\'#\\' onclick=\\'expand(\\\\\"\" + id;\n s += \"\\\\\");return false\\'>...</a></tt><br />\";\n elt.innerHTML = s;\n }\n}\n\nfunction toggle(id) {\n elt = document.getElementById(id+\"-toggle\");\n if (elt.innerHTML == \"-\")\n collapse(id); \n else\n expand(id);\n return false;\n}\n\nfunction highlight(id) {\n var elt = document.getElementById(id+\"-def\");\n if (elt) elt.className = \"py-highlight-hdr\";\n var elt = document.getElementById(id+\"-expanded\");\n if (elt) elt.className = \"py-highlight\";\n var elt = document.getElementById(id+\"-collapsed\");\n if (elt) elt.className = \"py-highlight\";\n}\n\nfunction num_lines(s) {\n var n = 1;\n var pos = s.indexOf(\"\\\\n\");\n while ( pos > 0) {\n n += 1;\n pos = s.indexOf(\"\\\\n\", pos+1);\n }\n return n;\n}\n\n// Collapse all blocks that mave more than `min_lines` lines.\nfunction collapse_all(min_lines) {\n var elts = document.getElementsByTagName(\"div\");\n for (var i=0; i<elts.length; i++) {\n var elt = elts[i];\n var split = elt.id.indexOf(\"-\");\n if (split > 0)\n if (elt.id.substring(split, elt.id.length) == \"-expanded\")\n if (num_lines(elt.innerHTML) > min_lines)\n collapse(elt.id.substring(0, split));\n }\n}\n\nfunction expandto(href) {\n var start = href.indexOf(\"#\")+1;\n if (start != 0 && start != href.length) {\n if (href.substring(start, href.length) != \"-\") {\n collapse_all(4);\n pos = href.indexOf(\".\", start);\n while (pos != -1) {\n var id = href.substring(start, pos);\n expand(id);\n pos = href.indexOf(\".\", pos+1);\n }\n var id = href.substring(start, href.length);\n expand(id);\n highlight(id);\n }\n }\n}\n\nfunction kill_doclink(id) {\n var parent = document.getElementById(id);\n parent.removeChild(parent.childNodes.item(0));\n}\nfunction auto_kill_doclink(ev) {\n if (!ev) var ev = window.event;\n if (!this.contains(ev.toElement)) {\n var parent = document.getElementById(this.parentID);\n parent.removeChild(parent.childNodes.item(0));\n }\n}\n\nfunction doclink(id, name, targets_id) {\n var elt = document.getElementById(id);\n\n // If we already opened the box, then destroy it.\n // (This case should never occur, but leave it in just in case.)\n if (elt.childNodes.length > 1) {\n elt.removeChild(elt.childNodes.item(0));\n }\n else {\n // The outer box: relative + inline positioning.\n var box1 = document.createElement(\"div\");\n box1.style.position = \"relative\";\n box1.style.display = \"inline\";\n box1.style.top = 0;\n box1.style.left = 0;\n \n // A shadow for fun\n var shadow = document.createElement(\"div\");\n shadow.style.position = \"absolute\";\n shadow.style.left = \"-1.3em\";\n shadow.style.top = \"-1.3em\";\n shadow.style.background = \"#404040\";\n \n // The inner box: absolute positioning.\n var box2 = document.createElement(\"div\");\n box2.style.position = \"relative\";\n box2.style.border = \"1px solid #a0a0a0\";\n box2.style.left = \"-.2em\";\n box2.style.top = \"-.2em\";\n box2.style.background = \"white\";\n box2.style.padding = \".3em .4em .3em .4em\";\n box2.style.fontStyle = \"normal\";\n box2.onmouseout=auto_kill_doclink;\n box2.parentID = id;\n\n // Get the targets\n var targets_elt = document.getElementById(targets_id);\n var targets = targets_elt.getAttribute(\"targets\");\n var links = \"\";\n target_list = targets.split(\",\");\n for (var i=0; i<target_list.length; i++) {\n var target = target_list[i].split(\"=\");\n links += \"<li><a href=\\'\" + target[1] + \n \"\\' style=\\'text-decoration:none\\'>\" +\n target[0] + \"</a></li>\";\n }\n \n // Put it all together.\n elt.insertBefore(box1, elt.childNodes.item(0));\n //box1.appendChild(box2);\n box1.appendChild(shadow);\n shadow.appendChild(box2);\n box2.innerHTML =\n \"Which <b>\"+name+\"</b> do you want to see documentation for?\" +\n \"<ul style=\\'margin-bottom: 0;\\'>\" +\n links + \n \"<li><a href=\\'#\\' style=\\'text-decoration:none\\' \" +\n \"onclick=\\'kill_doclink(\\\\\"\"+id+\"\\\\\");return false;\\'>\"+\n \"<i>None of the above</i></a></li></ul>\";\n }\n return false;\n}\n'''\n\nPYSRC_EXPANDTO_JAVASCRIPT = '''\\\n<script type=\"text/javascript\">\n<!--\nexpandto(location.href);\n// -->\n</script>\n'''\n\n \n_HDR = '''\\\n<?xml version=\"1.0\" encoding=\"ascii\"?>\n <!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\"\n \"DTD/xhtml1-transitional.dtd\">\n <html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"en\" lang=\"en\">\n <head>\n <title>$title$</title>\n <link rel=\"stylesheet\" href=\"epydoc.css\" type=\"text/css\" />\n <script type=\"text/javascript\" src=\"epydoc.js\"></script>\n </head>\n \n <body bgcolor=\"white\" text=\"black\" link=\"blue\" vlink=\"#204080\"\n alink=\"#204080\">\n'''\n_FOOT = '</body></html>'\nif __name__=='__main__':\n #s = PythonSourceColorizer('../apidoc.py', 'epydoc.apidoc').colorize()\n s = PythonSourceColorizer('/tmp/fo.py', 'epydoc.apidoc').colorize()\n #print s\n import codecs\n f = codecs.open('/home/edloper/public_html/color3.html', 'w', 'ascii', 'xmlcharrefreplace')\n f.write(_HDR+'<pre id=\"py-src-top\" class=\"py-src\">'+s+'</pre>'+_FOOT)\n f.close()\n", "metadata": "root", "header": "['module', '___EOS___']", "index": 0 }, { "content": " def __init__(self, module_filename, module_name,\n docindex=None, url_func=None, name_to_docs=None,\n tab_width=8):\n \"\"\"\n Create a new HTML colorizer for the specified module.\n\n @param module_filename: The name of the file containing the\n module; its text will be loaded from this file.\n @param module_name: The dotted name of the module; this will\n be used to create links back into the API source\n documentation.\n \"\"\"\n # Get the source version, if possible.\n try: module_filename = py_src_filename(module_filename)\n except: pass\n \n #: The filename of the module we're colorizing.\n self.module_filename = module_filename\n \n #: The dotted name of the module we're colorizing.\n self.module_name = module_name\n\n #: A docindex, used to create href links from identifiers to\n #: the API documentation for their values.\n self.docindex = docindex\n\n #: A mapping from short names to lists of ValueDoc, used to\n #: decide which values an identifier might map to when creating\n #: href links from identifiers to the API docs for their values.\n self.name_to_docs = name_to_docs\n \n #: A function that maps APIDoc -> URL, used to create href\n #: links from identifiers to the API documentation for their\n #: values.\n self.url_func = url_func\n\n #: The index in C{text} of the last character of the last\n #: token we've processed.\n self.pos = 0\n\n #: A list that maps line numbers to character offsets in\n #: C{text}. In particular, line C{M{i}} begins at character\n #: C{line_offset[i]} in C{text}. Since line numbers begin at\n #: 1, the first element of C{line_offsets} is C{None}.\n self.line_offsets = []\n\n #: A list of C{(toktype, toktext)} for all tokens on the\n #: logical line that we are currently processing. Once a\n #: complete line of tokens has been collected in C{cur_line},\n #: it is sent to L{handle_line} for processing.\n self.cur_line = []\n\n #: A list of the names of the class or functions that include\n #: the current block. C{context} has one element for each\n #: level of indentation; C{context[i]} is the name of the class\n #: or function defined by the C{i}th level of indentation, or\n #: C{None} if that level of indentation doesn't correspond to a\n #: class or function definition.\n self.context = []\n\n #: A list, corresponding one-to-one with L{self.context},\n #: indicating the type of each entry. Each element of\n #: C{context_types} is one of: C{'func'}, C{'class'}, C{None}.\n self.context_types = []\n\n #: A list of indentation strings for each of the current\n #: block's indents. I.e., the current total indentation can\n #: be found by taking C{''.join(self.indents)}.\n self.indents = []\n\n #: The line number of the line we're currently processing.\n self.lineno = 0\n\n #: The name of the class or function whose definition started\n #: on the previous logical line, or C{None} if the previous\n #: logical line was not a class or function definition.\n self.def_name = None\n\n #: The type of the class or function whose definition started\n #: on the previous logical line, or C{None} if the previous\n #: logical line was not a class or function definition.\n #: Can be C{'func'}, C{'class'}, C{None}.\n self.def_type = None\n\n #: The number of spaces to replace each tab in source code with\n self.tab_width = tab_width", "metadata": "root.PythonSourceColorizer.__init__", "header": "['class', 'PythonSourceColorizer', ':', '___EOS___']", "index": 325 } ]
[ { "span": "except: ", "start_line": 21, "start_column": 0, "end_line": 21, "end_column": 7 }, { "span": "except: ", "start_line": 339, "start_column": 8, "end_line": 339, "end_column": 15 } ]
[]
1
true
[ "[CLS]_", "Except", "_", "block_", "handles_", "'", "Base", "Except", "ion", "'_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "#", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "ep", "ydo", "c", ".", "html", ":", " ", "HTM", "L", " ", "coloriz", "ers_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Ed", "ward", " ", "Lo", "per_", "\\u\\u\\uNL\\u\\u\\u_", "#", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Creat", "ed", " ", "[", "10", "/", "16", "/", "02", " ", "09", ":", "4", "9", " ", "PM", "]_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "$", "Id", ":", " ", "html", "\\u", "coloriz", "e", ".", "py", " ", "167", "4", " ", "2008", "-0", "1", "-", "2", "9", " ", "0", "6", ":", "03", ":", "3", "6", "Z", " ", "edl", "oper", " ", "$", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\"\"\"", "\\", "10", ";", "Function", "s", " ", "to", " ", "produce", " ", "coloriz", "ed", " ", "HTM", "L", " ", "code", " ", "for", " ", "vari", "ous", " ", "object", "s", ".", "\\", "10", ";", "Curr", "ent", "ly", ",", " ", "C", "{", "html", "\\u", "coloriz", "e", "}", " ", "defin", "es", " ", "function", "s", " ", "to", " ", "coloriz", "e", "\\", "10", ";", "Pyth", "on", " ", "source", " ", "code", ".", "\\", "10", ";\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u", "docformat", "\\u\\u_", "=_", "'", "ep", "yte", "xt", " ", "en", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "import_", "re_", ",_", "codecs_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "ep", "ydo", "c_", "import_", "log_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "ep", "ydo", "c_", "._", "util_", "import_", "py", "\\u", "src", "\\u", "filename_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "ep", "ydo", "c_", "._", "apid", "oc_", "import_", "*_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "tokenize_", ",_", "token_", ",_", "cgi_", ",_", "keyword_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "try_", ":_", "from_", "c", "String", "IO_", "import_", "String", "IO_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "except_", ":_", "from_", "String", "IO_", "import_", "String", "IO_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "###########", "###########", "###########", "###########", "###########", "###########", "###", "#", "_", "\\u\\u\\uNL\\u\\u\\u_", "##", " ", "Pyth", "on", " ", "source", " ", "coloriz", "er_", "\\u\\u\\uNL\\u\\u\\u_", "###########", "###########", "###########", "###########", "###########", "###########", "###", "#", "_", "\\u\\u\\uNL\\u\\u\\u_", "\"\"\"", "\\", "10", ";", "Goal", "s", ":", "\\", "10", ";", " ", " ", "-", " ", "coloriz", "e", " ", "token", "s", " ", "appropr", "iate", "ly", " ", "(", "usi", "ng", " ", "css", ")", "\\", "10", ";", " ", " ", "-", " ", "option", "ally", " ", "add", " ", "line", " ", "numbers", "\\", "10", ";", " ", " ", "-", " ", "\\", "10", ";\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", ":", " ", "Javascript", " ", "code", " ", "for", " ", "the", " ", "Pyth", "on", "Sou", "rce", "Color", "izer_", "\\u\\u\\uNL\\u\\u\\u_", "PY", "SR", "C", "\\u", "JAVA", "SCRIPT", "S_", "=_", "'''", "\\\\", "\\", "10", ";", "function", " ", "expand", "(", "id", ")", " ", "{", "\\", "10", ";", " ", " ", "var", " ", "elt", " ", "=", " ", "document", ".", "get", "Element", "By", "Id", "(", "id", "+\"", "-", "expand", "ed", "\");", "\\", "10", ";", " ", " ", "if", " ", "(", "elt", ")", " ", "elt", ".", "style", ".", "display", " ", "=", " ", "\"", "block", "\";", "\\", "10", ";", " ", " ", "var", " ", "elt", " ", "=", " ", "document", ".", "get", "Element", "By", "Id", "(", "id", "+\"", "-", "expand", "ed", "-", "linenum", "s", "\");", "\\", "10", ";", " ", " ", "if", " ", "(", "elt", ")", " ", "elt", ".", "style", ".", "display", " ", "=", " ", "\"", "block", "\";", "\\", "10", ";", " ", " ", "var", " ", "elt", " ", "=", " ", "document", ".", "get", "Element", "By", "Id", "(", "id", "+\"", "-", "collapsed", "\");", "\\", "10", ";", " ", " ", "if", " ", "(", "elt", ")", " ", "{", " ", "elt", ".", "inner", "HTM", "L", " ", "=", " ", "\"\"", ";", " ", "elt", ".", "style", ".", "display", " ", "=", " ", "\"", "none", "\";", " ", "}", "\\", "10", ";", " ", " ", "var", " ", "elt", " ", "=", " ", "document", ".", "get", "Element", "By", "Id", "(", "id", "+\"", "-", "collapsed", "-", "linenum", "s", "\");", "\\", "10", ";", " ", " ", "if", " ", "(", "elt", ")", " ", "{", " ", "elt", ".", "inner", "HTM", "L", " ", "=", " ", "\"\"", ";", " ", "elt", ".", "style", ".", "display", " ", "=", " ", "\"", "none", "\";", " ", "}", "\\", "10", ";", " ", " ", "var", " ", "elt", " ", "=", " ", "document", ".", "get", "Element", "By", "Id", "(", "id", "+\"", "-", "toggle", "\");", "\\", "10", ";", " ", " ", "if", " ", "(", "elt", ")", " ", "{", " ", "elt", ".", "inner", "HTM", "L", " ", "=", " ", "\"-", "\";", " ", "}", "\\", "10", ";}", "\\", "10", ";", "\\", "10", ";", "function", " ", "collapse", "(", "id", ")", " ", "{", "\\", "10", ";", " ", " ", "var", " ", "elt", " ", "=", " ", "document", ".", "get", "Element", "By", "Id", "(", "id", "+\"", "-", "expand", "ed", "\");", "\\", "10", ";", " ", " ", "if", " ", "(", "elt", ")", " ", "elt", ".", "style", ".", "display", " ", "=", " ", "\"", "none", "\";", "\\", "10", ";", " ", " ", "var", " ", "elt", " ", "=", " ", "document", ".", "get", "Element", "By", "Id", "(", "id", "+\"", "-", "expand", "ed", "-", "linenum", "s", "\");", "\\", "10", ";", " ", " ", "if", " ", "(", "elt", ")", " ", "elt", ".", "style", ".", "display", " ", "=", " ", "\"", "none", "\";", "\\", "10", ";", " ", " ", "var", " ", "elt", " ", "=", " ", "document", ".", "get", "Element", "By", "Id", "(", "id", "+\"", "-", "collapsed", "-", "linenum", "s", "\");", "\\", "10", ";", " ", " ", "if", " ", "(", "elt", ")", " ", "{", " ", "elt", ".", "inner", "HTM", "L", " ", "=", " ", "\"<", "br", " ", "/>", "\";", " ", "elt", ".", "style", ".", "display", "=\"", "block", "\";", " ", "}", "\\", "10", ";", " ", " ", "var", " ", "elt", " ", "=", " ", "document", ".", "get", "Element", "By", "Id", "(", "id", "+\"", "-", "toggle", "\");", "\\", "10", ";", " ", " ", "if", " ", "(", "elt", ")", " ", "{", " ", "elt", ".", "inner", "HTM", "L", " ", "=", " ", "\"+", "\";", " ", "}", "\\", "10", ";", " ", " ", "var", " ", "elt", " ", "=", " ", "document", ".", "get", "Element", "By", "Id", "(", "id", "+\"", "-", "collapsed", "\");", "\\", "10", ";", " ", " ", "if", " ", "(", "elt", ")", " ", "{", "\\", "10", ";", " ", " ", " ", " ", "elt", ".", "style", ".", "display", " ", "=", " ", "\"", "block", "\";", "\\", "10", ";", " ", " ", " ", " ", "\\", "10", ";", " ", " ", " ", " ", "var", " ", "indent", " ", "=", " ", "elt", ".", "get", "Attribute", "(\"", "indent", "\");", "\\", "10", ";", " ", " ", " ", " ", "var", " ", "pad", " ", "=", " ", "elt", ".", "get", "Attribute", "(\"", "pad", "\");", "\\", "10", ";", " ", " ", " ", " ", "var", " ", "s", " ", "=", " ", "\"<", "tt", " ", "class", "=\\\\", "'", "py", "-", "linen", "o", "\\\\'", ">\"", ";", "\\", "10", ";", " ", " ", " ", " ", "for", " ", "(", "var", " ", "i", "=", "0", ";", " ", "i", "<", "pad", ".", "length", ";", " ", "i", "++", ")", " ", "{", " ", "s", " ", "+=", " ", "\"&", "nb", "sp", ";", "\"", " ", "}", "\\", "10", ";", " ", " ", " ", " ", "s", " ", "+=", " ", "\"<", "/", "tt", ">\"", ";", "\\", "10", ";", " ", " ", " ", " ", "s", " ", "+=", " ", "\"&", "nb", "sp", ";", "&", "nb", "sp", ";<", "tt", " ", "class", "=\\\\", "'", "py", "-", "line", "\\\\'", ">\"", ";", "\\", "10", ";", " ", " ", " ", " ", "for", " ", "(", "var", " ", "i", "=", "0", ";", " ", "i", "<", "indent", ".", "length", ";", " ", "i", "++", ")", " ", "{", " ", "s", " ", "+=", " ", "\"&", "nb", "sp", ";", "\"", " ", "}", "\\", "10", ";", " ", " ", " ", " ", "s", " ", "+=", " ", "\"<", "a", " ", "href", "=\\\\", "'#", "\\\\'", " ", "onc", "lick", "=\\\\", "'", "expand", "(\\\\\\\\", "\"\"", " ", "+", " ", "id", ";", "\\", "10", ";", " ", " ", " ", " ", "s", " ", "+=", " ", "\"\\\\\\\\", "\");", "return", " ", "fal", "se", "\\\\'", ">.", "..", "</", "a", "><", "/", "tt", "><", "br", " ", "/>", "\";", "\\", "10", ";", " ", " ", " ", " ", "elt", ".", "inner", "HTM", "L", " ", "=", " ", "s", ";", "\\", "10", ";", " ", " ", "}", "\\", "10", ";}", "\\", "10", ";", "\\", "10", ";", "function", " ", "toggle", "(", "id", ")", " ", "{", "\\", "10", ";", " ", " ", "elt", " ", "=", " ", "document", ".", "get", "Element", "By", "Id", "(", "id", "+\"", "-", "toggle", "\");", "\\", "10", ";", " ", " ", "if", " ", "(", "elt", ".", "inner", "HTM", "L", " ", "==", " ", "\"-", "\")", "\\", "10", ";", " ", " ", "collapse", "(", "id", ");", " ", "\\", "10", ";", " ", " ", "else", "\\", "10", ";", " ", " ", "expand", "(", "id", ");", "\\", "10", ";", " ", " ", "return", " ", "fal", "se", ";", "\\", "10", ";}", "\\", "10", ";", "\\", "10", ";", "function", " ", "highlight", "(", "id", ")", " ", "{", "\\", "10", ";", " ", " ", "var", " ", "elt", " ", "=", " ", "document", ".", "get", "Element", "By", "Id", "(", "id", "+\"", "-", "def", "\");", "\\", "10", ";", " ", " ", "if", " ", "(", "elt", ")", " ", "elt", ".", "class", "Name", " ", "=", " ", "\"", "py", "-", "highlight", "-", "hdr", "\";", "\\", "10", ";", " ", " ", "var", " ", "elt", " ", "=", " ", "document", ".", "get", "Element", "By", "Id", "(", "id", "+\"", "-", "expand", "ed", "\");", "\\", "10", ";", " ", " ", "if", " ", "(", "elt", ")", " ", "elt", ".", "class", "Name", " ", "=", " ", "\"", "py", "-", "highlight", "\";", "\\", "10", ";", " ", " ", "var", " ", "elt", " ", "=", " ", "document", ".", "get", "Element", "By", "Id", "(", "id", "+\"", "-", "collapsed", "\");", "\\", "10", ";", " ", " ", "if", " ", "(", "elt", ")", " ", "elt", ".", "class", "Name", " ", "=", " ", "\"", "py", "-", "highlight", "\";", "\\", "10", ";}", "\\", "10", ";", "\\", "10", ";", "function", " ", "num", "\\u", "lines", "(", "s", ")", " ", "{", "\\", "10", ";", " ", " ", "var", " ", "n", " ", "=", " ", "1", ";", "\\", "10", ";", " ", " ", "var", " ", "pos", " ", "=", " ", "s", ".", "index", "Of", "(\"", "\\\\\\\\", "n", "\");", "\\", "10", ";", " ", " ", "whi", "le", " ", "(", " ", "pos", " ", ">", " ", "0", ")", " ", "{", "\\", "10", ";", " ", " ", " ", " ", "n", " ", "+=", " ", "1", ";", "\\", "10", ";", " ", " ", " ", " ", "pos", " ", "=", " ", "s", ".", "index", "Of", "(\"", "\\\\\\\\", "n", "\",", " ", "pos", "+", "1", ");", "\\", "10", ";", " ", " ", "}", "\\", "10", ";", " ", " ", "return", " ", "n", ";", "\\", "10", ";}", "\\", "10", ";", "\\", "10", ";", "//", " ", "Collaps", "e", " ", "all", " ", "blocks", " ", "tha", "t", " ", "mav", "e", " ", "more", " ", "than", " ", "`", "min", "\\u", "lines", "`", " ", "lines", ".", "\\", "10", ";", "function", " ", "collapse", "\\u", "all", "(", "min", "\\u", "lines", ")", " ", "{", "\\", "10", ";", " ", " ", "var", " ", "elts", " ", "=", " ", "document", ".", "get", "Element", "s", "By", "Ta", "g", "Name", "(\"", "div", "\");", "\\", "10", ";", " ", " ", "for", " ", "(", "var", " ", "i", "=", "0", ";", " ", "i", "<", "elts", ".", "length", ";", " ", "i", "++", ")", " ", "{", "\\", "10", ";", " ", " ", " ", " ", "var", " ", "elt", " ", "=", " ", "elts", "[", "i", "];", "\\", "10", ";", " ", " ", " ", " ", "var", " ", "split", " ", "=", " ", "elt", ".", "id", ".", "index", "Of", "(\"", "-\"", ");", "\\", "10", ";", " ", " ", " ", " ", "if", " ", "(", "split", " ", ">", " ", "0", ")", "\\", "10", ";", " ", " ", "if", " ", "(", "elt", ".", "id", ".", "substring", "(", "split", ",", " ", "elt", ".", "id", ".", "length", ")", " ", "==", " ", "\"-", "expand", "ed", "\")", "\\", "10", ";", " ", " ", " ", " ", "if", " ", "(", "num", "\\u", "lines", "(", "elt", ".", "inner", "HTM", "L", ")", " ", ">", " ", "min", "\\u", "lines", ")", "\\", "10", ";", " ", " ", "collapse", "(", "elt", ".", "id", ".", "substring", "(", "0", ",", " ", "split", "))", ";", "\\", "10", ";", " ", " ", "}", "\\", "10", ";}", "\\", "10", ";", "\\", "10", ";", "function", " ", "expand", "to", "(", "href", ")", " ", "{", "\\", "10", ";", " ", " ", "var", " ", "start", " ", "=", " ", "href", ".", "index", "Of", "(\"", "#\"", ")+", "1", ";", "\\", "10", ";", " ", " ", "if", " ", "(", "start", " ", "!=", " ", "0", " ", "&&", " ", "start", " ", "!=", " ", "href", ".", "length", ")", " ", "{", "\\", "10", ";", " ", " ", " ", " ", "if", " ", "(", "href", ".", "substring", "(", "start", ",", " ", "href", ".", "length", ")", " ", "!=", " ", "\"-", "\")", " ", "{", "\\", "10", ";", " ", " ", "collapse", "\\u", "all", "(", "4", ");", "\\", "10", ";", " ", " ", "pos", " ", "=", " ", "href", ".", "index", "Of", "(\".", "\",", " ", "start", ");", "\\", "10", ";", " ", " ", "whi", "le", " ", "(", "pos", " ", "!=", " ", "-1", ")", " ", "{", "\\", "10", ";", " ", " ", " ", " ", "var", " ", "id", " ", "=", " ", "href", ".", "substring", "(", "start", ",", " ", "pos", ");", "\\", "10", ";", " ", " ", " ", " ", "expand", "(", "id", ");", "\\", "10", ";", " ", " ", " ", " ", "pos", " ", "=", " ", "href", ".", "index", "Of", "(\".", "\",", " ", "pos", "+", "1", ");", "\\", "10", ";", " ", " ", "}", "\\", "10", ";", " ", " ", "var", " ", "id", " ", "=", " ", "href", ".", "substring", "(", "start", ",", " ", "href", ".", "length", ");", "\\", "10", ";", " ", " ", "expand", "(", "id", ");", "\\", "10", ";", " ", " ", "highlight", "(", "id", ");", "\\", "10", ";", " ", " ", " ", " ", "}", "\\", "10", ";", " ", " ", "}", "\\", "10", ";}", "\\", "10", ";", "\\", "10", ";", "function", " ", "kill", "\\u", "doc", "link", "(", "id", ")", " ", "{", "\\", "10", ";", " ", " ", "var", " ", "parent", " ", "=", " ", "document", ".", "get", "Element", "By", "Id", "(", "id", ");", "\\", "10", ";", " ", " ", "parent", ".", "remove", "Chil", "d", "(", "parent", ".", "child", "Node", "s", ".", "item", "(", "0", "))", ";", "\\", "10", ";}", "\\", "10", ";", "function", " ", "auto", "\\u", "kill", "\\u", "doc", "link", "(", "ev", ")", " ", "{", "\\", "10", ";", " ", " ", "if", " ", "(!", "ev", ")", " ", "var", " ", "ev", " ", "=", " ", "window", ".", "event", ";", "\\", "10", ";", " ", " ", "if", " ", "(!", "this", ".", "contain", "s", "(", "ev", ".", "to", "Element", "))", " ", "{", "\\", "10", ";", " ", " ", " ", " ", "var", " ", "parent", " ", "=", " ", "document", ".", "get", "Element", "By", "Id", "(", "this", ".", "parent", "ID", ");", "\\", "10", ";", " ", " ", " ", " ", "parent", ".", "remove", "Chil", "d", "(", "parent", ".", "child", "Node", "s", ".", "item", "(", "0", "))", ";", "\\", "10", ";", " ", " ", "}", "\\", "10", ";}", "\\", "10", ";", "\\", "10", ";", "function", " ", "doc", "link", "(", "id", ",", " ", "name", ",", " ", "target", "s", "\\u", "id", ")", " ", "{", "\\", "10", ";", " ", " ", "var", " ", "elt", " ", "=", " ", "document", ".", "get", "Element", "By", "Id", "(", "id", ");", "\\", "10", ";", "\\", "10", ";", " ", " ", "//", " ", "If", " ", "we", " ", "alr", "ead", "y", " ", "opene", "d", " ", "the", " ", "box", ",", " ", "then", " ", "destroy", " ", "it", ".", "\\", "10", ";", " ", " ", "//", " ", "(", "Thi", "s", " ", "case", " ", "shou", "ld", " ", "neve", "r", " ", "occur", ",", " ", "but", " ", "lea", "ve", " ", "it", " ", "in", " ", "just", " ", "in", " ", "case", ".)", "\\", "10", ";", " ", " ", "if", " ", "(", "elt", ".", "child", "Node", "s", ".", "length", " ", ">", " ", "1", ")", " ", "{", "\\", "10", ";", " ", " ", " ", " ", "elt", ".", "remove", "Chil", "d", "(", "elt", ".", "child", "Node", "s", ".", "item", "(", "0", "))", ";", "\\", "10", ";", " ", " ", "}", "\\", "10", ";", " ", " ", "else", " ", "{", "\\", "10", ";", " ", " ", " ", " ", "//", " ", "The", " ", "outer", " ", "box", ":", " ", "relative", " ", "+", " ", "inline", " ", "position", "ing", ".", "\\", "10", ";", " ", " ", " ", " ", "var", " ", "box1", " ", "=", " ", "document", ".", "create", "Element", "(\"", "div", "\");", "\\", "10", ";", " ", " ", " ", " ", "box1", ".", "style", ".", "position", " ", "=", " ", "\"", "relative", "\";", "\\", "10", ";", " ", " ", " ", " ", "box1", ".", "style", ".", "display", " ", "=", " ", "\"", "inline", "\";", "\\", "10", ";", " ", " ", " ", " ", "box1", ".", "style", ".", "top", " ", "=", " ", "0", ";", "\\", "10", ";", " ", " ", " ", " ", "box1", ".", "style", ".", "left", " ", "=", " ", "0", ";", "\\", "10", ";", " ", " ", "\\", "10", ";", " ", " ", " ", " ", "//", " ", "A", " ", "shadow", " ", "for", " ", "fun", "\\", "10", ";", " ", " ", " ", " ", "var", " ", "shadow", " ", "=", " ", "document", ".", "create", "Element", "(\"", "div", "\");", "\\", "10", ";", " ", " ", " ", " ", "shadow", ".", "style", ".", "position", " ", "=", " ", "\"", "abs", "olute", "\";", "\\", "10", ";", " ", " ", " ", " ", "shadow", ".", "style", ".", "left", " ", "=", " ", "\"-", "1.3", "em", "\";", "\\", "10", ";", " ", " ", " ", " ", "shadow", ".", "style", ".", "top", " ", "=", " ", "\"-", "1.3", "em", "\";", "\\", "10", ";", " ", " ", " ", " ", "shadow", ".", "style", ".", "background", " ", "=", " ", "\"#", "404", "040", "\";", "\\", "10", ";", " ", " ", " ", " ", "\\", "10", ";", " ", " ", " ", " ", "//", " ", "The", " ", "inner", " ", "box", ":", " ", "abs", "olute", " ", "position", "ing", ".", "\\", "10", ";", " ", " ", " ", " ", "var", " ", "box", "2", " ", "=", " ", "document", ".", "create", "Element", "(\"", "div", "\");", "\\", "10", ";", " ", " ", " ", " ", "box", "2", ".", "style", ".", "position", " ", "=", " ", "\"", "relative", "\";", "\\", "10", ";", " ", " ", " ", " ", "box", "2", ".", "style", ".", "border", " ", "=", " ", "\"", "1p", "x", " ", "solid", " ", "#", "a0", "a0", "a0", "\";", "\\", "10", ";", " ", " ", " ", " ", "box", "2", ".", "style", ".", "left", " ", "=", " ", "\"-", ".2", "em", "\";", "\\", "10", ";", " ", " ", " ", " ", "box", "2", ".", "style", ".", "top", " ", "=", " ", "\"-", ".2", "em", "\";", "\\", "10", ";", " ", " ", " ", " ", "box", "2", ".", "style", ".", "background", " ", "=", " ", "\"", "white", "\";", "\\", "10", ";", " ", " ", " ", " ", "box", "2", ".", "style", ".", "padd", "ing", " ", "=", " ", "\".", "3e", "m", " ", ".4", "em", " ", ".3", "em", " ", ".4", "em", "\";", "\\", "10", ";", " ", " ", " ", " ", "box", "2", ".", "style", ".", "font", "Style", " ", "=", " ", "\"", "normal", "\";", "\\", "10", ";", " ", " ", " ", " ", "box", "2", ".", "onmouse", "out", "=", "auto", "\\u", "kill", "\\u", "doc", "link", ";", "\\", "10", ";", " ", " ", " ", " ", "box", "2", ".", "parent", "ID", " ", "=", " ", "id", ";", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "//", " ", "Get", " ", "the", " ", "target", "s", "\\", "10", ";", " ", " ", " ", " ", "var", " ", "target", "s", "\\u", "elt", " ", "=", " ", "document", ".", "get", "Element", "By", "Id", "(", "target", "s", "\\u", "id", ");", "\\", "10", ";", " ", " ", " ", " ", "var", " ", "target", "s", " ", "=", " ", "target", "s", "\\u", "elt", ".", "get", "Attribute", "(\"", "target", "s", "\");", "\\", "10", ";", " ", " ", " ", " ", "var", " ", "link", "s", " ", "=", " ", "\"\"", ";", "\\", "10", ";", " ", " ", " ", " ", "target", "\\u", "list", " ", "=", " ", "target", "s", ".", "split", "(\"", ",\"", ");", "\\", "10", ";", " ", " ", " ", " ", "for", " ", "(", "var", " ", "i", "=", "0", ";", " ", "i", "<", "target", "\\u", "list", ".", "length", ";", " ", "i", "++", ")", " ", "{", "\\", "10", ";", " ", " ", " ", " ", "var", " ", "target", " ", "=", " ", "target", "\\u", "list", "[", "i", "].", "split", "(\"", "=\"", ");", "\\", "10", ";", " ", " ", " ", " ", "link", "s", " ", "+=", " ", "\"<", "li", "><", "a", " ", "href", "=\\\\", "'\"", " ", "+", " ", "target", "[", "1", "]", " ", "+", " ", "\\", "10", ";", " ", " ", " ", "\"\\\\'", " ", "style", "=\\\\", "'", "text", "-", "decorat", "ion", ":", "none", "\\\\'", ">\"", " ", "+", "\\", "10", ";", " ", " ", " ", "target", "[", "0", "]", " ", "+", " ", "\"<", "/", "a", "><", "/", "li", ">\"", ";", "\\", "10", ";", " ", " ", " ", " ", "}", "\\", "10", ";", " ", " ", "\\", "10", ";", " ", " ", " ", " ", "//", " ", "Put", " ", "it", " ", "all", " ", "tog", "ether", ".", "\\", "10", ";", " ", " ", " ", " ", "elt", ".", "insert", "Be", "fore", "(", "box1", ",", " ", "elt", ".", "child", "Node", "s", ".", "item", "(", "0", "))", ";", "\\", "10", ";", " ", " ", " ", " ", "//", "box1", ".", "append", "Chil", "d", "(", "box", "2", ");", "\\", "10", ";", " ", " ", " ", " ", "box1", ".", "append", "Chil", "d", "(", "shadow", ");", "\\", "10", ";", " ", " ", " ", " ", "shadow", ".", "append", "Chil", "d", "(", "box", "2", ");", "\\", "10", ";", " ", " ", " ", " ", "box", "2", ".", "inner", "HTM", "L", " ", "=", "\\", "10", ";", " ", " ", " ", " ", "\"", "Whi", "ch", " ", "<", "b", ">\"", "+", "name", "+\"", "</", "b", ">", " ", "do", " ", "you", " ", "want", " ", "to", " ", "see", " ", "documentation", " ", "for", "?\"", " ", "+", "\\", "10", ";", " ", " ", " ", " ", "\"<", "ul", " ", "style", "=\\\\", "'", "marg", "in", "-", "bottom", ":", " ", "0", ";\\\\", "'>", "\"", " ", "+", "\\", "10", ";", " ", " ", " ", " ", "link", "s", " ", "+", " ", "\\", "10", ";", " ", " ", " ", " ", "\"<", "li", "><", "a", " ", "href", "=\\\\", "'#", "\\\\'", " ", "style", "=\\\\", "'", "text", "-", "decorat", "ion", ":", "none", "\\\\'", " ", "\"", " ", "+", "\\", "10", ";", " ", " ", " ", " ", "\"", "onc", "lick", "=\\\\", "'", "kill", "\\u", "doc", "link", "(\\\\\\\\", "\"\"", "+", "id", "+\"", "\\\\\\\\\"", ");", "return", " ", "fal", "se", ";\\\\", "'>", "\"+", "\\", "10", ";", " ", " ", " ", " ", "\"<", "i", ">", "Non", "e", " ", "of", " ", "the", " ", "above", "</", "i", "><", "/", "a", "><", "/", "li", "><", "/", "ul", ">\"", ";", "\\", "10", ";", " ", " ", "}", "\\", "10", ";", " ", " ", "return", " ", "fal", "se", ";", "\\", "10", ";}", "\\", "10", ";'", "''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "PY", "SR", "C", "\\u", "EXPAN", "DT", "O", "\\u", "JAVA", "SCRIPT_", "=_", "'''", "\\\\", "\\", "10", ";<", "script", " ", "type", "=\"", "text", "/", "javascript", "\">", "\\", "10", ";<", "!-", "-", "\\", "10", ";", "expand", "to", "(", "location", ".", "href", ");", "\\", "10", ";", "//", " ", "-->", "\\", "10", ";<", "/", "script", ">", "\\", "10", ";'", "''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u", "HDR", "_", "=_", "'''", "\\\\", "\\", "10", ";<", "?", "xml", " ", "version", "=\"", "1.0", "\"", " ", "encoding", "=\"", "ascii", "\"?", ">", "\\", "10", ";", " ", " ", " ", " ", "<!", "DOC", "TYPE", " ", "html", " ", "PUBLIC", " ", "\"-", "//", "W3", "C", "//", "DT", "D", " ", "XH", "TML", " ", "1.0", " ", "Transiti", "onal", "//", "EN", "\"", "\\", "10", ";", " ", " ", " ", " ", " ", " ", "\"", "DT", "D", "/", "xh", "tml", "1", "-", "transiti", "onal", ".", "dtd", "\">", "\\", "10", ";", " ", " ", " ", " ", "<", "html", " ", "xml", "ns", "=\"", "http", "://", "www", ".", "w3", ".", "org", "/", "1999", "/", "xh", "tml", "\"", " ", "xml", ":", "lang", "=\"", "en", "\"", " ", "lang", "=\"", "en", "\">", "\\", "10", ";", " ", " ", " ", " ", "<", "head", ">", "\\", "10", ";", " ", " ", "<", "title", ">", "$", "title", "$", "</", "title", ">", "\\", "10", ";", " ", " ", "<", "link", " ", "rel", "=\"", "stylesheet", "\"", " ", "href", "=\"", "ep", "ydo", "c", ".", "css", "\"", " ", "type", "=\"", "text", "/", "css", "\"", " ", "/>", "\\", "10", ";", " ", " ", "<", "script", " ", "type", "=\"", "text", "/", "javascript", "\"", " ", "src", "=\"", "ep", "ydo", "c", ".", "js", "\">", "</", "script", ">", "\\", "10", ";", " ", " ", " ", " ", "</", "head", ">", "\\", "10", ";", " ", " ", " ", " ", "\\", "10", ";", " ", " ", " ", " ", "<", "body", " ", "bg", "color", "=\"", "white", "\"", " ", "text", "=\"", "black", "\"", " ", "link", "=\"", "blue", "\"", " ", "vlin", "k", "=\"", "#", "204", "080", "\"", "\\", "10", ";", " ", " ", " ", " ", " ", " ", "alin", "k", "=\"", "#", "204", "080", "\">", "\\", "10", ";'", "''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u", "FOO", "T_", "=_", "'<", "/", "body", "><", "/", "html", ">'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "\\u\\u", "name\\u\\u_", "==_", "'\\u", "\\u", "main", "\\u\\u'_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", "s", " ", "=", " ", "Pyth", "on", "Sou", "rce", "Color", "ize", "r", "('.", "./", "apid", "oc", ".", "py", "',", " ", "'", "ep", "ydo", "c", ".", "apid", "oc", "')", ".", "coloriz", "e", "()", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "s_", "=_", "Pyth", "on", "Sou", "rce", "Color", "izer_", "(_", "'/", "tmp", "/", "fo", ".", "py", "'_", ",_", "'", "ep", "ydo", "c", ".", "apid", "oc", "'_", ")_", "._", "colorize_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", "print", " ", "s_", "\\u\\u\\uNL\\u\\u\\u_", "import_", "codecs_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "f_", "=_", "codecs_", "._", "open_", "(_", "'/", "home", "/", "edl", "oper", "/", "public", "\\u", "html", "/", "color", "3", ".", "html", "'_", ",_", "'", "w", "'_", ",_", "'", "ascii", "'_", ",_", "'", "xml", "char", "refre", "place", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "f_", "._", "write_", "(_", "\\u", "HDR", "_", "+_", "'<", "pre", " ", "id", "=\"", "py", "-", "src", "-", "top", "\"", " ", "class", "=\"", "py", "-", "src", "\">'_", "+_", "s_", "+_", "'<", "/", "pre", ">'_", "+_", "\\u", "FOO", "T_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "f_", "._", "close_", "(_", ")_", "\\u\\u\\uDEDENT\\u\\u\\u_", "[SEP]_", "class_", "Pyth", "on", "Sou", "rce", "Color", "izer_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "\\u\\u", "init\\u\\u_", "(_", "self_", ",_", "module", "\\u", "filename_", ",_", "module", "\\u", "name_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "doc", "index_", "=_", "None_", ",_", "url", "\\u", "func_", "=_", "None_", ",_", "name", "\\u", "to", "\\u", "docs_", "=_", "None_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "tab", "\\u", "width_", "=_", "8_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Creat", "e", " ", "a", " ", "new", " ", "HTM", "L", " ", "coloriz", "er", " ", "for", " ", "the", " ", "specified", " ", "module", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "@", "param", " ", "module", "\\u", "filename", ":", " ", "The", " ", "name", " ", "of", " ", "the", " ", "file", " ", "contain", "ing", " ", "the", "\\", "10", ";", " ", " ", " ", " ", "module", ";", " ", "its", " ", "text", " ", "will", " ", "be", " ", "load", "ed", " ", "from", " ", "this", " ", "file", ".", "\\", "10", ";", " ", " ", " ", " ", "@", "param", " ", "module", "\\u", "name", ":", " ", "The", " ", "dot", "ted", " ", "name", " ", "of", " ", "the", " ", "module", ";", " ", "this", " ", "will", "\\", "10", ";", " ", " ", " ", " ", "be", " ", "used", " ", "to", " ", "create", " ", "link", "s", " ", "back", " ", "int", "o", " ", "the", " ", "API", " ", "source", "\\", "10", ";", " ", " ", " ", " ", "documentation", ".", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Get", " ", "the", " ", "source", " ", "version", ",", " ", "if", " ", "possib", "le", "._", "\\u\\u\\uNL\\u\\u\\u_", "try_", ":_", "module", "\\u", "filename_", "=_", "py", "\\u", "src", "\\u", "filename_", "(_", "module", "\\u", "filename_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "except_", ":_", "pass_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", ":", " ", "The", " ", "filename", " ", "of", " ", "the", " ", "module", " ", "we", "'", "re", " ", "coloriz", "ing", "._", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "module", "\\u", "filename_", "=_", "module", "\\u", "filename_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", ":", " ", "The", " ", "dot", "ted", " ", "name", " ", "of", " ", "the", " ", "module", " ", "we", "'", "re", " ", "coloriz", "ing", "._", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "module", "\\u", "name_", "=_", "module", "\\u", "name_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", ":", " ", "A", " ", "doc", "index", ",", " ", "used", " ", "to", " ", "create", " ", "href", " ", "link", "s", " ", "from", " ", "identifi", "ers", " ", "to_", "\\u\\u\\uNL\\u\\u\\u_", "#", ":", " ", "the", " ", "API", " ", "documentation", " ", "for", " ", "thei", "r", " ", "values", "._", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "doc", "index_", "=_", "doc", "index_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", ":", " ", "A", " ", "mapping", " ", "from", " ", "short", " ", "names", " ", "to", " ", "lists", " ", "of", " ", "Value", "Doc", ",", " ", "used", " ", "to_", "\\u\\u\\uNL\\u\\u\\u_", "#", ":", " ", "decide", " ", "whi", "ch", " ", "values", " ", "an", " ", "identifi", "er", " ", "mig", "ht", " ", "map", " ", "to", " ", "whe", "n", " ", "creati", "ng_", "\\u\\u\\uNL\\u\\u\\u_", "#", ":", " ", "href", " ", "link", "s", " ", "from", " ", "identifi", "ers", " ", "to", " ", "the", " ", "API", " ", "docs", " ", "for", " ", "thei", "r", " ", "values", "._", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "name", "\\u", "to", "\\u", "docs_", "=_", "name", "\\u", "to", "\\u", "docs_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", ":", " ", "A", " ", "function", " ", "tha", "t", " ", "maps", " ", "API", "Doc", " ", "->", " ", "URL", ",", " ", "used", " ", "to", " ", "create", " ", "href_", "\\u\\u\\uNL\\u\\u\\u_", "#", ":", " ", "link", "s", " ", "from", " ", "identifi", "ers", " ", "to", " ", "the", " ", "API", " ", "documentation", " ", "for", " ", "thei", "r_", "\\u\\u\\uNL\\u\\u\\u_", "#", ":", " ", "values", "._", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "url", "\\u", "func_", "=_", "url", "\\u", "func_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", ":", " ", "The", " ", "index", " ", "in", " ", "C", "{", "text", "}", " ", "of", " ", "the", " ", "last", " ", "character", " ", "of", " ", "the", " ", "last_", "\\u\\u\\uNL\\u\\u\\u_", "#", ":", " ", "token", " ", "we", "'", "ve", " ", "process", "ed", "._", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "pos_", "=_", "0_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", ":", " ", "A", " ", "list", " ", "tha", "t", " ", "maps", " ", "line", " ", "numbers", " ", "to", " ", "character", " ", "offset", "s", " ", "in_", "\\u\\u\\uNL\\u\\u\\u_", "#", ":", " ", "C", "{", "text", "}.", " ", " ", "In", " ", "partic", "ular", ",", " ", "line", " ", "C", "{", "M", "{", "i", "}}", " ", "begins", " ", "at", " ", "character_", "\\u\\u\\uNL\\u\\u\\u_", "#", ":", " ", "C", "{", "line", "\\u", "offset", "[", "i", "]}", " ", "in", " ", "C", "{", "text", "}.", " ", " ", "Sin", "ce", " ", "line", " ", "numbers", " ", "begin", " ", "at_", "\\u\\u\\uNL\\u\\u\\u_", "#", ":", " ", "1", ",", " ", "the", " ", "first", " ", "element", " ", "of", " ", "C", "{", "line", "\\u", "offset", "s", "}", " ", "is", " ", "C", "{", "Non", "e", "}.", "_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "line", "\\u", "offsets_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", ":", " ", "A", " ", "list", " ", "of", " ", "C", "{(", "tok", "type", ",", " ", "tok", "text", ")}", " ", "for", " ", "all", " ", "token", "s", " ", "on", " ", "the_", "\\u\\u\\uNL\\u\\u\\u_", "#", ":", " ", "logical", " ", "line", " ", "tha", "t", " ", "we", " ", "are", " ", "currentl", "y", " ", "process", "ing", ".", " ", " ", "On", "ce", " ", "a_", "\\u\\u\\uNL\\u\\u\\u_", "#", ":", " ", "complete", " ", "line", " ", "of", " ", "token", "s", " ", "has", " ", "bee", "n", " ", "collected", " ", "in", " ", "C", "{", "cur", "\\u", "line", "},", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", ":", " ", "it", " ", "is", " ", "sent", " ", "to", " ", "L", "{", "handle", "\\u", "line", "}", " ", "for", " ", "process", "ing", "._", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "cur", "\\u", "line_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", ":", " ", "A", " ", "list", " ", "of", " ", "the", " ", "names", " ", "of", " ", "the", " ", "class", " ", "or", " ", "function", "s", " ", "tha", "t", " ", "include_", "\\u\\u\\uNL\\u\\u\\u_", "#", ":", " ", "the", " ", "current", " ", "block", ".", " ", " ", "C", "{", "context", "}", " ", "has", " ", "one", " ", "element", " ", "for", " ", "each_", "\\u\\u\\uNL\\u\\u\\u_", "#", ":", " ", "level", " ", "of", " ", "indent", "ation", ";", " ", "C", "{", "context", "[", "i", "]}", " ", "is", " ", "the", " ", "name", " ", "of", " ", "the", " ", "class_", "\\u\\u\\uNL\\u\\u\\u_", "#", ":", " ", "or", " ", "function", " ", "defin", "ed", " ", "by", " ", "the", " ", "C", "{", "i", "}", "th", " ", "level", " ", "of", " ", "indent", "ation", ",", " ", "or_", "\\u\\u\\uNL\\u\\u\\u_", "#", ":", " ", "C", "{", "Non", "e", "}", " ", "if", " ", "tha", "t", " ", "level", " ", "of", " ", "indent", "ation", " ", "doe", "sn", "'", "t", " ", "correspond", " ", "to", " ", "a_", "\\u\\u\\uNL\\u\\u\\u_", "#", ":", " ", "class", " ", "or", " ", "function", " ", "definit", "ion", "._", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "context_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", ":", " ", "A", " ", "list", ",", " ", "correspond", "ing", " ", "one", "-", "to", "-", "one", " ", "with", " ", "L", "{", "self", ".", "context", "},", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", ":", " ", "indicati", "ng", " ", "the", " ", "type", " ", "of", " ", "each", " ", "entry", ".", " ", " ", "Ea", "ch", " ", "element", " ", "of_", "\\u\\u\\uNL\\u\\u\\u_", "#", ":", " ", "C", "{", "context", "\\u", "types", "}", " ", "is", " ", "one", " ", "of", ":", " ", "C", "{", "'", "func", "'}", ",", " ", "C", "{", "'", "class", "'}", ",", " ", "C", "{", "Non", "e", "}.", "_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "context", "\\u", "types_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", ":", " ", "A", " ", "list", " ", "of", " ", "indent", "ation", " ", "string", "s", " ", "for", " ", "each", " ", "of", " ", "the", " ", "current_", "\\u\\u\\uNL\\u\\u\\u_", "#", ":", " ", "block", "'", "s", " ", "indent", "s", ".", " ", " ", "I", ".", "e", ".,", " ", "the", " ", "current", " ", "total", " ", "indent", "ation", " ", "can_", "\\u\\u\\uNL\\u\\u\\u_", "#", ":", " ", "be", " ", "found", " ", "by", " ", "tak", "ing", " ", "C", "{", "''", ".", "join", "(", "self", ".", "indent", "s", ")}", "._", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "indent", "s_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", ":", " ", "The", " ", "line", " ", "number", " ", "of", " ", "the", " ", "line", " ", "we", "'", "re", " ", "currentl", "y", " ", "process", "ing", "._", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "lineno_", "=_", "0_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", ":", " ", "The", " ", "name", " ", "of", " ", "the", " ", "class", " ", "or", " ", "function", " ", "who", "se", " ", "definit", "ion", " ", "started_", "\\u\\u\\uNL\\u\\u\\u_", "#", ":", " ", "on", " ", "the", " ", "previ", "ous", " ", "logical", " ", "line", ",", " ", "or", " ", "C", "{", "Non", "e", "}", " ", "if", " ", "the", " ", "previous_", "\\u\\u\\uNL\\u\\u\\u_", "#", ":", " ", "logical", " ", "line", " ", "was", " ", "not", " ", "a", " ", "class", " ", "or", " ", "function", " ", "definit", "ion", "._", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "def", "\\u", "name_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", ":", " ", "The", " ", "type", " ", "of", " ", "the", " ", "class", " ", "or", " ", "function", " ", "who", "se", " ", "definit", "ion", " ", "started_", "\\u\\u\\uNL\\u\\u\\u_", "#", ":", " ", "on", " ", "the", " ", "previ", "ous", " ", "logical", " ", "line", ",", " ", "or", " ", "C", "{", "Non", "e", "}", " ", "if", " ", "the", " ", "previous_", "\\u\\u\\uNL\\u\\u\\u_", "#", ":", " ", "logical", " ", "line", " ", "was", " ", "not", " ", "a", " ", "class", " ", "or", " ", "function", " ", "definit", "ion", "._", "\\u\\u\\uNL\\u\\u\\u_", "#", ":", " ", "Can", " ", "be", " ", "C", "{", "'", "func", "'}", ",", " ", "C", "{", "'", "class", "'}", ",", " ", "C", "{", "Non", "e", "}.", "_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "def", "\\u", "type_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", ":", " ", "The", " ", "number", " ", "of", " ", "space", "s", " ", "to", " ", "replace", " ", "each", " ", "tab", " ", "in", " ", "source", " ", "code", " ", "with_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "tab", "\\u", "width_", "=_", "tab", "\\u", "width_", "\\u\\u\\uNEWLINE\\u\\u\\u_" ]
[ 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2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, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 ]
Use of the return value of a procedure
msopentechcn/open-hackathon/open-hackathon-server/test/apitest/run.py
[ { "content": "def show_detail(items):\n for i in items:\n print repr(i)", "metadata": "root.show_detail", "header": "['module', '___EOS___']", "index": 42 }, { "content": "def show_test_result(result):\n print\n print \"---- START OF TEST RESULTS\"\n print result\n print\n print \"Result::errors\"\n print show_detail(result.errors)\n print\n print \"Result::failures\"\n print show_detail(result.failures)\n print\n print \"Result::skipped\"\n print show_detail(result.skipped)\n print\n print \"Result::successful\"\n print result.wasSuccessful()\n print\n print \"Result::test-run\"\n print result.testsRun\n print \"---- END OF TEST RESULTS\"\n print", "metadata": "root.show_test_result", "header": "['module', '___EOS___']", "index": 47 } ]
[ { "span": "show_detail(result.errors)", "start_line": 53, "start_column": 10, "end_line": 53, "end_column": 36 }, { "span": "show_detail(result.failures)", "start_line": 56, "start_column": 10, "end_line": 56, "end_column": 38 }, { "span": "show_detail(result.skipped)", "start_line": 59, "start_column": 10, "end_line": 59, "end_column": 37 } ]
[ { "span": "def show_detail(items):", "start_line": 42, "start_column": 0, "end_line": 42, "end_column": 23 } ]
1
false
[ "[CLS]_", "Use_", "of_", "the_", "return_", "value_", "of_", "a_", "procedure_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "show", "\\u", "detail_", "(_", "items_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "for_", "i_", "in_", "items_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "print_", "repr_", "(_", "i_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "show", "\\u", "test\\u", "result_", "(_", "result_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "print_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "print_", "\"----", " ", "START", " ", "OF", " ", "TEST", " ", "RESULTS", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "print_", "result_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "print_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "print_", "\"", "Result", "::", "error", "s", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "print_", "show", "\\u", "detail_", "(_", "result_", "._", "errors_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "print_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "print_", "\"", "Result", "::", "fail", "ure", "s", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "print_", "show", "\\u", "detail_", "(_", "result_", "._", "failures_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "print_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "print_", "\"", "Result", "::", "skip", "ped", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "print_", "show", "\\u", "detail_", "(_", "result_", "._", "skipped_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "print_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "print_", "\"", "Result", "::", "success", "ful", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "print_", "result_", "._", "was", "Success", "ful_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "print_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "print_", "\"", "Result", "::", "test", "-", "run", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "print_", "result_", "._", "tests", "Run_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "print_", "\"----", " ", "END", " ", "OF", " ", "TEST", " ", "RESULTS", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "print_", "\\u\\u\\uNEWLINE\\u\\u\\u_" ]
[ 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 2, 2, 2, 3, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 ]
Unused local variable
panoptes/POCS/scripts/read_weather.py
[ { "content": "def make_safety_decision(cfg, logger=None):\n '''\n Method makes decision whether conditions are safe or unsafe.\n '''\n if logger:\n logger.info('Making safety decision')\n # If sky-amb > threshold, then cloudy (safe)\n if 'threshold_cloudy' in cfg.keys():\n threshold_cloudy = cfg['threshold_cloudy']\n else:\n if logger:\n logger.warning('Using default cloudy threshold')\n threshold_cloudy = -20\n # If sky-amb > threshold, then very cloudy (unsafe)\n if 'threshold_very_cloudy' in cfg.keys():\n threshold_very_cloudy = cfg['threshold_very_cloudy']\n else:\n if logger:\n logger.warning('Using default very cloudy threshold')\n threshold_very_cloudy = -15\n # If avg_wind > threshold, then windy (safe)\n if 'threshold_windy' in cfg.keys():\n threshold_windy = cfg['threshold_windy']\n else:\n if logger:\n logger.warning('Using default windy threshold')\n threshold_windy = 20\n # If avg_wind > threshold, then very windy (unsafe)\n if 'threshold_very_windy' in cfg.keys():\n threshold_very_windy = cfg['threshold_very_windy']\n else:\n if logger:\n logger.warning('Using default very windy threshold')\n threshold_very_windy = 30\n # If wind > threshold, then gusty (safe)\n if 'threshold_gusty' in cfg.keys():\n threshold_gusty = cfg['threshold_gusty']\n else:\n if logger:\n logger.warning('Using default gusty threshold')\n threshold_gusty = 40\n # If wind > threshold, then very gusty (unsafe)\n if 'threshold_very_gusty' in cfg.keys():\n threshold_very_gusty = cfg['threshold_very_gusty']\n else:\n if logger:\n logger.warning('Using default very gusty threshold')\n threshold_very_gusty = 50\n # If rain frequency < threshold, then unsafe\n if 'threshold_rainy' in cfg.keys():\n threshold_rain = cfg['threshold_rainy']\n else:\n if logger:\n logger.warning('Using default rain threshold')\n threshold_rain = 230\n\n # Get Last n minutes of data\n if 'safety_delay' in cfg.keys():\n safety_delay = cfg['safety_delay']\n else:\n if logger:\n logger.warning('Using default safety delay')\n safety_delay = 15.\n end = dt.utcnow()\n start = end - tdelta(0, int(safety_delay * 60))\n db = PanMongo()\n entries = [x for x in db.weather.find({'date': {'$gt': start, '$lt': end}})]\n if logger:\n logger.info(' Found {} weather data entries in last {:.0f} minutes'.format(len(entries), safety_delay))\n\n # Cloudiness\n sky_diff = [x['data']['Sky Temperature (C)'] - x['data']['Ambient Temperature (C)']\n for x in entries\n if 'Ambient Temperature (C)' in x['data'].keys() and 'Sky Temperature (C)' in x['data'].keys()]\n\n if len(sky_diff) == 0:\n if logger:\n logger.info(' UNSAFE: no sky tempeartures found')\n sky_safe = False\n cloud_condition = 'Unknown'\n else:\n if max(sky_diff) > threshold_very_cloudy:\n if logger:\n logger.info(' UNSAFE: Very cloudy in last {:.0f} min.'\n ' Max sky diff {:.1f} C'.format(safety_delay, max(sky_diff)))\n sky_safe = False\n else:\n sky_safe = True\n\n if sky_diff[-1] > threshold_very_cloudy:\n cloud_condition = 'Very Cloudy'\n elif sky_diff[-1] > threshold_cloudy:\n cloud_condition = 'Cloudy'\n else:\n cloud_condition = 'Clear'\n if logger:\n logger.info(' Cloud Condition: {} (Sky-Amb={:.1f} C)'.format(cloud_condition, sky_diff[-1]))\n\n # Wind (average and gusts)\n wind_speed = [x['data']['Wind Speed (km/h)']\n for x in entries\n if 'Wind Speed (km/h)' in x['data'].keys()]\n\n if len(wind_speed) == 0:\n if logger:\n logger.info(' UNSAFE: no wind speed readings found')\n wind_safe = False\n gust_safe = False\n wind_condition = 'Unknown'\n gust_condition = 'Unknown'\n else:\n typical_data_interval = (end - min([x['date'] for x in entries])).total_seconds() / len(entries)\n mavg_count = int(np.ceil(120. / typical_data_interval))\n wind_mavg = movingaverage(wind_speed, mavg_count)\n\n # Windy?\n if max(wind_mavg) > threshold_very_windy:\n if logger:\n logger.info(' UNSAFE: Very windy in last {:.0f} min.'\n ' Max wind speed {:.1f} kph'.format(safety_delay, max(wind_mavg)))\n wind_safe = False\n else:\n wind_safe = True\n if wind_mavg[-1] > threshold_very_windy:\n wind_condition = 'Very Windy'\n elif wind_mavg[-1] > threshold_windy:\n wind_condition = 'Windy'\n else:\n wind_condition = 'Calm'\n if logger:\n logger.info(' Wind Condition: {} ({:.1f} km/h)'.format(wind_condition, wind_mavg[-1]))\n\n # Gusty?\n if max(wind_speed) > threshold_very_gusty:\n if logger:\n logger.info(' UNSAFE: Very gusty in last {:.0f} min.'\n ' Max gust speed {:.1f} kph'.format(safety_delay, max(wind_speed)))\n gust_safe = False\n else:\n gust_safe = True\n if wind_speed[-1] > threshold_very_gusty:\n gust_condition = 'Very Gusty'\n elif wind_speed[-1] > threshold_windy:\n gust_condition = 'Gusty'\n else:\n gust_condition = 'Calm'\n if logger:\n logger.info(' Gust Condition: {} ({:.1f} km/h)'.format(gust_condition, wind_speed[-1]))\n\n # Rain\n rf_value = [x['data']['Rain Frequency']\n for x in entries\n if 'Rain Frequency' in x['data'].keys()]\n\n if len(rf_value) == 0:\n rain_safe = False\n rain_condition = 'Unknown'\n else:\n if min(rf_value) < threshold_rain:\n if logger:\n logger.info(' UNSAFE: Rain in last {:.0f} min.'.format(safety_delay))\n rain_safe = False\n else:\n rain_safe = True\n if rf_value[-1] < threshold_rain:\n rain_condition = 'Rain'\n else:\n rain_condition = 'Dry'\n if logger:\n logger.info(' Rain Condition: {}'.format(rain_condition))\n\n safe = sky_safe & wind_safe & gust_safe & rain_safe\n translator = {True: 'safe', False: 'unsafe'}\n if logger:\n logger.info('Weather is {}'.format(translator[safe]))\n\n safe_dict = {'Safe': safe,\n 'Sky': cloud_condition,\n 'Wind': wind_condition,\n 'Gust': gust_condition,\n 'Rain': rain_condition}\n return safe_dict", "metadata": "root.make_safety_decision", "header": "['module', '___EOS___']", "index": 838 }, { "content": "def plot_weather(date_string):\n import matplotlib as mpl\n mpl.use('Agg')\n from matplotlib import pyplot as plt\n from matplotlib.dates import HourLocator, MinuteLocator, DateFormatter\n plt.ioff()\n\n dpi = 100\n plt.figure(figsize=(16, 9), dpi=dpi)\n\n hours = HourLocator(byhour=range(24), interval=1)\n hours_fmt = DateFormatter('%H')\n mins = MinuteLocator(range(0, 60, 15))\n mins_fmt = DateFormatter('%H:%M')\n\n if not date_string:\n today = True\n date = dt.utcnow()\n date_string = date.strftime('%Y%m%dUT')\n else:\n today = False\n date = dt.strptime('{} 23:59:59'.format(date_string), '%Y%m%dUT %H:%M:%S')\n\n start = dt(date.year, date.month, date.day, 0, 0, 0, 0)\n end = dt(date.year, date.month, date.day, 23, 59, 59, 0)\n\n # ------------------------------------------------------------------------\n # determine sunrise and sunset times\n # ------------------------------------------------------------------------\n cfg = load_config()['location']\n loc = EarthLocation(\n lat=cfg['latitude'],\n lon=cfg['longitude'],\n height=cfg['elevation'],\n )\n obs = Observer(location=loc, name='PANOPTES', timezone=cfg['timezone'])\n\n sunset = obs.sun_set_time(Time(start), which='next').datetime\n evening_civil_twilight = obs.twilight_evening_civil(Time(start), which='next').datetime\n evening_nautical_twilight = obs.twilight_evening_nautical(Time(start), which='next').datetime\n evening_astronomical_twilight = obs.twilight_evening_astronomical(Time(start), which='next').datetime\n morning_astronomical_twilight = obs.twilight_morning_astronomical(Time(start), which='next').datetime\n morning_nautical_twilight = obs.twilight_morning_nautical(Time(start), which='next').datetime\n morning_civil_twilight = obs.twilight_morning_civil(Time(start), which='next').datetime\n sunrise = obs.sun_rise_time(Time(start), which='next').datetime\n\n print('start: {}'.format(Time(start)))\n print(obs.is_night(Time(start)))\n print('sunset: {}'.format(sunset))\n print('evening_civil_twilight: {}'.format(evening_civil_twilight))\n print('evening_nautical_twilight: {}'.format(evening_nautical_twilight))\n print('evening_astronomical_twilight: {}'.format(evening_astronomical_twilight))\n print('morning_astronomical_twilight: {}'.format(morning_astronomical_twilight))\n print('morning_nautical_twilight: {}'.format(morning_nautical_twilight))\n print('morning_civil_twilight: {}'.format(morning_civil_twilight))\n\n # -------------------------------------------------------------------------\n # Plot a day's weather\n # -------------------------------------------------------------------------\n plot_positions = [([0.000, 0.835, 0.700, 0.170], [0.720, 0.835, 0.280, 0.170]),\n ([0.000, 0.635, 0.700, 0.170], [0.720, 0.635, 0.280, 0.170]),\n ([0.000, 0.450, 0.700, 0.170], [0.720, 0.450, 0.280, 0.170]),\n ([0.000, 0.265, 0.700, 0.170], [0.720, 0.265, 0.280, 0.170]),\n ([0.000, 0.185, 0.700, 0.065], [0.720, 0.185, 0.280, 0.065]),\n ([0.000, 0.000, 0.700, 0.170], [0.720, 0.000, 0.280, 0.170]),\n ]\n\n # Connect to sensors collection\n db = PanMongo()\n entries = [x for x in db.weather.find({'date': {'$gt': start, '$lt': end}}).sort([('date', pymongo.ASCENDING)])]\n if today:\n current_values = [x for x in db.current.find({\"type\": \"weather\"})][0]\n else:\n current_values = None\n\n print('Plot Ambient Temperature vs. Time')\n # -------------------------------------------------------------------------\n # Plot Ambient Temperature vs. Time\n t_axes = plt.axes(plot_positions[0][0])\n if today:\n time_title = date\n else:\n time_title = end\n plt.title('Weather for {} at {}'.format(date_string, time_title.strftime('%H:%M:%S UT')))\n amb_temp = [x['data']['Ambient Temperature (C)']\n for x in entries\n if 'Ambient Temperature (C)' in x['data'].keys()]\n time = [x['date'] for x in entries\n if 'Ambient Temperature (C)' in x['data'].keys()]\n t_axes.plot_date(time, amb_temp, 'ko',\n markersize=2, markeredgewidth=0,\n drawstyle=\"default\")\n try:\n max_temp = max(amb_temp)\n min_temp = min(amb_temp)\n label_time = end - tdelta(0, 7 * 60 * 60)\n label_temp = 28\n t_axes.annotate('Low: {:4.1f} $^\\circ$C, High: {:4.1f} $^\\circ$C'.format(\n min_temp, max_temp),\n xy=(label_time, max_temp),\n xytext=(label_time, label_temp),\n size=16,\n )\n except:\n pass\n plt.ylabel(\"Ambient Temp. (C)\")\n plt.grid(which='major', color='k')\n plt.yticks(range(-100, 100, 10))\n plt.xlim(start, end)\n plt.ylim(-5, 35)\n t_axes.xaxis.set_major_locator(hours)\n t_axes.xaxis.set_major_formatter(hours_fmt)\n\n if obs.is_night(Time(start)):\n plt.axvspan(start, morning_astronomical_twilight, ymin=0, ymax=1, color='blue', alpha=0.5)\n plt.axvspan(morning_astronomical_twilight, morning_nautical_twilight, ymin=0, ymax=1, color='blue', alpha=0.3)\n plt.axvspan(morning_nautical_twilight, morning_civil_twilight, ymin=0, ymax=1, color='blue', alpha=0.2)\n plt.axvspan(morning_civil_twilight, sunrise, ymin=0, ymax=1, color='blue', alpha=0.1)\n plt.axvspan(sunset, evening_civil_twilight, ymin=0, ymax=1, color='blue', alpha=0.1)\n plt.axvspan(evening_civil_twilight, evening_nautical_twilight, ymin=0, ymax=1, color='blue', alpha=0.2)\n plt.axvspan(evening_nautical_twilight, evening_astronomical_twilight, ymin=0, ymax=1, color='blue', alpha=0.3)\n plt.axvspan(evening_astronomical_twilight, end, ymin=0, ymax=1, color='blue', alpha=0.5)\n else:\n plt.axvspan(sunset, evening_civil_twilight, ymin=0, ymax=1, color='blue', alpha=0.1)\n plt.axvspan(evening_civil_twilight, evening_nautical_twilight, ymin=0, ymax=1, color='blue', alpha=0.2)\n plt.axvspan(evening_nautical_twilight, evening_astronomical_twilight, ymin=0, ymax=1, color='blue', alpha=0.3)\n plt.axvspan(evening_astronomical_twilight, morning_astronomical_twilight,\n ymin=0, ymax=1, color='blue', alpha=0.5)\n plt.axvspan(morning_astronomical_twilight, morning_nautical_twilight, ymin=0, ymax=1, color='blue', alpha=0.3)\n plt.axvspan(morning_nautical_twilight, morning_civil_twilight, ymin=0, ymax=1, color='blue', alpha=0.2)\n plt.axvspan(morning_civil_twilight, sunrise, ymin=0, ymax=1, color='blue', alpha=0.1)\n\n tlh_axes = plt.axes(plot_positions[0][1])\n plt.title('Last Hour')\n tlh_axes.plot_date(time, amb_temp, 'ko',\n markersize=4, markeredgewidth=0,\n drawstyle=\"default\")\n try:\n current_amb_temp = current_values['data']['Ambient Temperature (C)']\n current_time = current_values['date']\n label_time = current_time - tdelta(0, 30 * 60)\n label_temp = 28 # current_amb_temp + 7\n tlh_axes.annotate('Currently: {:.1f} $^\\circ$C'.format(current_amb_temp),\n xy=(current_time, current_amb_temp),\n xytext=(label_time, label_temp),\n size=16,\n )\n except:\n pass\n plt.grid(which='major', color='k')\n plt.yticks(range(-100, 100, 10))\n tlh_axes.xaxis.set_major_locator(mins)\n tlh_axes.xaxis.set_major_formatter(mins_fmt)\n tlh_axes.yaxis.set_ticklabels([])\n plt.xlim(date - tdelta(0, 60 * 60), date + tdelta(0, 5 * 60))\n plt.ylim(-5, 35)\n\n print('Plot Temperature Difference vs. Time')\n # -------------------------------------------------------------------------\n # Plot Temperature Difference vs. Time\n td_axes = plt.axes(plot_positions[1][0])\n temp_diff = [x['data']['Sky Temperature (C)'] - x['data']['Ambient Temperature (C)']\n for x in entries\n if 'Sky Temperature (C)' in x['data'].keys() and 'Ambient Temperature (C)' in x['data'].keys() and 'Sky Condition' in x['data'].keys()]\n time = [x['date'] for x in entries\n if 'Sky Temperature (C)' in x['data'].keys() and 'Ambient Temperature (C)' in x['data'].keys() and 'Sky Condition' in x['data'].keys()]\n sky_condition = [x['data']['Sky Condition']\n for x in entries\n if 'Sky Temperature (C)' in x['data'].keys() and 'Ambient Temperature (C)' in x['data'].keys() and 'Sky Condition' in x['data'].keys()]\n td_axes.plot_date(time, temp_diff, 'ko-', label='Cloudiness',\n markersize=2, markeredgewidth=0,\n drawstyle=\"default\")\n td_axes.fill_between(time, -60, temp_diff, where=np.array(sky_condition) == 'Clear',\n color='green', alpha=0.5)\n td_axes.fill_between(time, -60, temp_diff, where=np.array(sky_condition) == 'Cloudy',\n color='yellow', alpha=0.5)\n td_axes.fill_between(time, -60, temp_diff, where=np.array(sky_condition) == 'Very Cloudy',\n color='red', alpha=0.5)\n plt.ylabel(\"Cloudiness\")\n plt.grid(which='major', color='k')\n plt.yticks(range(-100, 100, 10))\n plt.xlim(start, end)\n plt.ylim(-60, 10)\n td_axes.xaxis.set_major_locator(hours)\n td_axes.xaxis.set_major_formatter(hours_fmt)\n td_axes.xaxis.set_ticklabels([])\n\n tdlh_axes = plt.axes(plot_positions[1][1])\n tdlh_axes.plot_date(time, temp_diff, 'ko-', label='Cloudiness',\n markersize=4, markeredgewidth=0,\n drawstyle=\"default\")\n tdlh_axes.fill_between(time, -60, temp_diff, where=np.array(sky_condition) == 'Clear',\n color='green', alpha=0.5)\n tdlh_axes.fill_between(time, -60, temp_diff, where=np.array(sky_condition) == 'Cloudy',\n color='yellow', alpha=0.5)\n tdlh_axes.fill_between(time, -60, temp_diff, where=np.array(sky_condition) == 'Very Cloudy',\n color='red', alpha=0.5)\n plt.grid(which='major', color='k')\n plt.yticks(range(-100, 100, 10))\n plt.xlim(date - tdelta(0, 60 * 60), date + tdelta(0, 5 * 60))\n plt.ylim(-60, 10)\n tdlh_axes.xaxis.set_major_locator(mins)\n tdlh_axes.xaxis.set_major_formatter(mins_fmt)\n tdlh_axes.xaxis.set_ticklabels([])\n tdlh_axes.yaxis.set_ticklabels([])\n\n print('Plot Wind Speed vs. Time')\n # -------------------------------------------------------------------------\n # Plot Wind Speed vs. Time\n w_axes = plt.axes(plot_positions[2][0])\n wind_speed = [x['data']['Wind Speed (km/h)']\n for x in entries\n if 'Wind Speed (km/h)' in x['data'].keys() and\n 'Wind Condition' in x['data'].keys() and\n 'Gust Condition' in x['data'].keys()]\n wind_mavg = movingaverage(wind_speed, 10)\n trans = {'Calm': 0, 'Windy': 1, 'Gusty': 1, 'Very Windy': 10, 'Very Gusty': 10}\n wind_condition = [trans[x['data']['Wind Condition']] + trans[x['data']['Gust Condition']]\n for x in entries\n if 'Wind Speed (km/h)' in x['data'].keys() and\n 'Wind Condition' in x['data'].keys() and\n 'Gust Condition' in x['data'].keys()]\n time = [x['date'] for x in entries\n if 'Wind Speed (km/h)' in x['data'].keys() and\n 'Wind Condition' in x['data'].keys() and\n 'Gust Condition' in x['data'].keys()]\n w_axes.plot_date(time, wind_speed, 'ko', alpha=0.5,\n markersize=2, markeredgewidth=0,\n drawstyle=\"default\")\n w_axes.plot_date(time, wind_mavg, 'b-',\n label='Wind Speed',\n markersize=3, markeredgewidth=0,\n linewidth=3, alpha=0.5,\n drawstyle=\"default\")\n w_axes.plot_date([start, end], [0, 0], 'k-', ms=1)\n w_axes.fill_between(time, -5, wind_speed,\n where=np.array(wind_condition) == 0,\n color='green', alpha=0.5)\n w_axes.fill_between(time, -5, wind_speed,\n where=(np.array(wind_condition) > 0) & (np.array(wind_condition) < 10),\n color='yellow', alpha=0.5)\n w_axes.fill_between(time, -5, wind_speed,\n where=np.array(wind_condition) > 10,\n color='red', alpha=0.5)\n try:\n max_wind = max(wind_speed)\n label_time = end - tdelta(0, 6 * 60 * 60)\n label_wind = 61\n w_axes.annotate('Max Gust: {:.1f} (km/h)'.format(max_wind),\n xy=(label_time, max_wind),\n xytext=(label_time, label_wind),\n size=16,\n )\n except:\n pass\n plt.ylabel(\"Wind (km/h)\")\n plt.grid(which='major', color='k')\n plt.yticks(range(-100, 100, 10))\n plt.xlim(start, end)\n wind_max = max([45, np.ceil(max(wind_speed) / 5.) * 5.])\n plt.ylim(0, 75)\n w_axes.xaxis.set_major_locator(hours)\n w_axes.xaxis.set_major_formatter(hours_fmt)\n w_axes.xaxis.set_ticklabels([])\n\n wlh_axes = plt.axes(plot_positions[2][1])\n wlh_axes.plot_date(time, wind_speed, 'ko', alpha=0.7,\n markersize=4, markeredgewidth=0,\n drawstyle=\"default\")\n wlh_axes.plot_date(time, wind_mavg, 'b-',\n label='Wind Speed',\n markersize=2, markeredgewidth=0,\n linewidth=3, alpha=0.5,\n drawstyle=\"default\")\n wlh_axes.plot_date([start, end], [0, 0], 'k-', ms=1)\n wlh_axes.fill_between(time, -5, wind_speed,\n where=np.array(wind_condition) == 0,\n color='green', alpha=0.5)\n wlh_axes.fill_between(time, -5, wind_speed,\n where=(np.array(wind_condition) > 0) & (np.array(wind_condition) < 10),\n color='yellow', alpha=0.5)\n wlh_axes.fill_between(time, -5, wind_speed,\n where=np.array(wind_condition) > 10,\n color='red', alpha=0.5)\n try:\n current_wind = current_values['data']['Wind Speed (km/h)']\n current_time = current_values['date']\n label_time = current_time - tdelta(0, 30 * 60)\n label_wind = 61\n wlh_axes.annotate('Currently: {:.0f} km/h'.format(current_wind),\n xy=(current_time, current_wind),\n xytext=(label_time, label_wind),\n size=16,\n )\n except:\n pass\n plt.grid(which='major', color='k')\n plt.yticks(range(-100, 100, 10))\n plt.xlim(date - tdelta(0, 60 * 60), date + tdelta(0, 5 * 60))\n wind_max = max([45, np.ceil(max(wind_speed) / 5.) * 5.])\n plt.ylim(0, 75)\n wlh_axes.xaxis.set_major_locator(mins)\n wlh_axes.xaxis.set_major_formatter(mins_fmt)\n wlh_axes.xaxis.set_ticklabels([])\n wlh_axes.yaxis.set_ticklabels([])\n\n print('Plot Rain Frequency vs. Time')\n # -------------------------------------------------------------------------\n # Plot Rain Frequency vs. Time\n rf_axes = plt.axes(plot_positions[3][0])\n rf_value = [x['data']['Rain Frequency']\n for x in entries\n if 'Rain Frequency' in x['data'].keys() and\n 'Rain Condition' in x['data'].keys()]\n rain_condition = [x['data']['Rain Condition']\n for x in entries\n if 'Rain Frequency' in x['data'].keys() and\n 'Rain Condition' in x['data'].keys()]\n time = [x['date'] for x in entries\n if 'Rain Frequency' in x['data'].keys() and\n 'Rain Condition' in x['data'].keys()]\n rf_axes.plot_date(time, rf_value, 'ko-', label='Rain',\n markersize=2, markeredgewidth=0,\n drawstyle=\"default\")\n rf_axes.fill_between(time, 0, rf_value, where=np.array(rain_condition) == 'Dry',\n color='green', alpha=0.5)\n rf_axes.fill_between(time, 0, rf_value, where=np.array(rain_condition) == 'Rain',\n color='red', alpha=0.5)\n plt.ylabel(\"Rain Sensor\")\n plt.grid(which='major', color='k')\n plt.ylim(120, 275)\n plt.xlim(start, end)\n rf_axes.xaxis.set_major_locator(hours)\n rf_axes.xaxis.set_major_formatter(hours_fmt)\n rf_axes.xaxis.set_ticklabels([])\n rf_axes.yaxis.set_ticklabels([])\n\n rflh_axes = plt.axes(plot_positions[3][1])\n rflh_axes.plot_date(time, rf_value, 'ko-', label='Rain',\n markersize=4, markeredgewidth=0,\n drawstyle=\"default\")\n rflh_axes.fill_between(time, 0, rf_value, where=np.array(rain_condition) == 'Dry',\n color='green', alpha=0.5)\n rflh_axes.fill_between(time, 0, rf_value, where=np.array(rain_condition) == 'Rain',\n color='red', alpha=0.5)\n plt.grid(which='major', color='k')\n plt.ylim(120, 275)\n plt.xlim(date - tdelta(0, 60 * 60), date + tdelta(0, 5 * 60))\n rflh_axes.xaxis.set_major_locator(mins)\n rflh_axes.xaxis.set_major_formatter(mins_fmt)\n rflh_axes.xaxis.set_ticklabels([])\n rflh_axes.yaxis.set_ticklabels([])\n\n print('Plot Safe/Unsafe vs. Time')\n # -------------------------------------------------------------------------\n # Safe/Unsafe vs. Time\n safe_axes = plt.axes(plot_positions[4][0])\n safe_value = [int(x['data']['Safe'])\n for x in entries\n if 'Safe' in x['data'].keys()]\n safe_time = [x['date'] for x in entries\n if 'Safe' in x['data'].keys()]\n safe_axes.plot_date(safe_time, safe_value, 'ko',\n markersize=2, markeredgewidth=0,\n drawstyle=\"default\")\n safe_axes.fill_between(safe_time, -1, safe_value, where=np.array(safe_value) == 1,\n color='green', alpha=0.5)\n safe_axes.fill_between(safe_time, -1, safe_value, where=np.array(safe_value) == 0,\n color='red', alpha=0.5)\n plt.ylabel(\"Safe\")\n plt.xlim(start, end)\n plt.ylim(-0.1, 1.1)\n plt.yticks([0, 1])\n plt.grid(which='major', color='k')\n safe_axes.xaxis.set_major_locator(hours)\n safe_axes.xaxis.set_major_formatter(hours_fmt)\n safe_axes.xaxis.set_ticklabels([])\n safe_axes.yaxis.set_ticklabels([])\n\n safelh_axes = plt.axes(plot_positions[4][1])\n safelh_axes.plot_date(safe_time, safe_value, 'ko-',\n markersize=4, markeredgewidth=0,\n drawstyle=\"default\")\n safelh_axes.fill_between(safe_time, -1, safe_value, where=np.array(safe_value) == 1,\n color='green', alpha=0.5)\n safelh_axes.fill_between(safe_time, -1, safe_value, where=np.array(safe_value) == 0,\n color='red', alpha=0.5)\n plt.ylim(-0.1, 1.1)\n plt.yticks([0, 1])\n plt.grid(which='major', color='k')\n plt.xlim(date - tdelta(0, 60 * 60), date + tdelta(0, 5 * 60))\n safelh_axes.xaxis.set_major_locator(mins)\n safelh_axes.xaxis.set_major_formatter(mins_fmt)\n safelh_axes.xaxis.set_ticklabels([])\n safelh_axes.yaxis.set_ticklabels([])\n\n print('Plot PWM Value vs. Time')\n # -------------------------------------------------------------------------\n # Plot PWM Value vs. Time\n pwm_axes = plt.axes(plot_positions[5][0])\n plt.ylabel(\"Heater (%)\")\n plt.ylim(-5, 105)\n plt.yticks([0, 25, 50, 75, 100])\n plt.xlim(start, end)\n plt.grid(which='major', color='k')\n rst_axes = pwm_axes.twinx()\n plt.ylim(-1, 21)\n plt.xlim(start, end)\n pwm_value = [x['data']['PWM Value']\n for x in entries\n if 'PWM Value' in x['data'].keys() and\n 'Rain Sensor Temp (C)' in x['data'].keys() and\n 'Ambient Temperature (C)' in x['data'].keys()]\n rst_delta = [x['data']['Rain Sensor Temp (C)'] - x['data']['Ambient Temperature (C)']\n for x in entries\n if 'PWM Value' in x['data'].keys() and\n 'Rain Sensor Temp (C)' in x['data'].keys() and\n 'Ambient Temperature (C)' in x['data'].keys()]\n time = [x['date'] for x in entries\n if 'PWM Value' in x['data'].keys() and\n 'Rain Sensor Temp (C)' in x['data'].keys() and\n 'Ambient Temperature (C)' in x['data'].keys()]\n rst_axes.plot_date(time, rst_delta, 'ro-', alpha=0.5,\n label='RST Delta (C)',\n markersize=2, markeredgewidth=0,\n drawstyle=\"default\")\n pwm_axes.plot_date(time, pwm_value, 'bo', label='Heater',\n markersize=2, markeredgewidth=0,\n drawstyle=\"default\")\n pwm_axes.xaxis.set_major_locator(hours)\n pwm_axes.xaxis.set_major_formatter(hours_fmt)\n\n pwmlh_axes = plt.axes(plot_positions[5][1])\n plt.ylim(-5, 105)\n plt.yticks([0, 25, 50, 75, 100])\n plt.xlim(date - tdelta(0, 60 * 60), date + tdelta(0, 5 * 60))\n plt.grid(which='major', color='k')\n rstlh_axes = pwmlh_axes.twinx()\n plt.ylim(-1, 21)\n plt.xlim(date - tdelta(0, 60 * 60), date + tdelta(0, 5 * 60))\n rstlh_axes.plot_date(time, rst_delta, 'ro-', alpha=0.5,\n label='RST Delta (C)',\n markersize=4, markeredgewidth=0,\n drawstyle=\"default\")\n rstlh_axes.xaxis.set_ticklabels([])\n rstlh_axes.yaxis.set_ticklabels([])\n pwmlh_axes.plot_date(time, pwm_value, 'bo', label='Heater',\n markersize=4, markeredgewidth=0,\n drawstyle=\"default\")\n pwmlh_axes.xaxis.set_major_locator(mins)\n pwmlh_axes.xaxis.set_major_formatter(mins_fmt)\n pwmlh_axes.yaxis.set_ticklabels([])\n\n # -------------------------------------------------------------------------\n # Plot Brightness vs. Time\n# ldr_axes = plt.axes(plot_positions[3][0])\n# max_ldr = 28587999.99999969\n# ldr_value = [x['data']['LDR Resistance (ohm)']\\\n# for x in entries\\\n# if 'LDR Resistance (ohm)' in x['data'].keys()]\n# brightness = [10.**(2. - 2.*x/max_ldr) for x in ldr_value]\n# time = [x['date'] for x in entries\\\n# if 'LDR Resistance (ohm)' in x['data'].keys()]\n# ldr_axes.plot_date(time, brightness, 'ko',\\\n# markersize=2, markeredgewidth=0,\\\n# drawstyle=\"default\")\n# plt.ylabel(\"Brightness (%)\")\n# plt.yticks(range(-100,100,10))\n# plt.ylim(-5,105)\n# plt.grid(which='major', color='k')\n# ldr_axes.xaxis.set_major_locator(hours)\n# ldr_axes.xaxis.set_major_formatter(hours_fmt)\n# plt.xlim(start, end)\n#\n# if obs.is_night(start):\n# plt.axvspan(start, morning_astronomical_twilight, ymin=0, ymax=1, color='blue', alpha=0.5)\n# plt.axvspan(morning_astronomical_twilight, morning_nautical_twilight, ymin=0, ymax=1, color='blue', alpha=0.3)\n# plt.axvspan(morning_nautical_twilight, morning_civil_twilight, ymin=0, ymax=1, color='blue', alpha=0.2)\n# plt.axvspan(morning_civil_twilight, sunrise, ymin=0, ymax=1, color='blue', alpha=0.1)\n# plt.axvspan(sunset, evening_civil_twilight, ymin=0, ymax=1, color='blue', alpha=0.1)\n# plt.axvspan(evening_civil_twilight, evening_nautical_twilight, ymin=0, ymax=1, color='blue', alpha=0.2)\n# plt.axvspan(evening_nautical_twilight, evening_astronomical_twilight, ymin=0, ymax=1, color='blue', alpha=0.3)\n# plt.axvspan(evening_astronomical_twilight, end, ymin=0, ymax=1, color='blue', alpha=0.5)\n# else:\n# plt.axvspan(sunset, evening_civil_twilight, ymin=0, ymax=1, color='blue', alpha=0.1)\n# plt.axvspan(evening_civil_twilight, evening_nautical_twilight, ymin=0, ymax=1, color='blue', alpha=0.2)\n# plt.axvspan(evening_nautical_twilight, evening_astronomical_twilight, ymin=0, ymax=1, color='blue', alpha=0.3)\n# plt.axvspan(evening_astronomical_twilight, morning_astronomical_twilight, ymin=0, ymax=1, color='blue', alpha=0.5)\n# plt.axvspan(morning_astronomical_twilight, morning_nautical_twilight, ymin=0, ymax=1, color='blue', alpha=0.3)\n# plt.axvspan(morning_nautical_twilight, morning_civil_twilight, ymin=0, ymax=1, color='blue', alpha=0.2)\n# plt.axvspan(morning_civil_twilight, sunrise, ymin=0, ymax=1, color='blue', alpha=0.1)\n\n # -------------------------------------------------------------------------\n plot_filename = '{}.png'.format(date_string)\n plot_file = os.path.expanduser('/var/panoptes/weather_plots/{}'.format(plot_filename))\n print('Save Figure: {}'.format(plot_file))\n plt.savefig(plot_file, dpi=dpi, bbox_inches='tight', pad_inches=0.10)\n # Link\n today_name = '/var/panoptes/weather_plots/today.png'\n if os.path.exists(today_name):\n os.remove(today_name)\n\n os.symlink(plot_file, today_name)", "metadata": "root.plot_weather", "header": "['module', '___EOS___']", "index": 1022 } ]
[ { "span": "threshold_gusty ", "start_line": 874, "start_column": 8, "end_line": 874, "end_column": 23 }, { "span": "threshold_gusty ", "start_line": 878, "start_column": 8, "end_line": 878, "end_column": 23 }, { "span": "wind_max ", "start_line": 1321, "start_column": 4, "end_line": 1321, "end_column": 12 } ]
[]
1
true
[ "[CLS]_", "Un", "used_", "local_", "variable_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "make", "\\u", "safety", "\\u", "decision_", "(_", "cfg_", ",_", "logger_", "=_", "None_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "'''", "\\", "10", ";", " ", " ", " ", " ", "Meth", "od", " ", "make", "s", " ", "decision", " ", "whe", "ther", " ", "condition", "s", " ", "are", " ", "safe", " ", "or", " ", "unsafe", ".", "\\", "10", ";", " ", " ", " ", " ", "'''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "logger_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "logger_", "._", "info_", "(_", "'", "Maki", "ng", " ", "safety", " ", "decision", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "If", " ", "sky", "-", "amb", " ", ">", " ", "threshol", "d", ",", " ", "then", " ", "cloud", "y", " ", "(", "safe", ")_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "'", "threshol", "d\\u", "cloud", "y", "'_", "in_", "cfg_", "._", "keys_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "threshol", "d\\u", "cloud", "y_", "=_", "cfg_", "[_", "'", "threshol", "d\\u", "cloud", "y", "'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "logger_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "logger_", "._", "warning_", "(_", "'", "Us", "ing", " ", "default", " ", "cloud", "y", " ", "threshol", "d", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "threshol", "d\\u", "cloud", "y_", "=_", "-_", "20_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "If", " ", "sky", "-", "amb", " ", ">", " ", "threshol", "d", ",", " ", "then", " ", "very", " ", "cloud", "y", " ", "(", "unsafe", ")_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "'", "threshol", "d\\u", "very", "\\u", "cloud", "y", "'_", "in_", "cfg_", "._", "keys_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "threshol", "d\\u", "very", "\\u", "cloud", "y_", "=_", "cfg_", "[_", "'", "threshol", "d\\u", "very", "\\u", "cloud", "y", "'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "logger_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "logger_", "._", "warning_", "(_", "'", "Us", "ing", " ", "default", " ", "very", " ", "cloud", "y", " ", "threshol", "d", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "threshol", "d\\u", "very", "\\u", "cloud", "y_", "=_", "-_", "15_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "If", " ", "avg", "\\u", "wind", " ", ">", " ", "threshol", "d", ",", " ", "then", " ", "wind", "y", " ", "(", "safe", ")_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "'", "threshol", "d\\u", "wind", "y", "'_", "in_", "cfg_", "._", "keys_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "threshol", "d\\u", "wind", "y_", "=_", "cfg_", "[_", "'", "threshol", "d\\u", "wind", "y", "'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "logger_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "logger_", "._", "warning_", "(_", "'", "Us", "ing", " ", "default", " ", "wind", "y", " ", "threshol", "d", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "threshol", "d\\u", "wind", "y_", "=_", "20_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "If", " ", "avg", "\\u", "wind", " ", ">", " ", "threshol", "d", ",", " ", "then", " ", "very", " ", "wind", "y", " ", "(", "unsafe", ")_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "'", "threshol", "d\\u", "very", "\\u", "wind", "y", "'_", "in_", "cfg_", "._", "keys_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "threshol", "d\\u", "very", "\\u", "wind", "y_", "=_", "cfg_", "[_", "'", "threshol", "d\\u", "very", "\\u", "wind", "y", "'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "logger_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "logger_", "._", "warning_", "(_", "'", "Us", "ing", " ", "default", " ", "very", " ", "wind", "y", " ", "threshol", "d", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "threshol", "d\\u", "very", "\\u", "wind", "y_", "=_", "30_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "If", " ", "wind", " ", ">", " ", "threshol", "d", ",", " ", "then", " ", "gus", "ty", " ", "(", "safe", ")_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "'", "threshol", "d\\u", "gus", "ty", "'_", "in_", "cfg_", "._", "keys_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "threshol", "d\\u", "gus", "ty_", "=_", "cfg_", "[_", "'", "threshol", "d\\u", "gus", "ty", "'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "logger_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "logger_", "._", "warning_", "(_", "'", "Us", "ing", " ", "default", " ", "gus", "ty", " ", "threshol", "d", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "threshol", "d\\u", "gus", "ty_", "=_", "40_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "If", " ", "wind", " ", ">", " ", "threshol", "d", ",", " ", "then", " ", "very", " ", "gus", "ty", " ", "(", "unsafe", ")_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "'", "threshol", "d\\u", "very", "\\u", "gus", "ty", "'_", "in_", "cfg_", "._", "keys_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "threshol", "d\\u", "very", "\\u", "gus", "ty_", "=_", "cfg_", "[_", "'", "threshol", "d\\u", "very", "\\u", "gus", "ty", "'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "logger_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "logger_", "._", "warning_", "(_", "'", "Us", "ing", " ", "default", " ", "very", " ", "gus", "ty", " ", "threshol", "d", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "threshol", "d\\u", "very", "\\u", "gus", "ty_", "=_", "50_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "If", " ", "rain", " ", "freque", "nc", "y", " ", "<", " ", "threshol", "d", ",", " ", "then", " ", "unsafe", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "'", "threshol", "d\\u", "rain", "y", "'_", "in_", "cfg_", "._", "keys_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "threshol", "d\\u", "rain_", "=_", "cfg_", "[_", "'", "threshol", "d\\u", "rain", "y", "'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "logger_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "logger_", "._", "warning_", "(_", "'", "Us", "ing", " ", "default", " ", "rain", " ", "threshol", "d", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "threshol", "d\\u", "rain_", "=_", "230_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Get", " ", "Las", "t", " ", "n", " ", "minute", "s", " ", "of", " ", "data_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "'", "safety", "\\u", "dela", "y", "'_", "in_", "cfg_", "._", "keys_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "safety", "\\u", "delay_", "=_", "cfg_", "[_", "'", "safety", "\\u", "dela", "y", "'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "logger_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "logger_", "._", "warning_", "(_", "'", "Us", "ing", " ", "default", " ", "safety", " ", "dela", "y", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "safety", "\\u", "delay_", "=_", "15.", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "end_", "=_", "dt_", "._", "utcnow_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "start_", "=_", "end_", "-_", "tde", "lta", "_", "(_", "0_", ",_", "int_", "(_", "safety", "\\u", "delay_", "*_", "60_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "db_", "=_", "Pan", "Mon", "go_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "entries_", "=_", "[_", "x_", "for_", "x_", "in_", "db_", "._", "weather_", "._", "find_", "(_", "{_", "'", "date", "'_", ":_", "{_", "'$", "gt", "'_", ":_", "start_", ",_", "'$", "lt", "'_", ":_", "end_", "}_", "}_", ")_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "logger_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "logger_", "._", "info_", "(_", "'", " ", " ", "Foun", "d", " ", "{}", " ", "wea", "ther", " ", "data", " ", "entri", "es", " ", "in", " ", "last", " ", "{:", ".0", "f", "}", " ", "minute", "s", "'_", "._", "format_", "(_", "len_", "(_", "entries_", ")_", ",_", "safety", "\\u", "delay_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Cloud", "iness", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "sky", "\\u", "diff_", "=_", "[_", "x_", "[_", "'", "data", "'_", "]_", "[_", "'", "Sky", " ", "Tempe", "ratur", "e", " ", "(", "C", ")'_", "]_", "-_", "x_", "[_", "'", "data", "'_", "]_", "[_", "'", "Ambi", "ent", " ", "Tempe", "ratur", "e", " ", "(", "C", ")'_", "]_", "\\u\\u\\uNL\\u\\u\\u_", "for_", "x_", "in_", "entries_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "'", "Ambi", "ent", " ", "Tempe", "ratur", "e", " ", "(", "C", ")'_", "in_", "x_", "[_", "'", "data", "'_", "]_", "._", "keys_", "(_", ")_", "and_", "'", "Sky", " ", "Tempe", "ratur", "e", " ", "(", "C", ")'_", "in_", "x_", "[_", "'", "data", "'_", "]_", "._", "keys_", "(_", ")_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "len_", "(_", "sky", "\\u", "diff_", ")_", "==_", "0_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "logger_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "logger_", "._", "info_", "(_", "'", " ", " ", "UNS", "AF", "E", ":", " ", "no", " ", "sky", " ", "tempe", "art", "ure", "s", " ", "found", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "sky", "\\u", "safe_", "=_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "cloud", "\\u", "condition_", "=_", "'", "Un", "know", "n", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "max_", "(_", "sky", "\\u", "diff_", ")_", ">_", "threshol", "d\\u", "very", "\\u", "cloud", "y_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "logger_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "logger_", "._", "info_", "(_", "'", " ", " ", "UNS", "AF", "E", ":", " ", " ", "Ver", "y", " ", "cloud", "y", " ", "in", " ", "last", " ", "{:", ".0", "f", "}", " ", "min", ".'_", "\\u\\u\\uNL\\u\\u\\u_", "'", " ", " ", "Max", " ", "sky", " ", "diff", " ", "{:", ".1", "f", "}", " ", "C", "'_", "._", "format_", "(_", "safety", "\\u", "delay_", ",_", "max_", "(_", "sky", "\\u", "diff_", ")_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "sky", "\\u", "safe_", "=_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "sky", "\\u", "safe_", "=_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "sky", "\\u", "diff_", "[_", "-_", "1_", "]_", ">_", "threshol", "d\\u", "very", "\\u", "cloud", "y_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "cloud", "\\u", "condition_", "=_", "'", "Ver", "y", " ", "Cloud", "y", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "sky", "\\u", "diff_", "[_", "-_", "1_", "]_", ">_", "threshol", "d\\u", "cloud", "y_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "cloud", "\\u", "condition_", "=_", "'", "Cloud", "y", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "cloud", "\\u", "condition_", "=_", "'", "Clear", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "logger_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "logger_", "._", "info_", "(_", "'", " ", " ", "Cloud", " ", "Cond", "ition", ":", " ", "{}", " ", "(", "Sky", "-", "Amb", "={", ":.", "1f", "}", " ", "C", ")'_", "._", "format_", "(_", "cloud", "\\u", "condition_", ",_", "sky", "\\u", "diff_", "[_", "-_", "1_", "]_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Wind", " ", "(", "averag", "e", " ", "and", " ", "gus", "ts", ")_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "wind", "\\u", "speed_", "=_", "[_", "x_", "[_", "'", "data", "'_", "]_", "[_", "'", "Wind", " ", "Spee", "d", " ", "(", "km", "/", "h", ")'_", "]_", "\\u\\u\\uNL\\u\\u\\u_", "for_", "x_", "in_", "entries_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "'", "Wind", " ", "Spee", "d", " ", "(", "km", "/", "h", ")'_", "in_", "x_", "[_", "'", "data", "'_", "]_", "._", "keys_", "(_", ")_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "len_", "(_", "wind", "\\u", "speed_", ")_", "==_", "0_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "logger_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "logger_", "._", "info_", "(_", "'", " ", " ", "UNS", "AF", "E", ":", " ", "no", " ", "wind", " ", "speed", " ", "readings", " ", "found", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "wind", "\\u", "safe_", "=_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "gus", "t", "\\u", "safe_", "=_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "wind", "\\u", "condition_", "=_", "'", "Un", "know", "n", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "gus", "t", "\\u", "condition_", "=_", "'", "Un", "know", "n", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "typical", "\\u", "data\\u", "interval_", "=_", "(_", "end_", "-_", "min_", "(_", "[_", "x_", "[_", "'", "date", "'_", "]_", "for_", "x_", "in_", "entries_", "]_", ")_", ")_", "._", "total", "\\u", "seconds_", "(_", ")_", "/_", "len_", "(_", "entries_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "mav", "g", "\\u", "count_", "=_", "int_", "(_", "np_", "._", "ceil_", "(_", "120", "._", "/_", "typical", "\\u", "data\\u", "interval_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "wind", "\\u", "mav", "g_", "=_", "movin", "ga", "vera", "ge_", "(_", "wind", "\\u", "speed_", ",_", "mav", "g", "\\u", "count_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Wind", "y", "?", "_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "max_", "(_", "wind", "\\u", "mav", "g_", ")_", ">_", "threshol", "d\\u", "very", "\\u", "wind", "y_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "logger_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "logger_", "._", "info_", "(_", "'", " ", " ", "UNS", "AF", "E", ":", " ", " ", "Ver", "y", " ", "wind", "y", " ", "in", " ", "last", " ", "{:", ".0", "f", "}", " ", "min", ".'_", "\\u\\u\\uNL\\u\\u\\u_", "'", " ", " ", "Max", " ", "wind", " ", "speed", " ", "{:", ".1", "f", "}", " ", "kp", "h", "'_", "._", "format_", "(_", "safety", "\\u", "delay_", ",_", "max_", "(_", "wind", "\\u", "mav", "g_", ")_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "wind", "\\u", "safe_", "=_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "wind", "\\u", "safe_", "=_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "wind", "\\u", "mav", "g_", "[_", "-_", "1_", "]_", ">_", "threshol", "d\\u", "very", "\\u", "wind", "y_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "wind", "\\u", "condition_", "=_", "'", "Ver", "y", " ", "Wind", "y", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "wind", "\\u", "mav", "g_", "[_", "-_", "1_", "]_", ">_", "threshol", "d\\u", "wind", "y_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "wind", "\\u", "condition_", "=_", "'", "Wind", "y", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "wind", "\\u", "condition_", "=_", "'", "Cal", "m", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "logger_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "logger_", "._", "info_", "(_", "'", " ", " ", "Wind", " ", "Cond", "ition", ":", " ", "{}", " ", "({", ":.", "1f", "}", " ", "km", "/", "h", ")'_", "._", "format_", "(_", "wind", "\\u", "condition_", ",_", "wind", "\\u", "mav", "g_", "[_", "-_", "1_", "]_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Gu", "sty", "?", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "max_", "(_", "wind", "\\u", "speed_", ")_", ">_", "threshol", "d\\u", "very", "\\u", "gus", "ty_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "logger_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "logger_", "._", "info_", "(_", "'", " ", " ", "UNS", "AF", "E", ":", " ", " ", "Ver", "y", " ", "gus", "ty", " ", "in", " ", "last", " ", "{:", ".0", "f", "}", " ", "min", ".'_", "\\u\\u\\uNL\\u\\u\\u_", "'", " ", " ", "Max", " ", "gus", "t", " ", "speed", " ", "{:", ".1", "f", "}", " ", "kp", "h", "'_", "._", "format_", "(_", "safety", "\\u", "delay_", ",_", "max_", "(_", "wind", "\\u", "speed_", ")_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "gus", "t", "\\u", "safe_", "=_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "gus", "t", "\\u", "safe_", "=_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "wind", "\\u", "speed_", "[_", "-_", "1_", "]_", ">_", "threshol", "d\\u", "very", "\\u", "gus", "ty_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "gus", "t", "\\u", "condition_", "=_", "'", "Ver", "y", " ", "Gu", "sty", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "wind", "\\u", "speed_", "[_", "-_", "1_", "]_", ">_", "threshol", "d\\u", "wind", "y_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "gus", "t", "\\u", "condition_", "=_", "'", "Gu", "sty", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "gus", "t", "\\u", "condition_", "=_", "'", "Cal", "m", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "logger_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "logger_", "._", "info_", "(_", "'", " ", " ", "Gu", "st", " ", "Cond", "ition", ":", " ", "{}", " ", "({", ":.", "1f", "}", " ", "km", "/", "h", ")'_", "._", "format_", "(_", "gus", "t", "\\u", "condition_", ",_", "wind", "\\u", "speed_", "[_", "-_", "1_", "]_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Rain", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "rf", "\\u", "value_", "=_", "[_", "x_", "[_", "'", "data", "'_", "]_", "[_", "'", "Rain", " ", "Freq", "uenc", "y", "'_", "]_", "\\u\\u\\uNL\\u\\u\\u_", "for_", "x_", "in_", "entries_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "'", "Rain", " ", "Freq", "uenc", "y", "'_", "in_", "x_", "[_", "'", "data", "'_", "]_", "._", "keys_", "(_", ")_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "len_", "(_", "rf", "\\u", "value_", ")_", "==_", "0_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "rain", "\\u", "safe_", "=_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "rain", "\\u", "condition_", "=_", "'", "Un", "know", "n", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "min_", "(_", "rf", "\\u", "value_", ")_", "<_", "threshol", "d\\u", "rain_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "logger_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "logger_", "._", "info_", "(_", "'", " ", " ", "UNS", "AF", "E", ":", " ", " ", "Rain", " ", "in", " ", "last", " ", "{:", ".0", "f", "}", " ", "min", ".'_", "._", "format_", "(_", "safety", "\\u", "delay_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "rain", "\\u", "safe_", "=_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "rain", "\\u", "safe_", "=_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "rf", "\\u", "value_", "[_", "-_", "1_", "]_", "<_", "threshol", "d\\u", "rain_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "rain", "\\u", "condition_", "=_", "'", "Rain", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "rain", "\\u", "condition_", "=_", "'", "Dry", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "logger_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "logger_", "._", "info_", "(_", "'", " ", " ", "Rain", " ", "Cond", "ition", ":", " ", "{}'_", "._", "format_", "(_", "rain", "\\u", "condition_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "safe_", "=_", "sky", "\\u", "safe_", "&_", "wind", "\\u", "safe_", "&_", "gus", "t", "\\u", "safe_", "&_", "rain", "\\u", "safe_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "translator_", "=_", "{_", "True_", ":_", "'", "safe", "'_", ",_", "False_", ":_", "'", "unsafe", "'_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "logger_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "logger_", "._", "info_", "(_", "'", "Wea", "ther", " ", "is", " ", "{}'_", "._", "format_", "(_", "translator_", "[_", "safe_", "]_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "safe", "\\u", "dict_", "=_", "{_", "'", "Safe", "'_", ":_", "safe_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "Sky", "'_", ":_", "cloud", "\\u", "condition_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "Wind", "'_", ":_", "wind", "\\u", "condition_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "Gu", "st", "'_", ":_", "gus", "t", "\\u", "condition_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "Rain", "'_", ":_", "rain", "\\u", "condition_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "safe", "\\u", "dict_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "plot", "\\u", "weather_", "(_", "date", "\\u", "string_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "import_", "matplotlib_", "as_", "mpl_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "mpl_", "._", "use_", "(_", "'", "Agg", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "matplotlib_", "import_", "pyplot_", "as_", "plt_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "matplotlib_", "._", "dates_", "import_", "Hour", "Locator_", ",_", "Minute", "Locator_", ",_", "Date", "Formatter_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "plt_", "._", "io", "ff_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "dpi_", "=_", "100_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "plt_", "._", "figure_", "(_", "figsize_", "=_", "(_", "16_", ",_", "9_", ")_", ",_", "dpi_", "=_", "dpi_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "hours_", "=_", "Hour", "Locator_", "(_", "by", "hour_", "=_", "range_", "(_", "24_", ")_", ",_", "interval_", "=_", "1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "hour", "s", "\\u", "fmt_", "=_", "Date", "Formatter_", "(_", "'%", "H", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "mins_", "=_", "Minute", "Locator_", "(_", "range_", "(_", "0_", ",_", "60_", ",_", "15_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "mins", "\\u", "fmt_", "=_", "Date", "Formatter_", "(_", "'%", "H", ":", "%", "M", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "not_", "date", "\\u", "string_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "today_", "=_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "date_", "=_", "dt_", "._", "utcnow_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "date", "\\u", "string_", "=_", "date_", "._", "strftime_", "(_", "'%", "Y", "%", "m", "%", "d", "UT", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "today_", "=_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "date_", "=_", "dt_", "._", "strptime_", "(_", "'{}", " ", "23", ":", "5", "9", ":", "5", "9", "'_", "._", "format_", "(_", "date", "\\u", "string_", ")_", ",_", "'%", "Y", "%", "m", "%", "d", "UT", " ", "%", "H", ":", "%", "M", ":", "%", "S", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "start_", "=_", "dt_", "(_", "date_", "._", "year_", ",_", "date_", "._", "month_", ",_", "date_", "._", "day_", ",_", "0_", ",_", "0_", ",_", "0_", ",_", "0_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "end_", "=_", "dt_", "(_", "date_", "._", "year_", ",_", "date_", "._", "month_", ",_", "date_", "._", "day_", ",_", "23_", ",_", "59_", ",_", "59_", ",_", "0_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "--------------", "--------------", "--------------", "--------------", "--------------", "--", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "dete", "rmin", "e", " ", "sun", "rise", " ", "and", " ", "suns", "et", " ", "times_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "--------------", "--------------", "--------------", "--------------", "--------------", "--", "_", "\\u\\u\\uNL\\u\\u\\u_", "cfg_", "=_", "load", "\\u", "config_", "(_", ")_", "[_", "'", "location", "'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "loc_", "=_", "Ear", "th", "Location_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "lat_", "=_", "cfg_", "[_", "'", "latitude", "'_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "lon_", "=_", "cfg_", "[_", "'", "longitude", "'_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "height_", "=_", "cfg_", "[_", "'", "elevat", "ion", "'_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "obs_", "=_", "Observer_", "(_", "location_", "=_", "loc_", ",_", "name_", "=_", "'", "PAN", "OPT", "ES", "'_", ",_", "timezone_", "=_", "cfg_", "[_", "'", "timezon", "e", "'_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "suns", "et_", "=_", "obs_", "._", "sun", "\\u", "set\\u", "time_", "(_", "Time_", "(_", "start_", ")_", ",_", "which_", "=_", "'", "next", "'_", ")_", "._", "datetime_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "even", "ing", "\\u", "civi", "l\\u", "twi", "light_", "=_", "obs_", "._", "twi", "light", "\\u", "even", "ing", "\\u", "civi", "l_", "(_", "Time_", "(_", "start_", ")_", ",_", "which_", "=_", "'", "next", "'_", ")_", "._", "datetime_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "even", "ing", "\\u", "naut", "ical", "\\u", "twi", "light_", "=_", "obs_", "._", "twi", "light", "\\u", "even", "ing", "\\u", "naut", "ical_", "(_", "Time_", "(_", "start_", ")_", ",_", "which_", "=_", "'", "next", "'_", ")_", "._", "datetime_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "even", "ing", "\\u", "astro", "nomi", "cal", "\\u", "twi", "light_", "=_", "obs_", "._", "twi", "light", "\\u", "even", "ing", "\\u", "astro", "nomi", "cal_", "(_", "Time_", "(_", "start_", ")_", ",_", "which_", "=_", "'", "next", "'_", ")_", "._", "datetime_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "mor", "ning", "\\u", "astro", "nomi", "cal", "\\u", "twi", "light_", "=_", "obs_", "._", "twi", "light", "\\u", "mor", "ning", "\\u", "astro", "nomi", "cal_", "(_", "Time_", "(_", "start_", ")_", ",_", "which_", "=_", "'", "next", "'_", ")_", "._", "datetime_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "mor", "ning", "\\u", "naut", "ical", "\\u", "twi", "light_", "=_", "obs_", "._", "twi", "light", "\\u", "mor", "ning", "\\u", "naut", "ical_", "(_", "Time_", "(_", "start_", ")_", ",_", "which_", "=_", "'", "next", "'_", ")_", "._", "datetime_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "mor", "ning", "\\u", "civi", "l\\u", "twi", "light_", "=_", "obs_", "._", "twi", "light", "\\u", "mor", "ning", "\\u", "civi", "l_", "(_", "Time_", "(_", "start_", ")_", ",_", "which_", "=_", "'", "next", "'_", ")_", "._", "datetime_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "sun", "rise", "_", "=_", "obs_", "._", "sun", "\\u", "rise", "\\u", "time_", "(_", "Time_", "(_", "start_", ")_", ",_", "which_", "=_", "'", "next", "'_", ")_", "._", "datetime_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "print_", "(_", "'", "start", ":", " ", " ", " ", "{}'_", "._", "format_", "(_", "Time_", "(_", "start_", ")_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "print_", "(_", "obs_", "._", "is", "\\u", "night", "_", "(_", "Time_", "(_", "start_", ")_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "print_", "(_", "'", "suns", "et", ":", " ", " ", "{}'_", "._", "format_", "(_", "suns", "et_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "print_", "(_", "'", "even", "ing", "\\u", "civi", "l\\u", "twi", "light", ":", " ", " ", " ", " ", "{}'_", "._", "format_", "(_", "even", "ing", "\\u", "civi", "l\\u", "twi", "light_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "print_", "(_", "'", "even", "ing", "\\u", "naut", "ical", "\\u", "twi", "light", ":", " ", "{}'_", "._", "format_", "(_", "even", "ing", "\\u", "naut", "ical", "\\u", "twi", "light_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "print_", "(_", "'", "even", "ing", "\\u", "astro", "nomi", "cal", "\\u", "twi", "light", ":", " ", "{}'_", "._", "format_", "(_", "even", "ing", "\\u", "astro", "nomi", "cal", "\\u", "twi", "light_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "print_", "(_", "'", "mor", "ning", "\\u", "astro", "nomi", "cal", "\\u", "twi", "light", ":", " ", "{}'_", "._", "format_", "(_", "mor", "ning", "\\u", "astro", "nomi", "cal", "\\u", "twi", "light_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "print_", "(_", "'", "mor", "ning", "\\u", "naut", "ical", "\\u", "twi", "light", ":", " ", "{}'_", "._", "format_", "(_", "mor", "ning", "\\u", "naut", "ical", "\\u", "twi", "light_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "print_", "(_", "'", "mor", "ning", "\\u", "civi", "l\\u", "twi", "light", ":", " ", " ", " ", " ", "{}'_", "._", "format_", "(_", "mor", "ning", "\\u", "civi", "l\\u", "twi", "light_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "--------------", "--------------", "--------------", "--------------", "--------------", "---", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Plot", " ", "a", " ", "day", "'", "s", " ", "weather_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "--------------", "--------------", "--------------", "--------------", "--------------", "---", "_", "\\u\\u\\uNL\\u\\u\\u_", "plot", "\\u", "positions_", "=_", "[_", "(_", "[_", "0.000_", ",_", "0.83", "5_", ",_", "0.70", "0_", ",_", "0.17", "0_", "]_", ",_", "[_", "0.72", "0_", ",_", "0.83", "5_", ",_", "0.28", "0_", ",_", "0.17", "0_", "]_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "[_", "0.000_", ",_", "0.63", "5_", ",_", "0.70", "0_", ",_", "0.17", "0_", "]_", ",_", "[_", "0.72", "0_", ",_", "0.63", "5_", ",_", "0.28", "0_", ",_", "0.17", "0_", "]_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "[_", "0.000_", ",_", "0.45", "0_", ",_", "0.70", "0_", ",_", "0.17", "0_", "]_", ",_", "[_", "0.72", "0_", ",_", "0.45", "0_", ",_", "0.28", "0_", ",_", "0.17", "0_", "]_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "[_", "0.000_", ",_", "0.26", "5_", ",_", "0.70", "0_", ",_", "0.17", "0_", "]_", ",_", "[_", "0.72", "0_", ",_", "0.26", "5_", ",_", "0.28", "0_", ",_", "0.17", "0_", "]_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "[_", "0.000_", ",_", "0.18", "5_", ",_", "0.70", "0_", ",_", "0.06", "5_", "]_", ",_", "[_", "0.72", "0_", ",_", "0.18", "5_", ",_", "0.28", "0_", ",_", "0.06", "5_", "]_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "[_", "0.000_", ",_", "0.000_", ",_", "0.70", "0_", ",_", "0.17", "0_", "]_", ",_", "[_", "0.72", "0_", ",_", "0.000_", ",_", "0.28", "0_", ",_", "0.17", "0_", "]_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Connect", " ", "to", " ", "sensor", "s", " ", "collection_", "\\u\\u\\uNL\\u\\u\\u_", "db_", "=_", "Pan", "Mon", "go_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "entries_", "=_", "[_", "x_", "for_", "x_", "in_", "db_", "._", "weather_", "._", "find_", "(_", "{_", "'", "date", "'_", ":_", "{_", "'$", "gt", "'_", ":_", "start_", ",_", "'$", "lt", "'_", ":_", "end_", "}_", "}_", ")_", "._", "sort_", "(_", "[_", "(_", "'", "date", "'_", ",_", "pymongo_", "._", "ASC", "ENDING_", ")_", "]_", ")_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "today_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "current", "\\u", "values_", "=_", "[_", "x_", "for_", "x_", "in_", "db_", "._", "current_", "._", "find_", "(_", "{_", "\"", "type", "\"_", ":_", "\"", "wea", "ther", "\"_", "}_", ")_", "]_", "[_", "0_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "current", "\\u", "values_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "print_", "(_", "'", "Plot", " ", "Ambi", "ent", " ", "Tempe", "ratur", "e", " ", "vs", ".", " ", "Time", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "--------------", "--------------", "--------------", "--------------", "--------------", "---", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Plot", " ", "Ambi", "ent", " ", "Tempe", "ratur", "e", " ", "vs", ".", " ", "Time_", "\\u\\u\\uNL\\u\\u\\u_", "t", "\\u", "axes_", "=_", "plt_", "._", "axes_", "(_", "plot", "\\u", "positions_", "[_", "0_", "]_", "[_", "0_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "today_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "time", "\\u", "title_", "=_", "date_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "time", "\\u", "title_", "=_", "end_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "plt_", "._", "title_", "(_", "'", "Wea", "ther", " ", "for", " ", "{}", " ", "at", " ", "{}'_", "._", "format_", "(_", "date", "\\u", "string_", ",_", "time", "\\u", "title_", "._", "strftime_", "(_", "'%", "H", ":", "%", "M", ":", "%", "S", " ", "UT", "'_", ")_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "amb", "\\u", "temp_", "=_", "[_", "x_", "[_", "'", "data", "'_", "]_", "[_", "'", "Ambi", "ent", " ", "Tempe", "ratur", "e", " ", "(", "C", ")'_", "]_", "\\u\\u\\uNL\\u\\u\\u_", "for_", "x_", "in_", "entries_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "'", "Ambi", "ent", " ", "Tempe", "ratur", "e", " ", "(", "C", ")'_", "in_", "x_", "[_", "'", "data", "'_", "]_", "._", "keys_", "(_", ")_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "time_", "=_", "[_", "x_", "[_", "'", "date", "'_", "]_", "for_", "x_", "in_", "entries_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "'", "Ambi", "ent", " ", "Tempe", "ratur", "e", " ", "(", "C", ")'_", "in_", "x_", "[_", "'", "data", "'_", "]_", "._", "keys_", "(_", ")_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "t", "\\u", "axes_", "._", "plot", "\\u", "date_", "(_", "time_", ",_", "amb", "\\u", "temp_", ",_", "'", "ko", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "markersize_", "=_", "2_", ",_", "marker", "edge", "width_", "=_", "0_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "draws", "tyle_", "=_", "\"", "default", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "max", "\\u", "temp_", "=_", "max_", "(_", "amb", "\\u", "temp_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "min", "\\u", "temp_", "=_", "min_", "(_", "amb", "\\u", "temp_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "label", "\\u", "time_", "=_", "end_", "-_", "tde", "lta", "_", "(_", "0_", ",_", "7_", "*_", "60_", "*_", "60_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "label", "\\u", "temp_", "=_", "28_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "t", "\\u", "axes_", "._", "annotate_", "(_", "'", "Lo", "w", ":", " ", "{:", "4.1", "f", "}", " ", "$", "^", "\\\\", "circ", "$", "C", ",", " ", "Hig", "h", ":", " ", "{:", "4.1", "f", "}", " ", "$", "^", "\\\\", "circ", "$", "C", "'_", "._", "format_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "min", "\\u", "temp_", ",_", "max", "\\u", "temp_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "xy_", "=_", "(_", "label", "\\u", "time_", ",_", "max", "\\u", "temp_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "xy", "text_", "=_", "(_", "label", "\\u", "time_", ",_", "label", "\\u", "temp_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "size_", "=_", "16_", ",_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "pass_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "plt_", "._", "ylabel_", "(_", "\"", "Ambi", "ent", " ", "Temp", ".", " ", "(", "C", ")\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "plt_", "._", "grid_", "(_", "which_", "=_", "'", "major", "'_", ",_", "color_", "=_", "'", "k", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "plt_", "._", "yticks_", "(_", "range_", "(_", "-_", "100_", ",_", "100_", ",_", "10_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "plt_", "._", "xlim_", "(_", "start_", ",_", "end_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "plt_", "._", "ylim_", "(_", "-_", "5_", ",_", "35_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "t", "\\u", "axes_", "._", "xaxis_", "._", "set\\u", "major", "\\u", "locator_", "(_", "hours_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "t", "\\u", "axes_", "._", "xaxis_", "._", "set\\u", "major", "\\u", "formatter_", "(_", "hour", "s", "\\u", "fmt_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "obs_", "._", "is", "\\u", "night", "_", "(_", "Time_", "(_", "start_", ")_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "plt_", "._", "ax", "vsp", "an_", "(_", "start_", ",_", "mor", "ning", "\\u", "astro", "nomi", "cal", "\\u", "twi", "light_", ",_", "ymin_", "=_", "0_", ",_", "ymax_", "=_", "1_", ",_", "color_", "=_", "'", "blue", "'_", ",_", "alpha_", "=_", "0.5_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "plt_", "._", "ax", "vsp", "an_", "(_", "mor", "ning", "\\u", "astro", "nomi", "cal", "\\u", "twi", "light_", ",_", "mor", "ning", "\\u", "naut", "ical", "\\u", "twi", "light_", ",_", "ymin_", "=_", "0_", ",_", "ymax_", "=_", "1_", ",_", "color_", "=_", "'", "blue", "'_", ",_", "alpha_", "=_", "0.3_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "plt_", "._", "ax", "vsp", "an_", "(_", "mor", "ning", "\\u", "naut", "ical", "\\u", "twi", "light_", ",_", "mor", "ning", "\\u", "civi", "l\\u", "twi", "light_", ",_", "ymin_", "=_", "0_", ",_", "ymax_", "=_", "1_", ",_", "color_", "=_", "'", "blue", "'_", ",_", "alpha_", "=_", "0.2_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "plt_", "._", "ax", "vsp", "an_", "(_", "mor", "ning", "\\u", "civi", "l\\u", "twi", "light_", ",_", "sun", "rise", "_", ",_", "ymin_", "=_", "0_", ",_", "ymax_", "=_", "1_", ",_", "color_", "=_", "'", "blue", "'_", ",_", "alpha_", "=_", "0.1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "plt_", "._", "ax", "vsp", "an_", "(_", "suns", "et_", ",_", "even", "ing", "\\u", "civi", "l\\u", "twi", "light_", ",_", "ymin_", "=_", "0_", ",_", "ymax_", "=_", "1_", ",_", "color_", "=_", "'", "blue", "'_", ",_", "alpha_", "=_", "0.1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "plt_", "._", "ax", "vsp", "an_", "(_", "even", "ing", "\\u", "civi", "l\\u", "twi", "light_", ",_", "even", "ing", "\\u", "naut", "ical", "\\u", "twi", "light_", ",_", "ymin_", "=_", "0_", ",_", "ymax_", "=_", "1_", ",_", "color_", "=_", "'", "blue", "'_", ",_", "alpha_", "=_", "0.2_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "plt_", "._", "ax", "vsp", "an_", "(_", "even", "ing", "\\u", "naut", "ical", "\\u", "twi", "light_", ",_", "even", "ing", "\\u", "astro", "nomi", "cal", "\\u", "twi", "light_", ",_", "ymin_", "=_", "0_", ",_", "ymax_", "=_", "1_", ",_", "color_", "=_", "'", "blue", "'_", ",_", "alpha_", "=_", "0.3_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "plt_", "._", "ax", "vsp", "an_", "(_", "even", "ing", "\\u", "astro", "nomi", "cal", "\\u", "twi", "light_", ",_", "end_", ",_", "ymin_", "=_", "0_", ",_", "ymax_", "=_", "1_", ",_", "color_", "=_", "'", "blue", "'_", ",_", "alpha_", "=_", "0.5_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "plt_", "._", "ax", "vsp", "an_", "(_", "suns", "et_", ",_", "even", "ing", "\\u", "civi", "l\\u", "twi", "light_", ",_", "ymin_", "=_", "0_", ",_", "ymax_", "=_", "1_", ",_", "color_", "=_", "'", "blue", "'_", ",_", "alpha_", "=_", "0.1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "plt_", "._", "ax", "vsp", "an_", "(_", "even", "ing", "\\u", "civi", "l\\u", "twi", "light_", ",_", "even", "ing", "\\u", "naut", "ical", "\\u", "twi", "light_", ",_", "ymin_", "=_", "0_", ",_", "ymax_", "=_", "1_", ",_", "color_", "=_", "'", "blue", "'_", ",_", "alpha_", "=_", "0.2_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "plt_", "._", "ax", "vsp", "an_", "(_", "even", "ing", "\\u", "naut", "ical", "\\u", "twi", "light_", ",_", "even", "ing", "\\u", "astro", "nomi", "cal", "\\u", "twi", "light_", ",_", "ymin_", "=_", "0_", ",_", "ymax_", "=_", "1_", ",_", "color_", "=_", "'", "blue", "'_", ",_", "alpha_", "=_", "0.3_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "plt_", "._", "ax", "vsp", "an_", "(_", "even", "ing", "\\u", "astro", "nomi", "cal", "\\u", "twi", "light_", ",_", "mor", "ning", "\\u", "astro", "nomi", "cal", "\\u", "twi", "light_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "ymin_", "=_", "0_", ",_", "ymax_", "=_", "1_", ",_", "color_", "=_", "'", "blue", "'_", ",_", "alpha_", "=_", "0.5_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "plt_", "._", "ax", "vsp", "an_", "(_", "mor", "ning", "\\u", "astro", "nomi", "cal", "\\u", "twi", "light_", ",_", "mor", "ning", "\\u", "naut", "ical", "\\u", "twi", "light_", ",_", "ymin_", "=_", "0_", ",_", "ymax_", "=_", "1_", ",_", "color_", "=_", "'", "blue", "'_", ",_", "alpha_", "=_", "0.3_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "plt_", "._", "ax", "vsp", "an_", "(_", "mor", "ning", "\\u", "naut", "ical", "\\u", "twi", "light_", ",_", "mor", "ning", "\\u", "civi", "l\\u", "twi", "light_", ",_", "ymin_", "=_", "0_", ",_", "ymax_", "=_", "1_", ",_", "color_", "=_", "'", "blue", "'_", ",_", "alpha_", "=_", "0.2_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "plt_", "._", "ax", "vsp", "an_", "(_", "mor", "ning", "\\u", "civi", "l\\u", "twi", "light_", ",_", "sun", "rise", "_", ",_", "ymin_", "=_", "0_", ",_", "ymax_", "=_", "1_", ",_", "color_", "=_", "'", "blue", "'_", ",_", "alpha_", "=_", "0.1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "tl", "h", "\\u", "axes_", "=_", "plt_", "._", "axes_", "(_", "plot", "\\u", "positions_", "[_", "0_", "]_", "[_", "1_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "plt_", "._", "title_", "(_", "'", "Las", "t", " ", "Hour", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "tl", "h", "\\u", "axes_", "._", "plot", "\\u", "date_", "(_", "time_", ",_", "amb", "\\u", "temp_", ",_", "'", "ko", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "markersize_", "=_", "4_", ",_", "marker", "edge", "width_", "=_", "0_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "draws", "tyle_", "=_", "\"", "default", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "current", "\\u", "amb", "\\u", "temp_", "=_", "current", "\\u", "values_", "[_", "'", "data", "'_", "]_", "[_", "'", "Ambi", "ent", " ", "Tempe", "ratur", "e", " ", "(", "C", ")'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "current", "\\u", "time_", "=_", "current", "\\u", "values_", "[_", "'", "date", "'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "label", "\\u", "time_", "=_", "current", "\\u", "time_", "-_", "tde", "lta", "_", "(_", "0_", ",_", "30_", "*_", "60_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "label", "\\u", "temp_", "=_", "28_", "#", " ", "current", "\\u", "amb", "\\u", "temp", " ", "+", " ", "7_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "tl", "h", "\\u", "axes_", "._", "annotate_", "(_", "'", "Curr", "ent", "ly", ":", " ", "{:", ".1", "f", "}", " ", "$", "^", "\\\\", "circ", "$", "C", "'_", "._", "format_", "(_", "current", "\\u", "amb", "\\u", "temp_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "xy_", "=_", "(_", "current", "\\u", "time_", ",_", "current", "\\u", "amb", "\\u", "temp_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "xy", "text_", "=_", "(_", "label", "\\u", "time_", ",_", "label", "\\u", "temp_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "size_", "=_", "16_", ",_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "pass_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "plt_", "._", "grid_", "(_", "which_", "=_", "'", "major", "'_", ",_", "color_", "=_", "'", "k", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "plt_", "._", "yticks_", "(_", "range_", "(_", "-_", "100_", ",_", "100_", ",_", "10_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "tl", "h", "\\u", "axes_", "._", "xaxis_", "._", "set\\u", "major", "\\u", "locator_", "(_", "mins_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "tl", "h", "\\u", "axes_", "._", "xaxis_", "._", "set\\u", "major", "\\u", "formatter_", "(_", "mins", "\\u", "fmt_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "tl", "h", "\\u", "axes_", "._", "yaxis_", "._", "set\\u", "tickl", "abels_", "(_", "[_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "plt_", "._", "xlim_", "(_", "date_", "-_", "tde", "lta", "_", "(_", "0_", ",_", "60_", "*_", "60_", ")_", ",_", "date_", "+_", "tde", "lta", "_", "(_", "0_", ",_", "5_", "*_", "60_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "plt_", "._", "ylim_", "(_", "-_", "5_", ",_", "35_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "print_", "(_", "'", "Plot", " ", "Tempe", "ratur", "e", " ", "Difference", " ", "vs", ".", " ", "Time", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "--------------", "--------------", "--------------", "--------------", "--------------", "---", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Plot", " ", "Tempe", "ratur", "e", " ", "Difference", " ", "vs", ".", " ", "Time_", "\\u\\u\\uNL\\u\\u\\u_", "td", "\\u", "axes_", "=_", "plt_", "._", "axes_", "(_", "plot", "\\u", "positions_", "[_", "1_", "]_", "[_", "0_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "temp", "\\u", "diff_", "=_", "[_", "x_", "[_", "'", "data", "'_", "]_", "[_", "'", "Sky", " ", "Tempe", "ratur", "e", " ", "(", "C", ")'_", "]_", "-_", "x_", "[_", "'", "data", "'_", "]_", "[_", "'", "Ambi", "ent", " ", "Tempe", "ratur", "e", " ", "(", "C", ")'_", "]_", "\\u\\u\\uNL\\u\\u\\u_", "for_", "x_", "in_", "entries_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "'", "Sky", " ", "Tempe", "ratur", "e", " ", "(", "C", ")'_", "in_", "x_", "[_", "'", "data", "'_", "]_", "._", "keys_", "(_", ")_", "and_", "'", "Ambi", "ent", " ", "Tempe", "ratur", "e", " ", "(", "C", ")'_", "in_", "x_", "[_", "'", "data", "'_", "]_", "._", "keys_", "(_", ")_", "and_", "'", "Sky", " ", "Cond", "ition", "'_", "in_", "x_", "[_", "'", "data", "'_", "]_", "._", "keys_", "(_", ")_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "time_", "=_", "[_", "x_", "[_", "'", "date", "'_", "]_", "for_", "x_", "in_", "entries_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "'", "Sky", " ", "Tempe", "ratur", "e", " ", "(", "C", ")'_", "in_", "x_", "[_", "'", "data", "'_", "]_", "._", "keys_", "(_", ")_", "and_", "'", "Ambi", "ent", " ", "Tempe", "ratur", "e", " ", "(", "C", ")'_", "in_", "x_", "[_", "'", "data", "'_", "]_", "._", "keys_", "(_", ")_", "and_", "'", "Sky", " ", "Cond", "ition", "'_", "in_", "x_", "[_", "'", "data", "'_", "]_", "._", "keys_", "(_", ")_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "sky", "\\u", "condition_", "=_", "[_", "x_", "[_", "'", "data", "'_", "]_", "[_", "'", "Sky", " ", "Cond", "ition", "'_", "]_", "\\u\\u\\uNL\\u\\u\\u_", "for_", "x_", "in_", "entries_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "'", "Sky", " ", "Tempe", "ratur", "e", " ", "(", "C", ")'_", "in_", "x_", "[_", "'", "data", "'_", "]_", "._", "keys_", "(_", ")_", "and_", "'", "Ambi", "ent", " ", "Tempe", "ratur", "e", " ", "(", "C", ")'_", "in_", "x_", "[_", "'", "data", "'_", "]_", "._", "keys_", "(_", ")_", "and_", "'", "Sky", " ", "Cond", "ition", "'_", "in_", "x_", "[_", "'", "data", "'_", "]_", "._", "keys_", "(_", ")_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "td", "\\u", "axes_", "._", "plot", "\\u", "date_", "(_", "time_", ",_", "temp", "\\u", "diff_", ",_", "'", "ko", "-'_", ",_", "label_", "=_", "'", "Cloud", "iness", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "markersize_", "=_", "2_", ",_", "marker", "edge", "width_", "=_", "0_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "draws", "tyle_", "=_", "\"", "default", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "td", "\\u", "axes_", "._", "fill", "\\u", "between_", "(_", "time_", ",_", "-_", "60_", ",_", "temp", "\\u", "diff_", ",_", "where_", "=_", "np_", "._", "array_", "(_", "sky", "\\u", "condition_", ")_", "==_", "'", "Clear", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "color_", "=_", "'", "green", "'_", ",_", "alpha_", "=_", "0.5_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "td", "\\u", "axes_", "._", "fill", "\\u", "between_", "(_", "time_", ",_", "-_", "60_", ",_", "temp", "\\u", "diff_", ",_", "where_", "=_", "np_", "._", "array_", "(_", "sky", "\\u", "condition_", ")_", "==_", "'", "Cloud", "y", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "color_", "=_", "'", "yell", "ow", "'_", ",_", "alpha_", "=_", "0.5_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "td", "\\u", "axes_", "._", "fill", "\\u", "between_", "(_", "time_", ",_", "-_", "60_", ",_", "temp", "\\u", "diff_", ",_", "where_", "=_", "np_", "._", "array_", "(_", "sky", "\\u", "condition_", ")_", "==_", "'", "Ver", "y", " ", "Cloud", "y", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "color_", "=_", "'", "red", "'_", ",_", "alpha_", "=_", "0.5_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "plt_", "._", "ylabel_", "(_", "\"", "Cloud", "iness", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "plt_", "._", "grid_", "(_", "which_", "=_", "'", "major", "'_", ",_", "color_", "=_", "'", "k", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "plt_", "._", "yticks_", "(_", "range_", "(_", "-_", "100_", ",_", "100_", ",_", "10_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "plt_", "._", "xlim_", "(_", "start_", ",_", "end_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "plt_", "._", "ylim_", "(_", "-_", "60_", ",_", "10_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "td", "\\u", "axes_", "._", "xaxis_", "._", "set\\u", "major", "\\u", "locator_", "(_", "hours_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "td", "\\u", "axes_", "._", "xaxis_", "._", "set\\u", "major", "\\u", "formatter_", "(_", "hour", "s", "\\u", "fmt_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "td", "\\u", "axes_", "._", "xaxis_", "._", "set\\u", "tickl", "abels_", "(_", "[_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "td", "lh", "\\u", "axes_", "=_", "plt_", "._", "axes_", "(_", "plot", "\\u", "positions_", "[_", "1_", "]_", "[_", "1_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "td", "lh", "\\u", "axes_", "._", "plot", "\\u", "date_", "(_", "time_", ",_", "temp", "\\u", "diff_", ",_", "'", "ko", "-'_", ",_", "label_", "=_", "'", "Cloud", "iness", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "markersize_", "=_", "4_", ",_", "marker", "edge", "width_", "=_", "0_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "draws", "tyle_", "=_", "\"", "default", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "td", "lh", "\\u", "axes_", "._", "fill", "\\u", "between_", "(_", "time_", ",_", "-_", "60_", ",_", "temp", "\\u", "diff_", ",_", "where_", "=_", "np_", "._", "array_", "(_", "sky", "\\u", "condition_", ")_", "==_", "'", "Clear", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "color_", "=_", "'", "green", "'_", ",_", "alpha_", "=_", "0.5_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "td", "lh", "\\u", "axes_", "._", "fill", "\\u", "between_", "(_", "time_", ",_", "-_", "60_", ",_", "temp", "\\u", "diff_", ",_", "where_", "=_", "np_", "._", "array_", "(_", "sky", "\\u", "condition_", ")_", "==_", "'", "Cloud", "y", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "color_", "=_", "'", "yell", "ow", "'_", ",_", "alpha_", "=_", "0.5_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "td", "lh", "\\u", "axes_", "._", "fill", "\\u", "between_", "(_", "time_", ",_", "-_", "60_", ",_", "temp", "\\u", "diff_", ",_", "where_", "=_", "np_", "._", "array_", "(_", "sky", "\\u", "condition_", ")_", "==_", "'", "Ver", "y", " ", "Cloud", "y", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "color_", "=_", "'", "red", "'_", ",_", "alpha_", "=_", "0.5_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "plt_", "._", "grid_", "(_", "which_", "=_", "'", "major", "'_", ",_", "color_", "=_", "'", "k", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "plt_", "._", "yticks_", "(_", "range_", "(_", "-_", "100_", ",_", "100_", ",_", "10_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "plt_", "._", "xlim_", "(_", "date_", "-_", "tde", "lta", "_", "(_", "0_", ",_", "60_", "*_", "60_", ")_", ",_", "date_", "+_", "tde", "lta", "_", "(_", "0_", ",_", "5_", "*_", "60_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "plt_", "._", "ylim_", "(_", "-_", "60_", ",_", "10_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "td", "lh", "\\u", "axes_", "._", "xaxis_", "._", "set\\u", "major", "\\u", "locator_", "(_", "mins_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "td", "lh", "\\u", "axes_", "._", "xaxis_", "._", "set\\u", "major", "\\u", "formatter_", "(_", "mins", "\\u", "fmt_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "td", "lh", "\\u", "axes_", "._", "xaxis_", "._", "set\\u", "tickl", "abels_", "(_", "[_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "td", "lh", "\\u", "axes_", "._", "yaxis_", "._", "set\\u", "tickl", "abels_", "(_", "[_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "print_", "(_", "'", "Plot", " ", "Wind", " ", "Spee", "d", " ", "vs", ".", " ", "Time", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "--------------", "--------------", "--------------", "--------------", "--------------", "---", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Plot", " ", "Wind", " ", "Spee", "d", " ", "vs", ".", " ", "Time_", "\\u\\u\\uNL\\u\\u\\u_", "w", "\\u", "axes_", "=_", "plt_", "._", "axes_", "(_", "plot", "\\u", "positions_", "[_", "2_", "]_", "[_", "0_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "wind", "\\u", "speed_", "=_", "[_", "x_", "[_", "'", "data", "'_", "]_", "[_", "'", "Wind", " ", "Spee", "d", " ", "(", "km", "/", "h", ")'_", "]_", "\\u\\u\\uNL\\u\\u\\u_", "for_", "x_", "in_", "entries_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "'", "Wind", " ", "Spee", "d", " ", "(", "km", "/", "h", ")'_", "in_", "x_", "[_", "'", "data", "'_", "]_", "._", "keys_", "(_", ")_", "and_", "\\u\\u\\uNL\\u\\u\\u_", "'", "Wind", " ", "Cond", "ition", "'_", "in_", "x_", "[_", "'", "data", "'_", "]_", "._", "keys_", "(_", ")_", "and_", "\\u\\u\\uNL\\u\\u\\u_", "'", "Gu", "st", " ", "Cond", "ition", "'_", "in_", "x_", "[_", "'", "data", "'_", "]_", "._", "keys_", "(_", ")_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "wind", "\\u", "mav", "g_", "=_", "movin", "ga", "vera", "ge_", "(_", "wind", "\\u", "speed_", ",_", "10_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "trans_", "=_", "{_", "'", "Cal", "m", "'_", ":_", "0_", ",_", "'", "Wind", "y", "'_", ":_", "1_", ",_", "'", "Gu", "sty", "'_", ":_", "1_", ",_", "'", "Ver", "y", " ", "Wind", "y", "'_", ":_", "10_", ",_", "'", "Ver", "y", " ", "Gu", "sty", "'_", ":_", "10_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "wind", "\\u", "condition_", "=_", "[_", "trans_", "[_", "x_", "[_", "'", "data", "'_", "]_", "[_", "'", "Wind", " ", "Cond", "ition", "'_", "]_", "]_", "+_", "trans_", "[_", "x_", "[_", "'", "data", "'_", "]_", "[_", "'", "Gu", "st", " ", "Cond", "ition", "'_", "]_", "]_", "\\u\\u\\uNL\\u\\u\\u_", "for_", "x_", "in_", "entries_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "'", "Wind", " ", "Spee", "d", " ", "(", "km", "/", "h", ")'_", "in_", "x_", "[_", "'", "data", "'_", "]_", "._", "keys_", "(_", ")_", "and_", "\\u\\u\\uNL\\u\\u\\u_", "'", "Wind", " ", "Cond", "ition", "'_", "in_", "x_", "[_", "'", "data", "'_", "]_", "._", "keys_", "(_", ")_", "and_", "\\u\\u\\uNL\\u\\u\\u_", "'", "Gu", "st", " ", "Cond", "ition", "'_", "in_", "x_", "[_", "'", "data", "'_", "]_", "._", "keys_", "(_", ")_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "time_", "=_", "[_", "x_", "[_", "'", "date", "'_", "]_", "for_", "x_", "in_", "entries_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "'", "Wind", " ", "Spee", "d", " ", "(", "km", "/", "h", ")'_", "in_", "x_", "[_", "'", "data", "'_", "]_", "._", "keys_", "(_", ")_", "and_", "\\u\\u\\uNL\\u\\u\\u_", "'", "Wind", " ", "Cond", "ition", "'_", "in_", "x_", "[_", "'", "data", "'_", "]_", "._", "keys_", "(_", ")_", "and_", "\\u\\u\\uNL\\u\\u\\u_", "'", "Gu", "st", " ", "Cond", "ition", "'_", "in_", "x_", "[_", "'", "data", "'_", "]_", "._", "keys_", "(_", ")_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "w", "\\u", "axes_", "._", "plot", "\\u", "date_", "(_", "time_", ",_", "wind", "\\u", "speed_", ",_", "'", "ko", "'_", ",_", "alpha_", "=_", "0.5_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "markersize_", "=_", "2_", ",_", "marker", "edge", "width_", "=_", "0_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "draws", "tyle_", "=_", "\"", "default", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "w", "\\u", "axes_", "._", "plot", "\\u", "date_", "(_", "time_", ",_", "wind", "\\u", "mav", "g_", ",_", "'", "b", "-'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "label_", "=_", "'", "Wind", " ", "Spee", "d", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "markersize_", "=_", "3_", ",_", "marker", "edge", "width_", "=_", "0_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "linewidth_", "=_", "3_", ",_", "alpha_", "=_", "0.5_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "draws", "tyle_", "=_", "\"", "default", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "w", "\\u", "axes_", "._", "plot", "\\u", "date_", "(_", "[_", "start_", ",_", "end_", "]_", ",_", "[_", "0_", ",_", "0_", "]_", ",_", "'", "k", "-'_", ",_", "ms_", "=_", "1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "w", "\\u", "axes_", "._", "fill", "\\u", "between_", "(_", "time_", ",_", "-_", "5_", ",_", "wind", "\\u", "speed_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "where_", "=_", "np_", "._", "array_", "(_", "wind", "\\u", "condition_", ")_", "==_", "0_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "color_", "=_", "'", "green", "'_", ",_", "alpha_", "=_", "0.5_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "w", "\\u", "axes_", "._", "fill", "\\u", "between_", "(_", "time_", ",_", "-_", "5_", ",_", "wind", "\\u", "speed_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "where_", "=_", "(_", "np_", "._", "array_", "(_", "wind", "\\u", "condition_", ")_", ">_", "0_", ")_", "&_", "(_", "np_", "._", "array_", "(_", "wind", "\\u", "condition_", ")_", "<_", "10_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "color_", "=_", "'", "yell", "ow", "'_", ",_", "alpha_", "=_", "0.5_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "w", "\\u", "axes_", "._", "fill", "\\u", "between_", "(_", "time_", ",_", "-_", "5_", ",_", "wind", "\\u", "speed_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "where_", "=_", "np_", "._", "array_", "(_", "wind", "\\u", "condition_", ")_", ">_", "10_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "color_", "=_", "'", "red", "'_", ",_", "alpha_", "=_", "0.5_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "max", "\\u", "wind_", "=_", "max_", "(_", "wind", "\\u", "speed_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "label", "\\u", "time_", "=_", "end_", "-_", "tde", "lta", "_", "(_", "0_", ",_", "6_", "*_", "60_", "*_", "60_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "label", "\\u", "wind_", "=_", "61_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "w", "\\u", "axes_", "._", "annotate_", "(_", "'", "Max", " ", "Gu", "st", ":", " ", "{:", ".1", "f", "}", " ", "(", "km", "/", "h", ")'_", "._", "format_", "(_", "max", "\\u", "wind_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "xy_", "=_", "(_", "label", "\\u", "time_", ",_", "max", "\\u", "wind_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "xy", "text_", "=_", "(_", "label", "\\u", "time_", ",_", "label", "\\u", "wind_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "size_", "=_", "16_", ",_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "pass_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "plt_", "._", "ylabel_", "(_", "\"", "Wind", " ", "(", "km", "/", "h", ")\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "plt_", "._", "grid_", "(_", "which_", "=_", "'", "major", "'_", ",_", "color_", "=_", "'", "k", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "plt_", "._", "yticks_", "(_", "range_", "(_", "-_", "100_", ",_", "100_", ",_", "10_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "plt_", "._", "xlim_", "(_", "start_", ",_", "end_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "wind", "\\u", "max_", "=_", "max_", "(_", "[_", "45_", ",_", "np_", "._", "ceil_", "(_", "max_", "(_", "wind", "\\u", "speed_", ")_", "/_", "5._", ")_", "*_", "5._", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "plt_", "._", "ylim_", "(_", "0_", ",_", "75_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "w", "\\u", "axes_", "._", "xaxis_", "._", "set\\u", "major", "\\u", "locator_", "(_", "hours_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "w", "\\u", "axes_", "._", "xaxis_", "._", "set\\u", "major", "\\u", "formatter_", "(_", "hour", "s", "\\u", "fmt_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "w", "\\u", "axes_", "._", "xaxis_", "._", "set\\u", "tickl", "abels_", "(_", "[_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "wl", "h", "\\u", "axes_", "=_", "plt_", "._", "axes_", "(_", "plot", "\\u", "positions_", "[_", "2_", "]_", "[_", "1_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "wl", "h", "\\u", "axes_", "._", "plot", "\\u", "date_", "(_", "time_", ",_", "wind", "\\u", "speed_", ",_", "'", "ko", "'_", ",_", "alpha_", "=_", "0.7_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "markersize_", "=_", "4_", ",_", "marker", "edge", "width_", "=_", "0_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "draws", "tyle_", "=_", "\"", "default", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "wl", "h", "\\u", "axes_", "._", "plot", "\\u", "date_", "(_", "time_", ",_", "wind", "\\u", "mav", "g_", ",_", "'", "b", "-'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "label_", "=_", "'", "Wind", " ", "Spee", "d", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "markersize_", "=_", "2_", ",_", "marker", "edge", "width_", "=_", "0_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "linewidth_", "=_", "3_", ",_", "alpha_", "=_", "0.5_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "draws", "tyle_", "=_", "\"", "default", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "wl", "h", "\\u", "axes_", "._", "plot", "\\u", "date_", "(_", "[_", "start_", ",_", "end_", "]_", ",_", "[_", "0_", ",_", "0_", "]_", ",_", "'", "k", "-'_", ",_", "ms_", "=_", "1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "wl", "h", "\\u", "axes_", "._", "fill", "\\u", "between_", "(_", "time_", ",_", "-_", "5_", ",_", "wind", "\\u", "speed_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "where_", "=_", "np_", "._", "array_", "(_", "wind", "\\u", "condition_", ")_", "==_", "0_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "color_", "=_", "'", "green", "'_", ",_", "alpha_", "=_", "0.5_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "wl", "h", "\\u", "axes_", "._", "fill", "\\u", "between_", "(_", "time_", ",_", "-_", "5_", ",_", "wind", "\\u", "speed_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "where_", "=_", "(_", "np_", "._", "array_", "(_", "wind", "\\u", "condition_", ")_", ">_", "0_", ")_", "&_", "(_", "np_", "._", "array_", "(_", "wind", "\\u", "condition_", ")_", "<_", "10_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "color_", "=_", "'", "yell", "ow", "'_", ",_", "alpha_", "=_", "0.5_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "wl", "h", "\\u", "axes_", "._", "fill", "\\u", "between_", "(_", "time_", ",_", "-_", "5_", ",_", "wind", "\\u", "speed_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "where_", "=_", "np_", "._", "array_", "(_", "wind", "\\u", "condition_", ")_", ">_", "10_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "color_", "=_", "'", "red", "'_", ",_", "alpha_", "=_", "0.5_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "current", "\\u", "wind_", "=_", "current", "\\u", "values_", "[_", "'", "data", "'_", "]_", "[_", "'", "Wind", " ", "Spee", "d", " ", "(", "km", "/", "h", ")'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "current", "\\u", "time_", "=_", "current", "\\u", "values_", "[_", "'", "date", "'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "label", "\\u", "time_", "=_", "current", "\\u", "time_", "-_", "tde", "lta", "_", "(_", "0_", ",_", "30_", "*_", "60_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "label", "\\u", "wind_", "=_", "61_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "wl", "h", "\\u", "axes_", "._", "annotate_", "(_", "'", "Curr", "ent", "ly", ":", " ", "{:", ".0", "f", "}", " ", "km", "/", "h", "'_", "._", "format_", "(_", "current", "\\u", "wind_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "xy_", "=_", "(_", "current", "\\u", "time_", ",_", "current", "\\u", "wind_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "xy", "text_", "=_", "(_", "label", "\\u", "time_", ",_", "label", "\\u", "wind_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "size_", "=_", "16_", ",_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "pass_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "plt_", "._", "grid_", "(_", "which_", "=_", "'", "major", "'_", ",_", "color_", "=_", "'", "k", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "plt_", "._", "yticks_", "(_", "range_", "(_", "-_", "100_", ",_", "100_", ",_", "10_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "plt_", "._", "xlim_", "(_", "date_", "-_", "tde", "lta", "_", "(_", "0_", ",_", "60_", "*_", "60_", ")_", ",_", "date_", "+_", "tde", "lta", "_", "(_", "0_", ",_", "5_", "*_", "60_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "wind", "\\u", "max_", "=_", "max_", "(_", "[_", "45_", ",_", "np_", "._", "ceil_", "(_", "max_", "(_", "wind", "\\u", "speed_", ")_", "/_", "5._", ")_", "*_", "5._", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "plt_", "._", "ylim_", "(_", "0_", ",_", "75_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "wl", "h", "\\u", "axes_", "._", "xaxis_", "._", "set\\u", "major", "\\u", "locator_", "(_", "mins_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "wl", "h", "\\u", "axes_", "._", "xaxis_", "._", "set\\u", "major", "\\u", "formatter_", "(_", "mins", "\\u", "fmt_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "wl", "h", "\\u", "axes_", "._", "xaxis_", "._", "set\\u", "tickl", "abels_", "(_", "[_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "wl", "h", "\\u", "axes_", "._", "yaxis_", "._", "set\\u", "tickl", "abels_", "(_", "[_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "print_", "(_", "'", "Plot", " ", "Rain", " ", "Freq", "uenc", "y", " ", "vs", ".", " ", "Time", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "--------------", "--------------", "--------------", "--------------", "--------------", "---", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Plot", " ", "Rain", " ", "Freq", "uenc", "y", " ", "vs", ".", " ", "Time_", "\\u\\u\\uNL\\u\\u\\u_", "rf", "\\u", "axes_", "=_", "plt_", "._", "axes_", "(_", "plot", "\\u", "positions_", "[_", "3_", "]_", "[_", "0_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "rf", "\\u", "value_", "=_", "[_", "x_", "[_", "'", "data", "'_", "]_", "[_", "'", "Rain", " ", "Freq", "uenc", "y", "'_", "]_", "\\u\\u\\uNL\\u\\u\\u_", "for_", "x_", "in_", "entries_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "'", "Rain", " ", "Freq", "uenc", "y", "'_", "in_", "x_", "[_", "'", "data", "'_", "]_", "._", "keys_", "(_", ")_", "and_", "\\u\\u\\uNL\\u\\u\\u_", "'", "Rain", " ", "Cond", "ition", "'_", "in_", "x_", "[_", "'", "data", "'_", "]_", "._", "keys_", "(_", ")_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "rain", "\\u", "condition_", "=_", "[_", "x_", "[_", "'", "data", "'_", "]_", "[_", "'", "Rain", " ", "Cond", "ition", "'_", "]_", "\\u\\u\\uNL\\u\\u\\u_", "for_", "x_", "in_", "entries_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "'", "Rain", " ", "Freq", "uenc", "y", "'_", "in_", "x_", "[_", "'", "data", "'_", "]_", "._", "keys_", "(_", ")_", "and_", "\\u\\u\\uNL\\u\\u\\u_", "'", "Rain", " ", "Cond", "ition", "'_", "in_", "x_", "[_", "'", "data", "'_", "]_", "._", "keys_", "(_", ")_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "time_", "=_", "[_", "x_", "[_", "'", "date", "'_", "]_", "for_", "x_", "in_", "entries_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "'", "Rain", " ", "Freq", "uenc", "y", "'_", "in_", "x_", "[_", "'", "data", "'_", "]_", "._", "keys_", "(_", ")_", "and_", "\\u\\u\\uNL\\u\\u\\u_", "'", "Rain", " ", "Cond", "ition", "'_", "in_", "x_", "[_", "'", "data", "'_", "]_", "._", "keys_", "(_", ")_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "rf", "\\u", "axes_", "._", "plot", "\\u", "date_", "(_", "time_", ",_", "rf", "\\u", "value_", ",_", "'", "ko", "-'_", ",_", "label_", "=_", "'", "Rain", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "markersize_", "=_", "2_", ",_", "marker", "edge", "width_", "=_", "0_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "draws", "tyle_", "=_", "\"", "default", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "rf", "\\u", "axes_", "._", "fill", "\\u", "between_", "(_", "time_", ",_", "0_", ",_", "rf", "\\u", "value_", ",_", "where_", "=_", "np_", "._", "array_", "(_", "rain", "\\u", "condition_", ")_", "==_", "'", "Dry", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "color_", "=_", "'", "green", "'_", ",_", "alpha_", "=_", "0.5_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "rf", "\\u", "axes_", "._", "fill", "\\u", "between_", "(_", "time_", ",_", "0_", ",_", "rf", "\\u", "value_", ",_", "where_", "=_", "np_", "._", "array_", "(_", "rain", "\\u", "condition_", ")_", "==_", "'", "Rain", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "color_", "=_", "'", "red", "'_", ",_", "alpha_", "=_", "0.5_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "plt_", "._", "ylabel_", "(_", "\"", "Rain", " ", "Sen", "sor", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "plt_", "._", "grid_", "(_", "which_", "=_", "'", "major", "'_", ",_", "color_", "=_", "'", "k", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "plt_", "._", "ylim_", "(_", "120_", ",_", "275_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "plt_", "._", "xlim_", "(_", "start_", ",_", "end_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "rf", "\\u", "axes_", "._", "xaxis_", "._", "set\\u", "major", "\\u", "locator_", "(_", "hours_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "rf", "\\u", "axes_", "._", "xaxis_", "._", "set\\u", "major", "\\u", "formatter_", "(_", "hour", "s", "\\u", "fmt_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "rf", "\\u", "axes_", "._", "xaxis_", "._", "set\\u", "tickl", "abels_", "(_", "[_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "rf", "\\u", "axes_", "._", "yaxis_", "._", "set\\u", "tickl", "abels_", "(_", "[_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "rfl", "h", "\\u", "axes_", "=_", "plt_", "._", "axes_", "(_", "plot", "\\u", "positions_", "[_", "3_", "]_", "[_", "1_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "rfl", "h", "\\u", "axes_", "._", "plot", "\\u", "date_", "(_", "time_", ",_", "rf", "\\u", "value_", ",_", "'", "ko", "-'_", ",_", "label_", "=_", "'", "Rain", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "markersize_", "=_", "4_", ",_", "marker", "edge", "width_", "=_", "0_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "draws", "tyle_", "=_", "\"", "default", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "rfl", "h", "\\u", "axes_", "._", "fill", "\\u", "between_", "(_", "time_", ",_", "0_", ",_", "rf", "\\u", "value_", ",_", "where_", "=_", "np_", "._", "array_", "(_", "rain", "\\u", "condition_", ")_", "==_", "'", "Dry", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "color_", "=_", "'", "green", "'_", ",_", "alpha_", "=_", "0.5_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "rfl", "h", "\\u", "axes_", "._", "fill", "\\u", "between_", "(_", "time_", ",_", "0_", ",_", "rf", "\\u", "value_", ",_", "where_", "=_", "np_", "._", "array_", "(_", "rain", "\\u", "condition_", ")_", "==_", "'", "Rain", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "color_", "=_", "'", "red", "'_", ",_", "alpha_", "=_", "0.5_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "plt_", "._", "grid_", "(_", "which_", "=_", "'", "major", "'_", ",_", "color_", "=_", "'", "k", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "plt_", "._", "ylim_", "(_", "120_", ",_", "275_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "plt_", "._", "xlim_", "(_", "date_", "-_", "tde", "lta", "_", "(_", "0_", ",_", "60_", "*_", "60_", ")_", ",_", "date_", "+_", "tde", "lta", "_", "(_", "0_", ",_", "5_", "*_", "60_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "rfl", "h", "\\u", "axes_", "._", "xaxis_", "._", "set\\u", "major", "\\u", "locator_", "(_", "mins_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "rfl", "h", "\\u", "axes_", "._", "xaxis_", "._", "set\\u", "major", "\\u", "formatter_", "(_", "mins", "\\u", "fmt_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "rfl", "h", "\\u", "axes_", "._", "xaxis_", "._", "set\\u", "tickl", "abels_", "(_", "[_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "rfl", "h", "\\u", "axes_", "._", "yaxis_", "._", "set\\u", "tickl", "abels_", "(_", "[_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "print_", "(_", "'", "Plot", " ", "Safe", "/", "Uns", "afe", " ", "vs", ".", " ", "Time", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "--------------", "--------------", "--------------", "--------------", "--------------", "---", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Safe", "/", "Uns", "afe", " ", "vs", ".", " ", "Time_", "\\u\\u\\uNL\\u\\u\\u_", "safe", "\\u", "axes_", "=_", "plt_", "._", "axes_", "(_", "plot", "\\u", "positions_", "[_", "4_", "]_", "[_", "0_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "safe", "\\u", "value_", "=_", "[_", "int_", "(_", "x_", "[_", "'", "data", "'_", "]_", "[_", "'", "Safe", "'_", "]_", ")_", "\\u\\u\\uNL\\u\\u\\u_", "for_", "x_", "in_", "entries_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "'", "Safe", "'_", "in_", "x_", "[_", "'", "data", "'_", "]_", "._", "keys_", "(_", ")_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "safe", "\\u", "time_", "=_", "[_", "x_", "[_", "'", "date", "'_", "]_", "for_", "x_", "in_", "entries_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "'", "Safe", "'_", "in_", "x_", "[_", "'", "data", "'_", "]_", "._", "keys_", "(_", ")_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "safe", "\\u", "axes_", "._", "plot", "\\u", "date_", "(_", "safe", "\\u", "time_", ",_", "safe", "\\u", "value_", ",_", "'", "ko", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "markersize_", "=_", "2_", ",_", "marker", "edge", "width_", "=_", "0_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "draws", "tyle_", "=_", "\"", "default", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "safe", "\\u", "axes_", "._", "fill", "\\u", "between_", "(_", "safe", "\\u", "time_", ",_", "-_", "1_", ",_", "safe", "\\u", "value_", ",_", "where_", "=_", "np_", "._", "array_", "(_", "safe", "\\u", "value_", ")_", "==_", "1_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "color_", "=_", "'", "green", "'_", ",_", "alpha_", "=_", "0.5_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "safe", "\\u", "axes_", "._", "fill", "\\u", "between_", "(_", "safe", "\\u", "time_", ",_", "-_", "1_", ",_", "safe", "\\u", "value_", ",_", "where_", "=_", "np_", "._", "array_", "(_", "safe", "\\u", "value_", ")_", "==_", "0_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "color_", "=_", "'", "red", "'_", ",_", "alpha_", "=_", "0.5_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "plt_", "._", "ylabel_", "(_", "\"", "Safe", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "plt_", "._", "xlim_", "(_", "start_", ",_", "end_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "plt_", "._", "ylim_", "(_", "-_", "0.1_", ",_", "1.1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "plt_", "._", "yticks_", "(_", "[_", "0_", ",_", "1_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "plt_", "._", "grid_", "(_", "which_", "=_", "'", "major", "'_", ",_", "color_", "=_", "'", "k", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "safe", "\\u", "axes_", "._", "xaxis_", "._", "set\\u", "major", "\\u", "locator_", "(_", "hours_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "safe", "\\u", "axes_", "._", "xaxis_", "._", "set\\u", "major", "\\u", "formatter_", "(_", "hour", "s", "\\u", "fmt_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "safe", "\\u", "axes_", "._", "xaxis_", "._", "set\\u", "tickl", "abels_", "(_", "[_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "safe", "\\u", "axes_", "._", "yaxis_", "._", "set\\u", "tickl", "abels_", "(_", "[_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "safe", "lh", "\\u", "axes_", "=_", "plt_", "._", "axes_", "(_", "plot", "\\u", "positions_", "[_", "4_", "]_", "[_", "1_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "safe", "lh", "\\u", "axes_", "._", "plot", "\\u", "date_", "(_", "safe", "\\u", "time_", ",_", "safe", "\\u", "value_", ",_", "'", "ko", "-'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "markersize_", "=_", "4_", ",_", "marker", "edge", "width_", "=_", "0_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "draws", "tyle_", "=_", "\"", "default", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "safe", "lh", "\\u", "axes_", "._", "fill", "\\u", "between_", "(_", "safe", "\\u", "time_", ",_", "-_", "1_", ",_", "safe", "\\u", "value_", ",_", "where_", "=_", "np_", "._", "array_", "(_", "safe", "\\u", "value_", ")_", "==_", "1_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "color_", "=_", "'", "green", "'_", ",_", "alpha_", "=_", "0.5_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "safe", "lh", "\\u", "axes_", "._", "fill", "\\u", "between_", "(_", "safe", "\\u", "time_", ",_", "-_", "1_", ",_", "safe", "\\u", "value_", ",_", "where_", "=_", "np_", "._", "array_", "(_", "safe", "\\u", "value_", ")_", "==_", "0_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "color_", "=_", "'", "red", "'_", ",_", "alpha_", "=_", "0.5_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "plt_", "._", "ylim_", "(_", "-_", "0.1_", ",_", "1.1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "plt_", "._", "yticks_", "(_", "[_", "0_", ",_", "1_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "plt_", "._", "grid_", "(_", "which_", "=_", "'", "major", "'_", ",_", "color_", "=_", "'", "k", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "plt_", "._", "xlim_", "(_", "date_", "-_", "tde", "lta", "_", "(_", "0_", ",_", "60_", "*_", "60_", ")_", ",_", "date_", "+_", "tde", "lta", "_", "(_", "0_", ",_", "5_", "*_", "60_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "safe", "lh", "\\u", "axes_", "._", "xaxis_", "._", "set\\u", "major", "\\u", "locator_", "(_", "mins_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "safe", "lh", "\\u", "axes_", "._", "xaxis_", "._", "set\\u", "major", "\\u", "formatter_", "(_", "mins", "\\u", "fmt_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "safe", "lh", "\\u", "axes_", "._", "xaxis_", "._", "set\\u", "tickl", "abels_", "(_", "[_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "safe", "lh", "\\u", "axes_", "._", "yaxis_", "._", "set\\u", "tickl", "abels_", "(_", "[_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "print_", "(_", "'", "Plot", " ", "PWM", " ", "Value", " ", "vs", ".", " ", "Time", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "--------------", "--------------", "--------------", "--------------", "--------------", "---", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Plot", " ", "PWM", " ", "Value", " ", "vs", ".", " ", "Time_", "\\u\\u\\uNL\\u\\u\\u_", "pwm", "\\u", "axes_", "=_", "plt_", "._", "axes_", "(_", "plot", "\\u", "positions_", "[_", "5_", "]_", "[_", "0_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "plt_", "._", "ylabel_", "(_", "\"", "Heat", "er", " ", "(%", ")\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "plt_", "._", "ylim_", "(_", "-_", "5_", ",_", "105_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "plt_", "._", "yticks_", "(_", "[_", "0_", ",_", "25_", ",_", "50_", ",_", "75_", ",_", "100_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "plt_", "._", "xlim_", "(_", "start_", ",_", "end_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "plt_", "._", "grid_", "(_", "which_", "=_", "'", "major", "'_", ",_", "color_", "=_", "'", "k", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "rst", "\\u", "axes_", "=_", "pwm", "\\u", "axes_", "._", "twin", "x_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "plt_", "._", "ylim_", "(_", "-_", "1_", ",_", "21_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "plt_", "._", "xlim_", "(_", "start_", ",_", "end_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "pwm", "\\u", "value_", "=_", "[_", "x_", "[_", "'", "data", "'_", "]_", "[_", "'", "PWM", " ", "Value", "'_", "]_", "\\u\\u\\uNL\\u\\u\\u_", "for_", "x_", "in_", "entries_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "'", "PWM", " ", "Value", "'_", "in_", "x_", "[_", "'", "data", "'_", "]_", "._", "keys_", "(_", ")_", "and_", "\\u\\u\\uNL\\u\\u\\u_", "'", "Rain", " ", "Sen", "sor", " ", "Temp", " ", "(", "C", ")'_", "in_", "x_", "[_", "'", "data", "'_", "]_", "._", "keys_", "(_", ")_", "and_", "\\u\\u\\uNL\\u\\u\\u_", "'", "Ambi", "ent", " ", "Tempe", "ratur", "e", " ", "(", "C", ")'_", "in_", "x_", "[_", "'", "data", "'_", "]_", "._", "keys_", "(_", ")_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "rst", "\\u", "delta_", "=_", "[_", "x_", "[_", "'", "data", "'_", "]_", "[_", "'", "Rain", " ", "Sen", "sor", " ", "Temp", " ", "(", "C", ")'_", "]_", "-_", "x_", "[_", "'", "data", "'_", "]_", "[_", "'", "Ambi", "ent", " ", "Tempe", "ratur", "e", " ", "(", "C", ")'_", "]_", "\\u\\u\\uNL\\u\\u\\u_", "for_", "x_", "in_", "entries_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "'", "PWM", " ", "Value", "'_", "in_", "x_", "[_", "'", "data", "'_", "]_", "._", "keys_", "(_", ")_", "and_", "\\u\\u\\uNL\\u\\u\\u_", "'", "Rain", " ", "Sen", "sor", " ", "Temp", " ", "(", "C", ")'_", "in_", "x_", "[_", "'", "data", "'_", "]_", "._", "keys_", "(_", ")_", "and_", "\\u\\u\\uNL\\u\\u\\u_", "'", "Ambi", "ent", " ", "Tempe", "ratur", "e", " ", "(", "C", ")'_", "in_", "x_", "[_", "'", "data", "'_", "]_", "._", "keys_", "(_", ")_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "time_", "=_", "[_", "x_", "[_", "'", "date", "'_", "]_", "for_", "x_", "in_", "entries_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "'", "PWM", " ", "Value", "'_", "in_", "x_", "[_", "'", "data", "'_", "]_", "._", "keys_", "(_", ")_", "and_", "\\u\\u\\uNL\\u\\u\\u_", "'", "Rain", " ", "Sen", "sor", " ", "Temp", " ", "(", "C", ")'_", "in_", "x_", "[_", "'", "data", "'_", "]_", "._", "keys_", "(_", ")_", "and_", "\\u\\u\\uNL\\u\\u\\u_", "'", "Ambi", "ent", " ", "Tempe", "ratur", "e", " ", "(", "C", ")'_", "in_", "x_", "[_", "'", "data", "'_", "]_", "._", "keys_", "(_", ")_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "rst", "\\u", "axes_", "._", "plot", "\\u", "date_", "(_", "time_", ",_", "rst", "\\u", "delta_", ",_", "'", "ro", "-'_", ",_", "alpha_", "=_", "0.5_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "label_", "=_", "'", "RST", " ", "Del", "ta", " ", "(", "C", ")'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "markersize_", "=_", "2_", ",_", "marker", "edge", "width_", "=_", "0_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "draws", "tyle_", "=_", "\"", "default", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "pwm", "\\u", "axes_", "._", "plot", "\\u", "date_", "(_", "time_", ",_", "pwm", "\\u", "value_", ",_", "'", "bo", "'_", ",_", "label_", "=_", "'", "Heat", "er", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "markersize_", "=_", "2_", ",_", "marker", "edge", "width_", "=_", "0_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "draws", "tyle_", "=_", "\"", "default", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "pwm", "\\u", "axes_", "._", "xaxis_", "._", "set\\u", "major", "\\u", "locator_", "(_", "hours_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "pwm", "\\u", "axes_", "._", "xaxis_", "._", "set\\u", "major", "\\u", "formatter_", "(_", "hour", "s", "\\u", "fmt_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "pwm", "lh", "\\u", "axes_", "=_", "plt_", "._", "axes_", "(_", "plot", "\\u", "positions_", "[_", "5_", "]_", "[_", "1_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "plt_", "._", "ylim_", "(_", "-_", "5_", ",_", "105_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "plt_", "._", "yticks_", "(_", "[_", "0_", ",_", "25_", ",_", "50_", ",_", "75_", ",_", "100_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "plt_", "._", "xlim_", "(_", "date_", "-_", "tde", "lta", "_", "(_", "0_", ",_", "60_", "*_", "60_", ")_", ",_", "date_", "+_", "tde", "lta", "_", "(_", "0_", ",_", "5_", "*_", "60_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "plt_", "._", "grid_", "(_", "which_", "=_", "'", "major", "'_", ",_", "color_", "=_", "'", "k", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "rst", "lh", "\\u", "axes_", "=_", "pwm", "lh", "\\u", "axes_", "._", "twin", "x_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "plt_", "._", "ylim_", "(_", "-_", "1_", ",_", "21_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "plt_", "._", "xlim_", "(_", "date_", "-_", "tde", "lta", "_", "(_", "0_", ",_", "60_", "*_", "60_", ")_", ",_", "date_", "+_", "tde", "lta", "_", "(_", "0_", ",_", "5_", "*_", "60_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "rst", "lh", "\\u", "axes_", "._", "plot", "\\u", "date_", "(_", "time_", ",_", "rst", "\\u", "delta_", ",_", "'", "ro", "-'_", ",_", "alpha_", "=_", "0.5_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "label_", "=_", "'", "RST", " ", "Del", "ta", " ", "(", "C", ")'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "markersize_", "=_", "4_", ",_", "marker", "edge", "width_", "=_", "0_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "draws", "tyle_", "=_", "\"", "default", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "rst", "lh", "\\u", "axes_", "._", "xaxis_", "._", "set\\u", "tickl", "abels_", "(_", "[_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "rst", "lh", "\\u", "axes_", "._", "yaxis_", "._", "set\\u", "tickl", "abels_", "(_", "[_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "pwm", "lh", "\\u", "axes_", "._", "plot", "\\u", "date_", "(_", "time_", ",_", "pwm", "\\u", "value_", ",_", "'", "bo", "'_", ",_", "label_", "=_", "'", "Heat", "er", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "markersize_", "=_", "4_", ",_", "marker", "edge", "width_", "=_", "0_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "draws", "tyle_", "=_", "\"", "default", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "pwm", "lh", "\\u", "axes_", "._", "xaxis_", "._", "set\\u", "major", "\\u", "locator_", "(_", "mins_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "pwm", "lh", "\\u", "axes_", "._", "xaxis_", "._", "set\\u", "major", "\\u", "formatter_", "(_", "mins", "\\u", "fmt_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "pwm", "lh", "\\u", "axes_", "._", "yaxis_", "._", "set\\u", "tickl", "abels_", "(_", "[_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "--------------", "--------------", "--------------", "--------------", "--------------", "---", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Plot", " ", "Bright", "ness", " ", "vs", ".", " ", "Time_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "ldr", "\\u", "axes", " ", "=", " ", "plt", ".", "axes", "(", "plot", "\\u", "position", "s", "[", "3", "][", "0", "])", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "max", "\\u", "ldr", " ", "=", " ", "285", "879", "99.", "999999", "69_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "ldr", "\\u", "value", " ", "=", " ", "[", "x", "['", "data", "']", "['", "LD", "R", " ", "Resist", "anc", "e", " ", "(", "oh", "m", ")'", "]\\\\", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "for", " ", "x", " ", "in", " ", "entri", "es", "\\\\_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "if", " ", "'", "LD", "R", " ", "Resist", "anc", "e", " ", "(", "oh", "m", ")'", " ", "in", " ", "x", "['", "data", "']", ".", "keys", "()]", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "bright", "ness", " ", "=", " ", "[", "10.", "**", "(", "2", ".", " ", "-", " ", "2", ".*", "x", "/", "max", "\\u", "ldr", ")", " ", "for", " ", "x", " ", "in", " ", "ldr", "\\u", "value", "]_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "time", " ", "=", " ", "[", "x", "['", "date", "']", " ", "for", " ", "x", " ", "in", " ", "entri", "es", "\\\\_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", " ", " ", " ", " ", "if", " ", "'", "LD", "R", " ", "Resist", "anc", "e", " ", "(", "oh", "m", ")'", " ", "in", " ", "x", "['", "data", "']", ".", "keys", "()]", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "ldr", "\\u", "axes", ".", "plot", "\\u", "date", "(", "time", ",", " ", "bright", "ness", ",", " ", "'", "ko", "',", "\\\\_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", " ", "marker", "size", "=", "2", ",", " ", "marker", "edge", "widt", "h", "=", "0", ",\\\\", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", " ", "draws", "tyl", "e", "=\"", "default", "\")", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "plt", ".", "ylabel", "(\"", "Bright", "ness", " ", "(%", ")\"", ")_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "plt", ".", "ytick", "s", "(", "range", "(-", "100", ",", "100", ",", "10", "))", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "plt", ".", "ylim", "(-", "5", ",", "105", ")_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "plt", ".", "grid", "(", "whi", "ch", "='", "major", "',", " ", "color", "='", "k", "')", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "ldr", "\\u", "axes", ".", "xaxis", ".", "set\\u", "major", "\\u", "locator", "(", "hour", "s", ")_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "ldr", "\\u", "axes", ".", "xaxis", ".", "set\\u", "major", "\\u", "formatter", "(", "hour", "s", "\\u", "fmt", ")_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "plt", ".", "xlim", "(", "start", ",", " ", "end", ")_", "\\u\\u\\uNL\\u\\u\\u_", "#", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "if", " ", "obs", ".", "is", "\\u", "night", "(", "start", "):", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", " ", " ", " ", " ", "plt", ".", "ax", "vsp", "an", "(", "start", ",", " ", "mor", "ning", "\\u", "astro", "nomi", "cal", "\\u", "twi", "light", ",", " ", "ymin", "=", "0", ",", " ", "ymax", "=", "1", ",", " ", "color", "='", "blue", "',", " ", "alpha", "=", "0.", "5", ")_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", " ", " ", " ", " ", "plt", ".", "ax", "vsp", "an", "(", "mor", "ning", "\\u", "astro", "nomi", "cal", "\\u", "twi", "light", ",", " ", "mor", "ning", "\\u", "naut", "ical", "\\u", "twi", "light", ",", " ", "ymin", "=", "0", ",", " ", "ymax", "=", "1", ",", " ", "color", "='", "blue", "',", " ", "alpha", "=", "0.", "3", ")_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", " ", " ", " ", " ", "plt", ".", "ax", "vsp", "an", "(", "mor", "ning", "\\u", "naut", "ical", "\\u", "twi", "light", ",", " ", "mor", "ning", "\\u", "civi", "l\\u", "twi", "light", ",", " ", "ymin", "=", "0", ",", " ", "ymax", "=", "1", ",", " ", "color", "='", "blue", "',", " ", "alpha", "=", "0.", "2", ")_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", " ", " ", " ", " ", "plt", ".", "ax", "vsp", "an", "(", "mor", "ning", "\\u", "civi", "l\\u", "twi", "light", ",", " ", "sun", "rise", ",", " ", "ymin", "=", "0", ",", " ", "ymax", "=", "1", ",", " ", "color", "='", "blue", "',", " ", "alpha", "=", "0.", "1", ")_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", " ", " ", " ", " ", "plt", ".", "ax", "vsp", "an", "(", "suns", "et", ",", " ", "even", "ing", "\\u", "civi", "l\\u", "twi", "light", ",", " ", "ymin", "=", "0", ",", " ", "ymax", "=", "1", ",", " ", "color", "='", "blue", "',", " ", "alpha", "=", "0.", "1", ")_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", " ", " ", " ", " ", "plt", ".", "ax", "vsp", "an", "(", "even", "ing", "\\u", "civi", "l\\u", "twi", "light", ",", " ", "even", "ing", "\\u", "naut", "ical", "\\u", "twi", "light", ",", " ", "ymin", "=", "0", ",", " ", "ymax", "=", "1", ",", " ", "color", "='", "blue", "',", " ", "alpha", "=", "0.", "2", ")_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", " ", " ", " ", " ", "plt", ".", "ax", "vsp", "an", "(", "even", "ing", "\\u", "naut", "ical", "\\u", "twi", "light", ",", " ", "even", "ing", "\\u", "astro", "nomi", "cal", "\\u", "twi", "light", ",", " ", "ymin", "=", "0", ",", " ", "ymax", "=", "1", ",", " ", "color", "='", "blue", "',", " ", "alpha", "=", "0.", "3", ")_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", " ", " ", " ", " ", "plt", ".", "ax", "vsp", "an", "(", "even", "ing", "\\u", "astro", "nomi", "cal", "\\u", "twi", "light", ",", " ", "end", ",", " ", "ymin", "=", "0", ",", " ", "ymax", "=", "1", ",", " ", "color", "='", "blue", "',", " ", "alpha", "=", "0.", "5", ")_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "else", ":_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", " ", " ", " ", " ", "plt", ".", "ax", "vsp", "an", "(", "suns", "et", ",", " ", "even", "ing", "\\u", "civi", "l\\u", "twi", "light", ",", " ", "ymin", "=", "0", ",", " ", "ymax", "=", "1", ",", " ", "color", "='", "blue", "',", " ", "alpha", "=", "0.", "1", ")_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", " ", " ", " ", " ", "plt", ".", "ax", "vsp", "an", "(", "even", "ing", "\\u", "civi", "l\\u", "twi", "light", ",", " ", "even", "ing", "\\u", "naut", "ical", "\\u", "twi", "light", ",", " ", "ymin", "=", "0", ",", " ", "ymax", "=", "1", ",", " ", "color", "='", "blue", "',", " ", "alpha", "=", "0.", "2", ")_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", " ", " ", " ", " ", "plt", ".", "ax", "vsp", "an", "(", "even", "ing", "\\u", "naut", "ical", "\\u", "twi", "light", ",", " ", "even", "ing", "\\u", "astro", "nomi", "cal", "\\u", "twi", "light", ",", " ", "ymin", "=", "0", ",", " ", "ymax", "=", "1", ",", " ", "color", "='", "blue", "',", " ", "alpha", "=", "0.", "3", ")_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", " ", " ", " ", " ", "plt", ".", "ax", "vsp", "an", "(", "even", "ing", "\\u", "astro", "nomi", "cal", "\\u", "twi", "light", ",", " ", "mor", "ning", "\\u", "astro", "nomi", "cal", "\\u", "twi", "light", ",", " ", "ymin", "=", "0", ",", " ", "ymax", "=", "1", ",", " ", "color", "='", "blue", "',", " ", "alpha", "=", "0.", "5", ")_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", " ", " ", " ", " ", "plt", ".", "ax", "vsp", "an", "(", "mor", "ning", "\\u", "astro", "nomi", "cal", "\\u", "twi", "light", ",", " ", "mor", "ning", "\\u", "naut", "ical", "\\u", "twi", "light", ",", " ", "ymin", "=", "0", ",", " ", "ymax", "=", "1", ",", " ", "color", "='", "blue", "',", " ", "alpha", "=", "0.", "3", ")_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", " ", " ", " ", " ", "plt", ".", "ax", "vsp", "an", "(", "mor", "ning", "\\u", "naut", "ical", "\\u", "twi", "light", ",", " ", "mor", "ning", "\\u", "civi", "l\\u", "twi", "light", ",", " ", "ymin", "=", "0", ",", " ", "ymax", "=", "1", ",", " ", "color", "='", "blue", "',", " ", "alpha", "=", "0.", "2", ")_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", " ", " ", " ", " ", "plt", ".", "ax", "vsp", "an", "(", "mor", "ning", "\\u", "civi", "l\\u", "twi", "light", ",", " ", "sun", "rise", ",", " ", "ymin", "=", "0", ",", " ", "ymax", "=", "1", ",", " ", "color", "='", "blue", "',", " ", "alpha", "=", "0.", "1", ")_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "--------------", "--------------", "--------------", "--------------", "--------------", "---", "_", "\\u\\u\\uNL\\u\\u\\u_", "plot", "\\u", "filename_", "=_", "'{}", ".", "png", "'_", "._", "format_", "(_", "date", "\\u", "string_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "plot", "\\u", "file_", "=_", "os_", "._", "path_", "._", "expanduser_", "(_", "'/", "var", "/", "pano", "pte", "s", "/", "wea", "ther", "\\u", "plots", "/{}'_", "._", "format_", "(_", "plot", "\\u", "filename_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "print_", "(_", "'", "Save", " ", "Fig", "ure", ":", " ", "{}'_", "._", "format_", "(_", "plot", "\\u", "file_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "plt_", "._", "savefig_", "(_", "plot", "\\u", "file_", ",_", "dpi_", "=_", "dpi_", ",_", "bbox", "\\u", "inches_", "=_", "'", "tig", "ht", "'_", ",_", "pad", "\\u", "inches_", "=_", "0.10", "_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Link_", "\\u\\u\\uNL\\u\\u\\u_", "toda", "y", "\\u", "name_", "=_", "'/", "var", "/", "pano", "pte", "s", "/", "wea", "ther", "\\u", "plots", "/", "toda", "y", ".", "png", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "os_", "._", "path_", "._", "exists_", "(_", "toda", "y", "\\u", "name_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "os_", "._", "remove_", "(_", "toda", "y", "\\u", "name_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "os_", "._", "symlink_", "(_", "plot", "\\u", "file_", ",_", "toda", "y", "\\u", "name_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_" ]
[ 4, 4, 4, 4, 4, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,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, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 ]
Module is imported more than once
statsmodels/statsmodels/statsmodels/sandbox/gam.py
[ { "content": "\"\"\"\nGeneralized additive models\n\n\n\nRequirements for smoothers\n--------------------------\n\nsmooth(y, weights=xxx) : ? no return ? alias for fit\npredict(x=None) : smoothed values, fittedvalues or for new exog\ndf_fit() : degress of freedom of fit ?\n\n\nNotes\n-----\n- using PolySmoother works for AdditiveModel, and GAM with Poisson and Binomial\n- testfailure with Gamma, no other families tested\n- there is still an indeterminacy in the split up of the constant across\n components (smoothers) and alpha, sum, i.e. constant, looks good.\n - role of offset, that I haven't tried to figure out yet\n\nRefactoring\n-----------\ncurrently result is attached to model instead of other way around\nsplit up Result in class for AdditiveModel and for GAM,\nsubclass GLMResults, needs verification that result statistics are appropriate\nhow much inheritance, double inheritance?\nrenamings and cleanup\ninterface to other smoothers, scipy splines\n\nbasic unittests as support for refactoring exist, but we should have a test\ncase for gamma and the others. Advantage of PolySmoother is that we can\nbenchmark against the parametric GLM results.\n\n\"\"\"\n\n# JP:\n# changes: use PolySmoother instead of crashing bspline\n# TODO: check/catalogue required interface of a smoother\n# TODO: replace default smoother by corresponding function to initialize\n# other smoothers\n# TODO: fix iteration, don't define class with iterator methods, use looping;\n# add maximum iteration and other optional stop criteria\n# fixed some of the dimension problems in PolySmoother,\n# now graph for example looks good\n# NOTE: example script is now in examples folder\n#update: I did some of the above, see module docstring\n\nfrom statsmodels.compat.python import next, range\nimport numpy as np\n\nfrom statsmodels.genmod import families\nfrom statsmodels.sandbox.nonparametric.smoothers import PolySmoother\nfrom statsmodels.genmod.generalized_linear_model import GLM\nfrom statsmodels.tools.sm_exceptions import IterationLimitWarning, iteration_limit_doc\n\nimport warnings\n\nDEBUG = False\n\n\n\n\n\n", "metadata": "root", "header": "['module', '___EOS___']", "index": 0 }, { "content": " def predict(self, exog):\n '''predict response, sum of smoothed components\n TODO: What's this in the case of GLM, corresponds to X*beta ?\n '''\n #note: sum is here over axis=0,\n #TODO: transpose in smoothed and sum over axis=1\n\n #BUG: there is some inconsistent orientation somewhere\n #temporary hack, won't work for 1d\n #print dir(self)\n #print 'self.nobs, self.k_vars', self.nobs, self.k_vars\n exog_smoothed = self.smoothed(exog)\n #print 'exog_smoothed.shape', exog_smoothed.shape\n if exog_smoothed.shape[0] == self.k_vars:\n import warnings\n warnings.warn(\"old orientation, colvars, will go away\",\n FutureWarning)\n return np.sum(self.smoothed(exog), axis=0) + self.alpha\n if exog_smoothed.shape[1] == self.k_vars:\n return np.sum(exog_smoothed, axis=1) + self.alpha\n else:\n raise ValueError('shape mismatch in predict')", "metadata": "root.Results.predict", "header": "['class', 'Results', '(', 'object', ')', ':', '___EOS___']", "index": 136 }, { "content": " def fit(self, Y, rtol=1.0e-06, maxiter=30):\n\n self.rtol = rtol\n self.maxiter = maxiter\n\n self.Y = np.asarray(Y, np.float64)\n\n self.history = []\n\n #iter(self)\n self._iter__()\n\n #TODO code duplication with next?\n alpha = self.Y.mean()\n mu0 = self.family.starting_mu(Y)\n #Z = self.family.link(alpha) + self.family.link.deriv(alpha) * (Y - alpha)\n Z = self.family.link(alpha) + self.family.link.deriv(alpha) * (Y - mu0)\n m = AdditiveModel(self.exog, smoothers=self.smoothers, family=self.family)\n self.results = m.fit(Z)\n self.results.mu = self.family.link.inverse(self.results.predict(self.exog))\n self.results.Y = Y\n\n while self.cont():\n self.results = self.next()\n self.scale = self.results.scale = self.estimate_scale()\n\n if self.iter >= self.maxiter:\n import warnings\n warnings.warn(iteration_limit_doc, IterationLimitWarning)\n\n return self.results", "metadata": "root.Model.fit", "header": "['class', 'Model', '(', 'GLM', ',', 'AdditiveModel', ')', ':', '___NEWLINE___', '#class Model(AdditiveModel):', '___NL___', '#TODO: what does GLM do? Is it actually used ?', '___NL___', \"#only used in __init__, dropping it doesn't change results\", '___NL___', \"#but where gets family attached now? - weird, it's Gaussian in this case now\", '___NL___', '#also where is the link defined?', '___NL___', '#AdditiveModel overwrites family and sets it to Gaussian - corrected', '___NL___', '___NL___', '#I think both GLM and AdditiveModel subclassing is only used in __init__', '___NL___', '___NL___', '#niter = 2', '___NL___', '___NL___', '# def __init__(self, exog, smoothers=None, family=family.Gaussian()):', '___NL___', '# GLM.__init__(self, exog, family=family)', '___NL___', '# AdditiveModel.__init__(self, exog, smoothers=smoothers)', '___NL___', '# self.family = family', '___NL___', '___EOS___']", "index": 403 } ]
[ { "span": "import warnings", "start_line": 150, "start_column": 12, "end_line": 150, "end_column": 27 }, { "span": "import warnings", "start_line": 430, "start_column": 12, "end_line": 430, "end_column": 27 } ]
[ { "span": "import warnings", "start_line": 56, "start_column": 0, "end_line": 56, "end_column": 15 } ]
1
true
[ "[CLS]_", "Module_", "is_", "imported_", "more_", "than_", "once_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\"\"\"", "\\", "10", ";", "General", "ize", "d", " ", "additi", "ve", " ", "model", "s", "\\", "10", ";", "\\", "10", ";", "\\", "10", ";", "\\", "10", ";", "Requirements", " ", "for", " ", "smooth", "ers", "\\", "10", ";", "--------------", "------------", "\\", "10", ";", "\\", "10", ";", "smooth", "(", "y", ",", " ", "weight", "s", "=", "xxx", ")", " ", ":", " ", "?", " ", "no", " ", "return", " ", "?", " ", "alias", " ", "for", " ", "fit", "\\", "10", ";", "predi", "ct", "(", "x", "=", "Non", "e", ")", " ", ":", " ", "smoothed", " ", "values", ",", " ", "fitted", "values", " ", "or", " ", "for", " ", "new", " ", "exo", "g", "\\", "10", ";", "df", "\\u", "fit", "()", " ", ":", " ", "degr", "ess", " ", "of", " ", "freed", "om", " ", "of", " ", "fit", " ", "?", "\\", "10", ";", "\\", "10", ";", "\\", "10", ";", "Not", "es", "\\", "10", ";", "-----", "\\", "10", ";", "-", " ", "usi", "ng", " ", "Poly", "Smooth", "er", " ", "works", " ", "for", " ", "Add", "iti", "ve", "Model", ",", " ", "and", " ", "GAM", " ", "with", " ", "Pois", "son", " ", "and", " ", "Bin", "omial", "\\", "10", ";", "-", " ", "testf", "ail", "ure", " ", "with", " ", "Gamma", ",", " ", "no", " ", "other", " ", "families", " ", "tested", "\\", "10", ";", "-", " ", "there", " ", "is", " ", "still", " ", "an", " ", "inde", "termina", "cy", " ", "in", " ", "the", " ", "split", " ", "up", " ", "of", " ", "the", " ", "constant", " ", "acro", "ss", "\\", "10", ";", " ", " ", "component", "s", " ", "(", "smooth", "ers", ")", " ", "and", " ", "alpha", ",", " ", "sum", ",", " ", "i", ".", "e", ".", " ", "constant", ",", " ", "look", "s", " ", "good", ".", "\\", "10", ";", " ", " ", "-", " ", "role", " ", "of", " ", "offset", ",", " ", "tha", "t", " ", "I", " ", "have", "n", "'", "t", " ", "trie", "d", " ", "to", " ", "figure", " ", "out", " ", "ye", "t", "\\", "10", ";", "\\", "10", ";", "Ref", "actor", "ing", "\\", "10", ";", "-----------", "\\", "10", ";", "currentl", "y", " ", "result", " ", "is", " ", "attache", "d", " ", "to", " ", "model", " ", "inst", "ead", " ", "of", " ", "other", " ", "way", " ", "aro", "und", "\\", "10", ";", "split", " ", "up", " ", "Result", " ", "in", " ", "class", " ", "for", " ", "Add", "iti", "ve", "Model", " ", "and", " ", "for", " ", "GAM", ",", "\\", "10", ";", "subclass", " ", "GL", "MR", "esult", "s", ",", " ", "need", "s", " ", "verification", " ", "tha", "t", " ", "result", " ", "statistic", "s", " ", "are", " ", "appropr", "iate", "\\", "10", ";", "how", " ", "muc", "h", " ", "inherita", "nce", ",", " ", "double", " ", "inherita", "nce", "?", "\\", "10", ";", "rena", "ming", "s", " ", "and", " ", "clean", "up", "\\", "10", ";", "interface", " ", "to", " ", "other", " ", "smooth", "ers", ",", " ", "sci", "py", " ", "spline", "s", "\\", "10", ";", "\\", "10", ";", "basic", " ", "unittest", "s", " ", "as", " ", "support", " ", "for", " ", "refactor", "ing", " ", "exist", ",", " ", "but", " ", "we", " ", "shou", "ld", " ", "have", " ", "a", " ", "test", "\\", "10", ";", "case", " ", "for", " ", "gamma", " ", "and", " ", "the", " ", "other", "s", ".", " ", "Adv", "anta", "ge", " ", "of", " ", "Poly", "Smooth", "er", " ", "is", " ", "tha", "t", " ", "we", " ", "can", "\\", "10", ";", "bench", "mark", " ", "against", " ", "the", " ", "parametr", "ic", " ", "GL", "M", " ", "results", ".", "\\", "10", ";", "\\", "10", ";\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "JP", ":_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "change", "s", ":", " ", "use", " ", "Poly", "Smooth", "er", " ", "inst", "ead", " ", "of", " ", "crash", "ing", " ", "bsp", "line_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "TOD", "O", ":", " ", "check", "/", "catalogue", " ", "require", "d", " ", "interface", " ", "of", " ", "a", " ", "smooth", "er_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "TOD", "O", ":", " ", "replace", " ", "default", " ", "smooth", "er", " ", "by", " ", "correspond", "ing", " ", "function", " ", "to", " ", "initialize_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", " ", " ", "other", " ", "smooth", "ers_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "TOD", "O", ":", " ", "fix", " ", "iterati", "on", ",", " ", "don", "'", "t", " ", "defin", "e", " ", "class", " ", "with", " ", "iter", "ator", " ", "method", "s", ",", " ", "use", " ", "looping", ";_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", " ", " ", "add", " ", "maxim", "um", " ", "iterati", "on", " ", "and", " ", "other", " ", "option", "al", " ", "stop", " ", "criteria_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "fixed", " ", "some", " ", "of", " ", "the", " ", "dimension", " ", "problem", "s", " ", "in", " ", "Poly", "Smooth", "er", ",_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", " ", " ", "now", " ", "graph", " ", "for", " ", "example", " ", "look", "s", " ", "good_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "NOTE", ":", " ", "example", " ", "script", " ", "is", " ", "now", " ", "in", " ", "example", "s", " ", "folder_", "\\u\\u\\uNL\\u\\u\\u_", "#", "update", ":", " ", "I", " ", "did", " ", "some", " ", "of", " ", "the", " ", "above", ",", " ", "see", " ", "module", " ", "docstring_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "from_", "stats", "models_", "._", "compat_", "._", "python_", "import_", "next_", ",_", "range_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "numpy_", "as_", "np_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "from_", "stats", "models_", "._", "gen", "mod_", "import_", "families_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "stats", "models_", "._", "sandbox_", "._", "nonp", "aram", "etric", "_", "._", "smooth", "ers_", "import_", "Poly", "Smooth", "er_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "stats", "models_", "._", "gen", "mod_", "._", "generaliz", "ed", "\\u", "linear", "\\u", "model_", "import_", "GL", "M_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "stats", "models_", "._", "tools_", "._", "sm", "\\u", "exceptions_", "import_", "Iterat", "ion", "Limit", "Warning_", ",_", "iterati", "on", "\\u", "limit", "\\u", "doc_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "import_", "warnings_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "DEBUG_", "=_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "[SEP]_", "class_", "Results_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "predict_", "(_", "self_", ",_", "exo", "g_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "'''", "predi", "ct", " ", "response", ",", " ", "sum", " ", "of", " ", "smoothed", " ", "component", "s", "\\", "10", ";", " ", " ", " ", " ", "TOD", "O", ":", " ", "What", "'", "s", " ", "this", " ", "in", " ", "the", " ", "case", " ", "of", " ", "GL", "M", ",", " ", "correspond", "s", " ", "to", " ", "X", "*", "beta", " ", "?", "\\", "10", ";", " ", " ", " ", " ", "'''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", "note", ":", " ", "sum", " ", "is", " ", "here", " ", "over", " ", "axis", "=", "0", ",_", "\\u\\u\\uNL\\u\\u\\u_", "#", "TOD", "O", ":", " ", "transpose", " ", "in", " ", "smoothed", " ", "and", " ", "sum", " ", "over", " ", "axis", "=", "1_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", "BUG", ":", " ", "there", " ", "is", " ", "some", " ", "inconsistent", " ", "orientation", " ", "some", "where_", "\\u\\u\\uNL\\u\\u\\u_", "#", "temporar", "y", " ", "hack", ",", " ", "won", "'", "t", " ", "work", " ", "for", " ", "1d_", "\\u\\u\\uNL\\u\\u\\u_", "#", "print", " ", "dir", "(", "self", ")_", "\\u\\u\\uNL\\u\\u\\u_", "#", "print", " ", "'", "self", ".", "nob", "s", ",", " ", "self", ".", "k", "\\u", "vars", "',", " ", "self", ".", "nob", "s", ",", " ", "self", ".", "k", "\\u", "vars_", "\\u\\u\\uNL\\u\\u\\u_", "exo", "g", "\\u", "smoothed", "_", "=_", "self_", "._", "smoothed", "_", "(_", "exo", "g_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", "print", " ", "'", "exo", "g", "\\u", "smoothed", ".", "shape", "',", " ", "exo", "g", "\\u", "smoothed", ".", "shape_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "exo", "g", "\\u", "smoothed", "_", "._", "shape_", "[_", "0_", "]_", "==_", "self_", "._", "k", "\\u", "vars_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "import_", "warnings_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "warnings_", "._", "warn_", "(_", "\"", "old", " ", "orientation", ",", " ", "col", "vars", ",", " ", "will", " ", "go", " ", "awa", "y", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "Fu", "ture", "Warning_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "np_", "._", "sum_", "(_", "self_", "._", "smoothed", "_", "(_", "exo", "g_", ")_", ",_", "axis_", "=_", "0_", ")_", "+_", "self_", "._", "alpha_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "exo", "g", "\\u", "smoothed", "_", "._", "shape_", "[_", "1_", "]_", "==_", "self_", "._", "k", "\\u", "vars_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "np_", "._", "sum_", "(_", "exo", "g", "\\u", "smoothed", "_", ",_", "axis_", "=_", "1_", ")_", "+_", "self_", "._", "alpha_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "raise_", "Value", "Error_", "(_", "'", "shape", " ", "mism", "atch", " ", "in", " ", "predi", "ct", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Model_", "(_", "GL", "M_", ",_", "Add", "iti", "ve", "Model_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", "class", " ", "Model", "(", "Add", "iti", "ve", "Model", "):", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", "TOD", "O", ":", " ", "what", " ", "doe", "s", " ", "GL", "M", " ", "do", "?", " ", "Is", " ", "it", " ", "actual", "ly", " ", "used", " ", "?", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", "only", " ", "used", " ", "in", " ", "\\u\\u", "init", "\\u\\u", ",", " ", "drop", "ping", " ", "it", " ", "doe", "sn", "'", "t", " ", "change", " ", "results_", "\\u\\u\\uNL\\u\\u\\u_", "#", "but", " ", "where", " ", "gets", " ", "famil", "y", " ", "attache", "d", " ", "now", "?", " ", "-", " ", "weird", ",", " ", "it", "'", "s", " ", "Gaussian", " ", "in", " ", "this", " ", "case", " ", "now_", "\\u\\u\\uNL\\u\\u\\u_", "#", "als", "o", " ", "where", " ", "is", " ", "the", " ", "link", " ", "defin", "ed", "?", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", "Add", "iti", "ve", "Model", " ", "overwrit", "es", " ", "famil", "y", " ", "and", " ", "sets", " ", "it", " ", "to", " ", "Gaussian", " ", "-", " ", "corrected", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", "I", " ", "think", " ", "bot", "h", " ", "GL", "M", " ", "and", " ", "Add", "iti", "ve", "Model", " ", "subclassing", " ", "is", " ", "only", " ", "used", " ", "in", " ", "\\u\\u", "init\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", "nite", "r", " ", "=", " ", "2_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", " ", " ", " ", "def", " ", "\\u\\u", "init", "\\u\\u", "(", "self", ",", " ", "exo", "g", ",", " ", "smooth", "ers", "=", "Non", "e", ",", " ", "famil", "y", "=", "famil", "y", ".", "Gaussian", "())", ":_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", " ", " ", " ", "GL", "M", ".\\u", "\\u", "init", "\\u\\u", "(", "self", ",", " ", "exo", "g", ",", " ", "famil", "y", "=", "famil", "y", ")_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", " ", " ", " ", "Add", "iti", "ve", "Model", ".\\u", "\\u", "init", "\\u\\u", "(", "self", ",", " ", "exo", "g", ",", " ", "smooth", "ers", "=", "smooth", "ers", ")_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", " ", " ", " ", "self", ".", "famil", "y", " ", "=", " ", "family_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "fit_", "(_", "self_", ",_", "Y_", ",_", "rtol_", "=_", "1.0e-", "06_", ",_", "maxiter_", "=_", "30_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "rtol_", "=_", "rtol_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "maxiter_", "=_", "maxiter_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "Y_", "=_", "np_", "._", "asarray_", "(_", "Y_", ",_", "np_", "._", "float64_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "history_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", "iter", "(", "self", ")_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "\\u", "iter\\u\\u_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", "TOD", "O", " ", "code", " ", "duplicat", "ion", " ", "with", " ", "next", "?", "_", "\\u\\u\\uNL\\u\\u\\u_", "alpha_", "=_", "self_", "._", "Y_", "._", "mean_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "mu", "0_", "=_", "self_", "._", "family_", "._", "startin", "g", "\\u", "mu_", "(_", "Y_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", "Z", " ", "=", " ", "self", ".", "famil", "y", ".", "link", "(", "alpha", ")", " ", "+", " ", "self", ".", "famil", "y", ".", "link", ".", "deriv", "(", "alpha", ")", " ", "*", " ", "(", "Y", " ", "-", " ", "alpha", ")_", "\\u\\u\\uNL\\u\\u\\u_", "Z_", "=_", "self_", "._", "family_", "._", "link_", "(_", "alpha_", ")_", "+_", "self_", "._", "family_", "._", "link_", "._", "deriv_", "(_", "alpha_", ")_", "*_", "(_", "Y_", "-_", "mu", "0_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "m_", "=_", "Add", "iti", "ve", "Model_", "(_", "self_", "._", "exo", "g_", ",_", "smooth", "ers_", "=_", "self_", "._", "smooth", "ers_", ",_", "family_", "=_", "self_", "._", "family_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "results_", "=_", "m_", "._", "fit_", "(_", "Z_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "results_", "._", "mu_", "=_", "self_", "._", "family_", "._", "link_", "._", "inverse_", "(_", "self_", "._", "results_", "._", "predict_", "(_", "self_", "._", "exo", "g_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "results_", "._", "Y_", "=_", "Y_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "while_", "self_", "._", "cont_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "results_", "=_", "self_", "._", "next_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "scale_", "=_", "self_", "._", "results_", "._", "scale_", "=_", "self_", "._", "estimate", "\\u", "scale_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "self_", "._", "iter_", ">=_", "self_", "._", "maxiter_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "import_", "warnings_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "warnings_", "._", "warn_", "(_", "iterati", "on", "\\u", "limit", "\\u", "doc_", ",_",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2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 ]
Except block handles 'BaseException'
tarmstrong/nbdiff/nbdiff/server/command/MergeURLCommand.py
[ { "content": " def process(self, request, filename, db_session):\n errMsg = \"\"\n parser = NotebookParser()\n # Max Size of a notebook accepted is 20M.\n max_size = 20*1024*1024\n\n try:\n localURL = request.form['localURL']\n baseURL = request.form['baseURL']\n remoteURL = request.form['remoteURL']\n except BadRequestKeyError:\n errMsg = \"\"\"Invalid notebook Merge Request.\n <br/>Please return to the home page and\n submit the request again.\"\"\"\n return render_template('Error.html', err=errMsg)\n\n try:\n localFile = urllib2.urlopen(localURL)\n if int(localFile.info()['Content-Length']) > max_size:\n errMsg = errMsg + \"\"\"The Local notebook\n exceeds 20MB. Only notebooks below\n 20MB are accepted.<br/>\"\"\"\n except:\n errMsg = errMsg + \"\"\"We are unable to access\n the Local notebook file from the\n given URL.<br/>\"\"\"\n\n try:\n baseFile = urllib2.urlopen(baseURL)\n if int(baseFile.info()['Content-Length']) > max_size:\n errMsg = errMsg + \"\"\"The Base notebook\n exceeds 20MB. Only notebooks below\n 20MB are accepted.<br/>\"\"\"\n except:\n errMsg = errMsg + \"\"\"We are unable to access\n the Base notebook file from the given\n URL.<br/>\"\"\"\n\n try:\n remoteFile = urllib2.urlopen(remoteURL)\n if int(remoteFile.info()['Content-Length']) > max_size:\n errMsg = errMsg + \"\"\"The Remote notebook\n exceeds 20MB. Only notebooks below\n 20MB are accepted.<br/>\"\"\"\n except:\n errMsg = errMsg + \"\"\"We are unable to access\n the Remote notebook file from\n the given URL.<br/>\"\"\"\n\n if len(errMsg) == 0:\n try:\n nb_local = parser.parse(localFile)\n except nbformat.NotJSONError:\n errMsg = errMsg + \"\"\"The Local notebook\n contains invalid JSON data. <br/>\"\"\"\n try:\n nb_base = parser.parse(baseFile)\n except nbformat.NotJSONError:\n errMsg = errMsg + \"\"\"The Base notebook\n contains invalid JSON data. <br/>\"\"\"\n try:\n nb_remote = parser.parse(remoteFile)\n except nbformat.NotJSONError:\n errMsg = errMsg + \"\"\"The Remote notebook\n contains invalid JSON data. <br/>\"\"\"\n\n localFile.close()\n baseFile.close()\n remoteFile.close()\n\n if len(errMsg) == 0:\n mergedNotebook = notebook_merge(nb_local, nb_base, nb_remote)\n\n # bitarray used to convert notebook to binary for BLOB\n ba = bitarray.bitarray()\n ba.fromstring(json.dumps(mergedNotebook, indent=2))\n\n # object to be saved to database\n obj = nbdiffModel(ba.to01())\n\n # add to database and commit it.\n try:\n db_session.add(obj)\n db_session.commit()\n except OperationalError:\n db_session.rollback()\n print \"\"\"The database is not initialized.\n Please restart server with argument init_db\"\"\"\n errMsg = \"\"\"There was an error with the database. <br/>\n Please contact administrator to resolve this issue.\"\"\"\n return render_template('Error.html', err=errMsg)\n except:\n db_session.rollback()\n errMsg = \"\"\"There was an unexpected error with the database.\n <br/>Please try again later. <br/>\n If this problem persists please contact administrator.\"\"\"\n return render_template('Error.html', err=errMsg)\n\n # return the id of the object.\n nb_id = obj.id\n\n # redirect is used because we want users\n # to have a easier url to return to.\n return redirect(\"/Comparison/\"+str(nb_id), code=302)\n else:\n return render_template('Error.html', err=errMsg)", "metadata": "root.MergeURLCommand.process", "header": "['class', 'MergeURLCommand', '(', 'BaseCommand', ')', ':', '___EOS___']", "index": 15 } ]
[ { "span": "except:", "start_line": 37, "start_column": 8, "end_line": 37, "end_column": 15 }, { "span": "except:", "start_line": 48, "start_column": 8, "end_line": 48, "end_column": 15 }, { "span": "except:", "start_line": 59, "start_column": 8, "end_line": 59, "end_column": 15 }, { "span": "except:", "start_line": 106, "start_column": 12, "end_line": 106, "end_column": 19 } ]
[]
1
true
[ "[CLS]_", "Except", "_", "block_", "handles_", "'", "Base", "Except", "ion", "'_", "[SEP]_", "class_", "Merge", "URL", "Command_", "(_", "Base", "Command_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "def_", "process_", "(_", "self_", ",_", "request_", ",_", "filename_", ",_", "db", "\\u", "session_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "err", "Msg_", "=_", "\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "parser_", "=_", "Notebook", "Parser_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Max", " ", "Size", " ", "of", " ", "a", " ", "notebook", " ", "accept", "ed", " ", "is", " ", "20", "M", "._", "\\u\\u\\uNL\\u\\u\\u_", "max", "\\u", "size_", "=_", "20_", "*_", "1024_", "*_", "1024_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "local", "URL_", "=_", "request_", "._", "form_", "[_", "'", "local", "URL", "'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "base", "URL_", "=_", "request_", "._", "form_", "[_", "'", "base", "URL", "'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "remote", "URL_", "=_", "request_", "._", "form_", "[_", "'", "remote", "URL", "'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "Ba", "d", "Request", "Key", "Error_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "err", "Msg_", "=_", "\"\"\"", "Inva", "lid", " ", "notebook", " ", "Merge", " ", "Request", ".", "\\", "10", ";", " ", " ", " ", " ", "<", "br", "/>", "Ple", "ase", " ", "return", " ", "to", " ", "the", " ", "home", " ", "page", " ", "and", "\\", "10", ";", " ", " ", " ", " ", "submit", " ", "the", " ", "request", " ", "again", ".\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "render", "\\u", "template_", "(_", "'", "Error", ".", "html", "'_", ",_", "err_", "=_", "err", "Msg_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "local", "File_", "=_", "urllib2_", "._", "urlopen_", "(_", "local", "URL_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "int_", "(_", "local", "File_", "._", "info_", "(_", ")_", "[_", "'", "Conten", "t", "-", "Length", "'_", "]_", ")_", ">_", "max", "\\u", "size_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "err", "Msg_", "=_", "err", "Msg_", "+_", "\"\"\"", "The", " ", "Local", " ", "notebook", "\\", "10", ";", " ", " ", "exceed", "s", " ", "20", "MB", ".", " ", "On", "ly", " ", "notebook", "s", " ", "belo", "w", "\\", "10", ";", " ", " ", "20", "MB", " ", "are", " ", "accept", "ed", ".", "<", "br", "/>", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "err", "Msg_", "=_", "err", "Msg_", "+_", "\"\"\"", "We", " ", "are", " ", "una", "ble", " ", "to", " ", "access", "\\", "10", ";", " ", " ", " ", " ", "the", " ", "Local", " ", "notebook", " ", "file", " ", "from", " ", "the", "\\", "10", ";", " ", " ", " ", " ", "give", "n", " ", "URL", ".", "<", "br", "/>", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "base", "File_", "=_", "urllib2_", "._", "urlopen_", "(_", "base", "URL_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "int_", "(_", "base", "File_", "._", "info_", "(_", ")_", "[_", "'", "Conten", "t", "-", "Length", "'_", "]_", ")_", ">_", "max", "\\u", "size_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "err", "Msg_", "=_", "err", "Msg_", "+_", "\"\"\"", "The", " ", "Base", " ", "notebook", "\\", "10", ";", " ", " ", "exceed", "s", " ", "20", "MB", ".", " ", "On", "ly", " ", "notebook", "s", " ", "belo", "w", "\\", "10", ";", " ", " ", "20", "MB", " ", "are", " ", "accept", "ed", ".", "<", "br", "/>", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "err", "Msg_", "=_", "err", "Msg_", "+_", "\"\"\"", "We", " ", "are", " ", "una", "ble", " ", "to", " ", "access", "\\", "10", ";", " ", " ", " ", " ", "the", " ", "Base", " ", "notebook", " ", "file", " ", "from", " ", "the", " ", "give", "n", "\\", "10", ";", " ", " ", " ", " ", "URL", ".", "<", "br", "/>", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "remote", "File_", "=_", "urllib2_", "._", "urlopen_", "(_", "remote", "URL_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "int_", "(_", "remote", "File_", "._", "info_", "(_", ")_", "[_", "'", "Conten", "t", "-", "Length", "'_", "]_", ")_", ">_", "max", "\\u", "size_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "err", "Msg_", "=_", "err", "Msg_", "+_", "\"\"\"", "The", " ", "Remo", "te", " ", "notebook", "\\", "10", ";", " ", " ", "exceed", "s", " ", "20", "MB", ".", " ", "On", "ly", " ", "notebook", "s", " ", "belo", "w", "\\", "10", ";", " ", " ", "20", "MB", " ", "are", " ", "accept", "ed", ".", "<", "br", "/>", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "err", "Msg_", "=_", "err", "Msg_", "+_", "\"\"\"", "We", " ", "are", " ", "una", "ble", " ", "to", " ", "access", "\\", "10", ";", " ", " ", " ", " ", "the", " ", "Remo", "te", " ", "notebook", " ", "file", " ", "from", "\\", "10", ";", " ", " ", " ", " ", "the", " ", "give", "n", " ", "URL", ".", "<", "br", "/>", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "len_", "(_", "err", "Msg_", ")_", "==_", "0_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "nb", "\\u", "local_", "=_", "parser_", "._", "parse_", "(_", "local", "File_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "nb", "format_", "._", "Not", "JSO", "NE", "rror_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "err", "Msg_", "=_", "err", "Msg_", "+_", "\"\"\"", "The", " ", "Local", " ", "notebook", "\\", "10", ";", " ", " ", "contain", "s", " ", "invalid", " ", "JSO", "N", " ", "data", ".", " ", "<", "br", "/>", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "nb", "\\u", "base_", "=_", "parser_", "._", "parse_", "(_", "base", "File_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "nb", "format_", "._", "Not", "JSO", "NE", "rror_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "err", "Msg_", "=_", "err", "Msg_", "+_", "\"\"\"", "The", " ", "Base", " ", "notebook", "\\", "10", ";", " ", " ", "contain", "s", " ", "invalid", " ", "JSO", "N", " ", "data", ".", " ", "<", "br", "/>", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "nb", "\\u", "remote_", "=_", "parser_", "._", "parse_", "(_", "remote", "File_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "nb", "format_", "._", "Not", "JSO", "NE", "rror_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "err", "Msg_", "=_", "err", "Msg_", "+_", "\"\"\"", "The", " ", "Remo", "te", " ", "notebook", "\\", "10", ";", " ", " ", "contain", "s", " ", "invalid", " ", "JSO", "N", " ", "data", ".", " ", "<", "br", "/>", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "local", "File_", "._", "close_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "base", "File_", "._", "close_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "remote", "File_", "._", "close_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "len_", "(_", "err", "Msg_", ")_", "==_", "0_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "merge", "d", "Notebook", "_", "=_", "notebook", "\\u", "merge_", "(_", "nb", "\\u", "local_", ",_", "nb", "\\u", "base_", ",_", "nb", "\\u", "remote_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "bita", "rray", " ", "used", " ", "to", " ", "convert", " ", "notebook", " ", "to", " ", "binar", "y", " ", "for", " ", "BLOB", "_", "\\u\\u\\uNL\\u\\u\\u_", "ba_", "=_", "bita", "rray_", "._", "bita", "rray_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "ba_", "._", "fromstring_", "(_", "json_", "._", "dumps_", "(_", "merge", "d", "Notebook", "_", ",_", "indent_", "=_", "2_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "object", " ", "to", " ", "be", " ", "saved", " ", "to", " ", "database_", "\\u\\u\\uNL\\u\\u\\u_", "obj_", "=_", "nb", "diff", "Model_", "(_", "ba_", "._", "to", "01_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "add", " ", "to", " ", "databa", "se", " ", "and", " ", "commit", " ", "it", "._", "\\u\\u\\uNL\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "db", "\\u", "session_", "._", "add_", "(_", "obj_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "db", "\\u", "session_", "._", "commit_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "Opera", "tion", "al", "Error_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "db", "\\u", "session_", "._", "rollback_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "print_", "\"\"\"", "The", " ", "databa", "se", " ", "is", " ", "not", " ", "initialize", "d", ".", "\\", "10", ";", " ", " ", "Ple", "ase", " ", "restart", " ", "server", " ", "with", " ", "argu", "ment", " ", "init", "\\u", "db", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "err", "Msg_", "=_", "\"\"\"", "There", " ", "was", " ", "an", " ", "error", " ", "with", " ", "the", " ", "databa", "se", ".", " ", "<", "br", "/>", "\\", "10", ";", " ", "Ple", "ase", " ", "contact", " ", "administrat", "or", " ", "to", " ", "resolve", " ", "this", " ", "issue", ".\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "render", "\\u", "template_", "(_", "'", "Error", ".", "html", "'_", ",_", "err_", "=_", "err", "Msg_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "db", "\\u", "session_", "._", "rollback_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "err", "Msg_", "=_", "\"\"\"", "There", " ", "was", " ", "an", " ", "unexpected", " ", "error", " ", "with", " ", "the", " ", "databa", "se", ".", "\\", "10", ";", " ", " ", "<", "br", "/>", "Ple", "ase", " ", "try", " ", "again", " ", "late", "r", ".", " ", "<", "br", "/>", "\\", "10", ";", " ", " ", "If", " ", "this", " ", "problem", " ", "persist", "s", " ", "plea", "se", " ", "contact", " ", "administrat", "or", ".\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "render", "\\u", "template_", "(_", "'", "Error", ".", "html", "'_", ",_", "err_", "=_", "err", "Msg_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "return", " ", "the", " ", "id", " ", "of", " ", "the", " ", "object", "._", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "nb", "\\u", "id_", "=_", "obj_", "._", "id_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "redirec", "t", " ", "is", " ", "used", " ", "bec", "aus", "e", " ", "we", " ", "want", " ", "users_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "to", " ", "have", " ", "a", " ", "easi", "er", " ", "url", " ", "to", " ", "return", " ", "to", "._", "\\u\\u\\uNL\\u\\u\\u_", "return_", "redirect_", "(_", "\"/", "Compari", "son", "/\"_", "+_", "str_", "(_", "nb", "\\u", "id_", ")_", ",_", "code_", "=_", "302_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "render", "\\u", "template_", "(_", "'", "Error", ".", "html", "'_", ",_", "err_", "=_", "err", "Msg_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_" ]
[ 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,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 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 ]
First argument to super() is not enclosing class
ciex/souma/synapse/__init__.py
[ { "content": " def __new__(cls, *args, **kwargs):\n \"\"\"Singleton pattern\"\"\"\n if not cls._instance:\n cls._instance = super(ElectricalSynapse, cls).__new__(cls, *args, **kwargs)\n return cls._instance", "metadata": "root.Synapse.__new__", "header": "['class', 'Synapse', '(', ')', ':', '___EOS___']", "index": 29 } ]
[ { "span": "super(ElectricalSynapse, cls).", "start_line": 32, "start_column": 28, "end_line": 32, "end_column": 57 } ]
[]
1
true
[ "[CLS]_", "First_", "argument_", "to_", "super_", "(_", ")_", "is_", "not_", "encl", "osin", "g_", "class_", "[SEP]_", "class_", "Synapse", "_", "(_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "\\u\\u", "new\\u\\u_", "(_", "cls_", ",_", "*_", "args_", ",_", "**_", "kwargs_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "Singleton", " ", "pattern", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "not_", "cls_", "._", "\\u", "instance_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "cls_", "._", "\\u", "instance_", "=_", "super_", "(_", "Electric", "al", "Synapse", "_", ",_", "cls_", ")_", "._", "\\u\\u", "new\\u\\u_", "(_", "cls_", ",_", "*_", "args_", ",_", "**_", "kwargs_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "cls_", "._", "\\u", "instance_", "\\u\\u\\uNEWLINE\\u\\u\\u_" ]
[ 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 ]
Unused import
linkfloyd/linkfloyd/linkfloyd/channels/migrations/0004_auto__del_field_channel_parent_channel__add_field_channel_parent.py
[ { "content": "# encoding: utf-8\nimport datetime\nfrom south.db import db\nfrom south.v2 import SchemaMigration\nfrom django.db import models\n\n", "metadata": "root", "header": "['module', '___EOS___']", "index": 0 }, { "content": "class Migration(SchemaMigration):\n\n\n\n\n\n models = {\n 'auth.group': {\n 'Meta': {'object_name': 'Group'},\n 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),\n 'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '80'}),\n 'permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': \"orm['auth.Permission']\", 'symmetrical': 'False', 'blank': 'True'})\n },\n 'auth.permission': {\n 'Meta': {'ordering': \"('content_type__app_label', 'content_type__model', 'codename')\", 'unique_together': \"(('content_type', 'codename'),)\", 'object_name': 'Permission'},\n 'codename': ('django.db.models.fields.CharField', [], {'max_length': '100'}),\n 'content_type': ('django.db.models.fields.related.ForeignKey', [], {'to': \"orm['contenttypes.ContentType']\"}),\n 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),\n 'name': ('django.db.models.fields.CharField', [], {'max_length': '50'})\n },\n 'auth.user': {\n 'Meta': {'object_name': 'User'},\n 'date_joined': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime(2012, 7, 24, 6, 41, 19, 219645)'}),\n 'email': ('django.db.models.fields.EmailField', [], {'max_length': '75', 'blank': 'True'}),\n 'first_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}),\n 'groups': ('django.db.models.fields.related.ManyToManyField', [], {'to': \"orm['auth.Group']\", 'symmetrical': 'False', 'blank': 'True'}),\n 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),\n 'is_active': ('django.db.models.fields.BooleanField', [], {'default': 'True'}),\n 'is_staff': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),\n 'is_superuser': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),\n 'last_login': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime(2012, 7, 24, 6, 41, 19, 219531)'}),\n 'last_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}),\n 'password': ('django.db.models.fields.CharField', [], {'max_length': '128'}),\n 'user_permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': \"orm['auth.Permission']\", 'symmetrical': 'False', 'blank': 'True'}),\n 'username': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '30'})\n },\n 'channels.channel': {\n 'Meta': {'object_name': 'Channel'},\n 'description': ('django.db.models.fields.CharField', [], {'max_length': \"'255'\"}),\n 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),\n 'is_official': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),\n 'language': ('django.db.models.fields.related.ForeignKey', [], {'to': \"orm['channels.Language']\"}),\n 'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '255'}),\n 'notes': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}),\n 'parent': ('django.db.models.fields.related.ForeignKey', [], {'to': \"orm['channels.Channel']\", 'null': 'True', 'blank': 'True'}),\n 'slug': ('django.db.models.fields.SlugField', [], {'unique': 'True', 'max_length': '255', 'db_index': 'True'})\n },\n 'channels.language': {\n 'Meta': {'object_name': 'Language'},\n 'code': ('django.db.models.fields.CharField', [], {'max_length': '5', 'null': 'True'}),\n 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),\n 'name': ('django.db.models.fields.CharField', [], {'max_length': '16'})\n },\n 'channels.subscription': {\n 'Meta': {'unique_together': \"(('user', 'channel'),)\", 'object_name': 'Subscription'},\n 'channel': ('django.db.models.fields.related.ForeignKey', [], {'to': \"orm['channels.Channel']\"}),\n 'email_frequency': ('django.db.models.fields.CharField', [], {'default': \"'daily'\", 'max_length': '12'}),\n 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),\n 'status': ('django.db.models.fields.CharField', [], {'default': \"'member'\", 'max_length': '12'}),\n 'user': ('django.db.models.fields.related.ForeignKey', [], {'related_name': \"'channel_subscriptions'\", 'to': \"orm['auth.User']\"})\n },\n 'contenttypes.contenttype': {\n 'Meta': {'ordering': \"('name',)\", 'unique_together': \"(('app_label', 'model'),)\", 'object_name': 'ContentType', 'db_table': \"'django_content_type'\"},\n 'app_label': ('django.db.models.fields.CharField', [], {'max_length': '100'}),\n 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),\n 'model': ('django.db.models.fields.CharField', [], {'max_length': '100'}),\n 'name': ('django.db.models.fields.CharField', [], {'max_length': '100'})\n }\n }\n\n complete_apps = ['channels']", "metadata": "root.Migration", "header": "['module', '___EOS___']", "index": 6 }, { "content": " def forwards(self, orm):\n \n # Deleting field 'Channel.parent_channel'\n db.delete_column('channels_channel', 'parent_channel_id')\n\n # Adding field 'Channel.parent'\n db.add_column('channels_channel', 'parent', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['channels.Channel'], null=True, blank=True), keep_default=False)", "metadata": "root.Migration.forwards", "header": "['class', 'Migration', '(', 'SchemaMigration', ')', ':', '___EOS___']", "index": 8 }, { "content": " def backwards(self, orm):\n \n # Adding field 'Channel.parent_channel'\n db.add_column('channels_channel', 'parent_channel', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['channels.Channel'], null=True, blank=True), keep_default=False)\n\n # Deleting field 'Channel.parent'\n db.delete_column('channels_channel', 'parent_id')", "metadata": "root.Migration.backwards", "header": "['class', 'Migration', '(', 'SchemaMigration', ')', ':', '___EOS___']", "index": 17 } ]
[ { "span": "import datetime", "start_line": 1, "start_column": 0, "end_line": 1, "end_column": 15 }, { "span": "from django.db import models", "start_line": 4, "start_column": 0, "end_line": 4, "end_column": 28 } ]
[]
1
false
[ "[CLS]_", "Un", "used_", "import_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "#", " ", "encoding", ":", " ", "utf", "-", "8_", "\\u\\u\\uNL\\u\\u\\u_", "import_", "datetime_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "south_", "._", "db_", "import_", "db_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "south_", "._", "v2_", "import_", "Schema", "Migration_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "django_", "._", "db_", "import_", "models_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "class_", "Migration_", "(_", "Schema", "Migration_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "models_", "=_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "'", "auth", ".", "group", "'_", ":_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "'", "Meta", "'_", ":_", "{_", "'", "object\\u", "name", "'_", ":_", "'", "Group", "'_", "}_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "id", "'_", ":_", "(_", "'", "django", ".", "db", ".", "model", "s", ".", "fields", ".", "Auto", "Field", "'_", ",_", "[_", "]_", ",_", "{_", "'", "primary", "\\u", "key", "'_", ":_", "'", "Tru", "e", "'_", "}_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "name", "'_", ":_", "(_", "'", "django", ".", "db", ".", "model", "s", ".", "fields", ".", "Char", "Field", "'_", ",_", "[_", "]_", ",_", "{_", "'", "unique", "'_", ":_", "'", "Tru", "e", "'_", ",_", "'", "max", "\\u", "length", "'_", ":_", "'", "80", "'_", "}_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "permissi", "ons", "'_", ":_", "(_", "'", "django", ".", "db", ".", "model", "s", ".", "fields", ".", "relate", "d", ".", "Many", "To", "Many", "Field", "'_", ",_", "[_", "]_", ",_", "{_", "'", "to", "'_", ":_", "\"", "orm", "['", "auth", ".", "Permi", "ssion", "']\"_", ",_", "'", "symmetric", "al", "'_", ":_", "'", "Fal", "se", "'_", ",_", "'", "blank", "'_", ":_", "'", "Tru", "e", "'_", "}_", ")_", "\\u\\u\\uNL\\u\\u\\u_", "}_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "auth", ".", "permissi", "on", "'_", ":_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "'", "Meta", "'_", ":_", "{_", "'", "orderi", "ng", "'_", ":_", "\"(", "'", "content", "\\u", "type\\u\\u", "app", "\\u", "label", "',", " ", "'", "content", "\\u", "type\\u\\u", "model", "',", " ", "'", "code", "name", "')\"_", ",_", "'", "unique", "\\u", "tog", "ether", "'_", ":_", "\"(", "('", "content", "\\u", "type", "',", " ", "'", "code", "name", "'),)\"_", ",_", "'", "object\\u", "name", "'_", ":_", "'", "Permi", "ssion", "'_", "}_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "code", "name", "'_", ":_", "(_", "'", "django", ".", "db", ".", "model", "s", ".", "fields", ".", "Char", "Field", "'_", ",_", "[_", "]_", ",_", "{_", "'", "max", "\\u", "length", "'_", ":_", "'", "100", "'_", "}_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "content", "\\u", "type", "'_", ":_", "(_", "'", "django", ".", "db", ".", "model", "s", ".", "fields", ".", "relate", "d", ".", "Fore", "ign", "Key", "'_", ",_", "[_", "]_", ",_", "{_", "'", "to", "'_", ":_", "\"", "orm", "['", "contenttype", "s", ".", "Conten", "t", "Type", "']\"_", "}_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "id", "'_", ":_", "(_", "'", "django", ".", "db", ".", "model", "s", ".", "fields", ".", "Auto", "Field", "'_", ",_", "[_", "]_", ",_", "{_", "'", "primary", "\\u", "key", "'_", ":_", "'", "Tru", "e", "'_", "}_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "name", "'_", ":_", "(_", "'", "django", ".", "db", ".", "model", "s", ".", "fields", ".", "Char", "Field", "'_", ",_", "[_", "]_", ",_", "{_", "'", "max", "\\u", "length", "'_", ":_", "'", "50", "'_", "}_", ")_", "\\u\\u\\uNL\\u\\u\\u_", "}_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "auth", ".", "user", "'_", ":_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "'", "Meta", "'_", ":_", "{_", "'", "object\\u", "name", "'_", ":_", "'", "User", "'_", "}_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "date", "\\u", "joine", "d", "'_", ":_", "(_", "'", "django", ".", "db", ".", "model", "s", ".", "fields", ".", "Date", "Time", "Field", "'_", ",_", "[_", "]_", ",_", "{_", "'", "default", "'_", ":_", "'", "datetime", ".", "datetime", "(", "2012", ",", " ", "7", ",", " ", "24", ",", " ", "6", ",", " ", "4", "1", ",", " ", "1", "9", ",", " ", "219", "645", ")'_", "}_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "email", "'_", ":_", "(_", "'", "django", ".", "db", ".", "model", "s", ".", "fields", ".", "Ema", "il", "Field", "'_", ",_", "[_", "]_", ",_", "{_", "'", "max", "\\u", "length", "'_", ":_", "'", "7", "5", "'_", ",_", "'", "blank", "'_", ":_", "'", "Tru", "e", "'_", "}_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "first", "\\u", "name", "'_", ":_", "(_", "'", "django", ".", "db", ".", "model", "s", ".", "fields", ".", "Char", "Field", "'_", ",_", "[_", "]_", ",_", "{_", "'", "max", "\\u", "length", "'_", ":_", "'", "30", "'_", ",_", "'", "blank", "'_", ":_", "'", "Tru", "e", "'_", "}_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "group", "s", "'_", ":_", "(_", "'", "django", ".", "db", ".", "model", "s", ".", "fields", ".", "relate", "d", ".", "Many", "To", "Many", "Field", "'_", ",_", "[_", "]_", ",_", "{_", "'", "to", "'_", ":_", "\"", "orm", "['", "auth", ".", "Group", "']\"_", ",_", "'", "symmetric", "al", "'_", ":_", "'", "Fal", "se", "'_", ",_", "'", "blank", "'_", ":_", "'", "Tru", "e", "'_", "}_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "id", "'_", ":_", "(_", "'", "django", ".", "db", ".", "model", "s", ".", "fields", ".", "Auto", "Field", "'_", ",_", "[_", "]_", ",_", "{_", "'", "primary", "\\u", "key", "'_", ":_", "'", "Tru", "e", "'_", "}_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "is", "\\u", "active", "'_", ":_", "(_", "'", "django", ".", "db", ".", "model", "s", ".", "fields", ".", "Boo", "lean", "Field", "'_", ",_", "[_", "]_", ",_", "{_", "'", "default", "'_", ":_", "'", "Tru", "e", "'_", "}_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "is", "\\u", "sta", "ff", "'_", ":_", "(_", "'", "django", ".", "db", ".", "model", "s", ".", "fields", ".", "Boo", "lean", "Field", "'_", ",_", "[_", "]_", ",_", "{_", "'", "default", "'_", ":_", "'", "Fal", "se", "'_", "}_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "is", "\\u", "super", "user", "'_", ":_", "(_", "'", "django", ".", "db", ".", "model", "s", ".", "fields", ".", "Boo", "lean", "Field", "'_", ",_", "[_", "]_", ",_", "{_", "'", "default", "'_", ":_", "'", "Fal", "se", "'_", "}_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "last", "\\u", "login", "'_", ":_", "(_", "'", "django", ".", "db", ".", "model", "s", ".", "fields", ".", "Date", "Time", "Field", "'_", ",_", "[_", "]_", ",_", "{_", "'", "default", "'_", ":_", "'", "datetime", ".", "datetime", "(", "2012", ",", " ", "7", ",", " ", "24", ",", " ", "6", ",", " ", "4", "1", ",", " ", "1", "9", ",", " ", "219", "531", ")'_", "}_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "last", "\\u", "name", "'_", ":_", "(_", "'", "django", ".", "db", ".", "model", "s", ".", "fields", ".", "Char", "Field", "'_", ",_", "[_", "]_", ",_", "{_", "'", "max", "\\u", "length", "'_", ":_", "'", "30", "'_", ",_", "'", "blank", "'_", ":_", "'", "Tru", "e", "'_", "}_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "password", "'_", ":_", "(_", "'", "django", ".", "db", ".", "model", "s", ".", "fields", ".", "Char", "Field", "'_", ",_", "[_", "]_", ",_", "{_", "'", "max", "\\u", "length", "'_", ":_", "'", "128", "'_", "}_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "user", "\\u", "permissi", "ons", "'_", ":_", "(_", "'", "django", ".", "db", ".", "model", "s", ".", "fields", ".", "relate", "d", ".", "Many", "To", "Many", "Field", "'_", ",_", "[_", "]_", ",_", "{_", "'", "to", "'_", ":_", "\"", "orm", "['", "auth", ".", "Permi", "ssion", "']\"_", ",_", "'", "symmetric", "al", "'_", ":_", "'", "Fal", "se", "'_", ",_", "'", "blank", "'_", ":_", "'", "Tru", "e", "'_", "}_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "user", "name", "'_", ":_", "(_", "'", "django", ".", "db", ".", "model", "s", ".", "fields", ".", "Char", "Field", "'_", ",_", "[_", "]_", ",_", "{_", "'", "unique", "'_", ":_", "'", "Tru", "e", "'_", ",_", "'", "max", "\\u", "length", "'_", ":_", "'", "30", "'_", "}_", ")_", "\\u\\u\\uNL\\u\\u\\u_", "}_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "channel", "s", ".", "channel", "'_", ":_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "'", "Meta", "'_", ":_", "{_", "'", "object\\u", "name", "'_", ":_", "'", "Chan", "nel", "'_", "}_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "description", "'_", ":_", "(_", "'", "django", ".", "db", ".", "model", "s", ".", "fields", ".", "Char", "Field", "'_", ",_", "[_", "]_", ",_", "{_", "'", "max", "\\u", "length", "'_", ":_", "\"'", "255", "'\"_", "}_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "id", "'_", ":_", "(_", "'", "django", ".", "db", ".", "model", "s", ".", "fields", ".", "Auto", "Field", "'_", ",_", "[_", "]_", ",_", "{_", "'", "primary", "\\u", "key", "'_", ":_", "'", "Tru", "e", "'_", "}_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "is", "\\u", "official", "'_", ":_", "(_", "'", "django", ".", "db", ".", "model", "s", ".", "fields", ".", "Boo", "lean", "Field", "'_", ",_", "[_", "]_", ",_", "{_", "'", "default", "'_", ":_", "'", "Fal", "se", "'_", "}_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "language", "'_", ":_", "(_", "'", "django", ".", "db", ".", "model", "s", ".", "fields", ".", "relate", "d", ".", "Fore", "ign", "Key", "'_", ",_", "[_", "]_", ",_", "{_", "'", "to", "'_", ":_", "\"", "orm", "['", "channel", "s", ".", "Lang", "ua", "ge", "']\"_", "}_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "name", "'_", ":_", "(_", "'", "django", ".", "db", ".", "model", "s", ".", "fields", ".", "Char", "Field", "'_", ",_", "[_", "]_", ",_", "{_", "'", "unique", "'_", ":_", "'", "Tru", "e", "'_", ",_", "'", "max", "\\u", "length", "'_", ":_", "'", "255", "'_", "}_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "note", "s", "'_", ":_", "(_", "'", "django", ".", "db", ".", "model", "s", ".", "fields", ".", "Text", "Field", "'_", ",_", "[_", "]_", ",_", "{_", "'", "null", "'_", ":_", "'", "Tru", "e", "'_", ",_", "'", "blank", "'_", ":_", "'", "Tru", "e", "'_", "}_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "parent", "'_", ":_", "(_", "'", "django", ".", "db", ".", "model", "s", ".", "fields", ".", "relate", "d", ".", "Fore", "ign", "Key", "'_", ",_", "[_", "]_", ",_", "{_", "'", "to", "'_", ":_", "\"", "orm", "['", "channel", "s", ".", "Chan", "nel", "']\"_", ",_", "'", "null", "'_", ":_", "'", "Tru", "e", "'_", ",_", "'", "blank", "'_", ":_", "'", "Tru", "e", "'_", "}_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "slug", "'_", ":_", "(_", "'", "django", ".", "db", ".", "model", "s", ".", "fields", ".", "Sl", "ug", "Field", "'_", ",_", "[_", "]_", ",_", "{_", "'", "unique", "'_", ":_", "'", "Tru", "e", "'_", ",_", "'", "max", "\\u", "length", "'_", ":_", "'", "255", "'_", ",_", "'", "db", "\\u", "index", "'_", ":_", "'", "Tru", "e", "'_", "}_", ")_", "\\u\\u\\uNL\\u\\u\\u_", "}_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "channel", "s", ".", "language", "'_", ":_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "'", "Meta", "'_", ":_", "{_", "'", "object\\u", "name", "'_", ":_", "'", "Lang", "ua", "ge", "'_", "}_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "code", "'_", ":_", "(_", "'", "django", ".", "db", ".", "model", "s", ".", "fields", ".", "Char", "Field", "'_", ",_", "[_", "]_", ",_", "{_", "'", "max", "\\u", "length", "'_", ":_", "'", "5", "'_", ",_", "'", "null", "'_", ":_", "'", "Tru", "e", "'_", "}_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "id", "'_", ":_", "(_", "'", "django", ".", "db", ".", "model", "s", ".", "fields", ".", "Auto", "Field", "'_", ",_", "[_", "]_", ",_", "{_", "'", "primary", "\\u", "key", "'_", ":_", "'", "Tru", "e", "'_", "}_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "name", "'_", ":_", "(_", "'", "django", ".", "db", ".", "model", "s", ".", "fields", ".", "Char", "Field", "'_", ",_", "[_", "]_", ",_", "{_", "'", "max", "\\u", "length", "'_", ":_", "'", "16", "'_", "}_", ")_", "\\u\\u\\uNL\\u\\u\\u_", "}_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "channel", "s", ".", "subscript", "ion", "'_", ":_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "'", "Meta", "'_", ":_", "{_", "'", "unique", "\\u", "tog", "ether", "'_", ":_", "\"(", "('", "user", "',", " ", "'", "channel", "'),)\"_", ",_", "'", "object\\u", "name", "'_", ":_", "'", "Subscription", "'_", "}_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "channel", "'_", ":_", "(_", "'", "django", ".", "db", ".", "model", "s", ".", "fields", ".", "relate", "d", ".", "Fore", "ign", "Key", "'_", ",_", "[_", "]_", ",_", "{_", "'", "to", "'_", ":_", "\"", "orm", "['", "channel", "s", ".", "Chan", "nel", "']\"_", "}_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "email", "\\u", "freque", "nc", "y", "'_", ":_", "(_", "'", "django", ".", "db", ".", "model", "s", ".", "fields", ".", "Char", "Field", "'_", ",_", "[_", "]_", ",_", "{_", "'", "default", "'_", ":_", "\"'", "daily", "'\"_", ",_", "'", "max", "\\u", "length", "'_", ":_", "'", "1", "2", "'_", "}_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "id", "'_", ":_", "(_", "'", "django", ".", "db", ".", "model", "s", ".", "fields", ".", "Auto", "Field", "'_", ",_", "[_", "]_", ",_", "{_", "'", "primary", "\\u", "key", "'_", ":_", "'", "Tru", "e", "'_", "}_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "status", "'_", ":_", "(_", "'", "django", ".", "db", ".", "model", "s", ".", "fields", ".", "Char", "Field", "'_", ",_", "[_", "]_", ",_", "{_", "'", "default", "'_", ":_", "\"'", "member", "'\"_", ",_", "'", "max", "\\u", "length", "'_", ":_", "'", "1", "2", "'_", "}_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "user", "'_", ":_", "(_", "'", "django", ".", "db", ".", "model", "s", ".", "fields", ".", "relate", "d", ".", "Fore", "ign", "Key", "'_", ",_", "[_", "]_", ",_", "{_", "'", "relate", "d\\u", "name", "'_", ":_", "\"'", "channel", "\\u", "subscript", "ion", "s", "'\"_", ",_", "'", "to", "'_", ":_", "\"", "orm", "['", "auth", ".", "User", "']\"_", "}_", ")_", "\\u\\u\\uNL\\u\\u\\u_", "}_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "contenttype", "s", ".", "contenttype", "'_", ":_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "'", "Meta", "'_", ":_", "{_", "'", "orderi", "ng", "'_", ":_", "\"(", "'", "name", "',)\"_", ",_", "'", "unique", "\\u", "tog", "ether", "'_", ":_", "\"(", "('", "app", "\\u", "label", "',", " ", "'", "model", "'),)\"_", ",_", "'", "object\\u", "name", "'_", ":_", "'", "Conten", "t", "Type", "'_", ",_", "'", "db", "\\u", "table", "'_", ":_", "\"'", "django", "\\u", "content", "\\u", "type", "'\"_", "}_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "app", "\\u", "label", "'_", ":_", "(_", "'", "django", ".", "db", ".", "model", "s", ".", "fields", ".", "Char", "Field", "'_", ",_", "[_", "]_", ",_", "{_", "'", "max", "\\u", "length", "'_", ":_", "'", "100", "'_", "}_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "id", "'_", ":_", "(_", "'", "django", ".", "db", ".", "model", "s", ".", "fields", ".", "Auto", "Field", "'_", ",_", "[_", "]_", ",_", "{_", "'", "primary", "\\u", "key", "'_", ":_", "'", "Tru", "e", "'_", "}_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "model", "'_", ":_", "(_", "'", "django", ".", "db", ".", "model", "s", ".", "fields", ".", "Char", "Field", "'_", ",_", "[_", "]_", ",_", "{_", "'", "max", "\\u", "length", "'_", ":_", "'", "100", "'_", "}_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "name", "'_", ":_", "(_", "'", "django", ".", "db", ".", "model", "s", ".", "fields", ".", "Char", "Field", "'_", ",_", "[_", "]_", ",_", "{_", "'", "max", "\\u", "length", "'_", ":_", "'", "100", "'_", "}_", ")_", "\\u\\u\\uNL\\u\\u\\u_", "}_", "\\u\\u\\uNL\\u\\u\\u_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "complete", "\\u", "apps_", "=_", "[_", "'", "channel", "s", "'_", "]_", "[SEP]_", "class_", "Migration_", "(_", "Schema", "Migration_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "def_", "forwards_", "(_", "self_", ",_", "orm_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Del", "eti", "ng", " ", "field", " ", "'", "Chan", "nel", ".", "parent", "\\u", "channel", "'_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "db_", "._", "delete", "\\u", "column_", "(_", "'", "channel", "s", "\\u", "channel", "'_", ",_", "'", "parent", "\\u", "channel", "\\u", "id", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Add", "ing", " ", "field", " ", "'", "Chan", "nel", ".", "parent", "'_", "\\u\\u\\uNL\\u\\u\\u_", "db_", "._", "add", "\\u", "column_", "(_", "'", "channel", "s", "\\u", "channel", "'_", ",_", "'", "parent", "'_", ",_", "self_", "._", "gf_", "(_", "'", "django", ".", "db", ".", "model", "s", ".", "fields", ".", "relate", "d", ".", "Fore", "ign", "Key", "'_", ")_", "(_", "to_", "=_", "orm_", "[_", "'", "channel", "s", ".", "Chan", "nel", "'_", "]_", ",_", "null_", "=_", "True_", ",_", "blank_", "=_", "True_", ")_", ",_", "keep", "\\u", "default_", "=_", "False_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Migration_", "(_", "Schema", "Migration_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "backwards_", "(_", "self_", ",_", "orm_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Add", "ing", " ", "field", " ", "'", "Chan", "nel", ".", "parent", "\\u", "channel", "'_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "db_", "._", "add", "\\u", "column_", "(_", "'", "channel", "s", "\\u", "channel", "'_", ",_", "'", "parent", "\\u", "channel", "'_", ",_", "self_", "._", "gf_", "(_", "'", "django", ".", "db", ".", "model", "s", ".", "fields", ".", "relate", "d", ".", "Fore", "ign", "Key", "'_", ")_", "(_", "to_", "=_", "orm_", "[_", "'", "channel", "s", ".", "Chan", "nel", "'_", "]_", ",_", "null_", "=_", "True_", ",_", "blank_", "=_", "True_", ")_", ",_", "keep", "\\u", "default_", "=_", "False_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Del", "eti", "ng", " ", "field", " ", "'", "Chan", "nel", ".", "parent", "'_", "\\u\\u\\uNL\\u\\u\\u_", "db_", "._", "delete", "\\u", "column_", "(_", "'", "channel", "s", "\\u", "channel", "'_", ",_", "'", "parent", "\\u", "id", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_" ]
[ 4, 4, 4, 4, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 1, 1, 1, 1, 1, 2, 2, 2, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,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 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 ]
Unused import
hycis/Pynet/pynet/datasets/i2r.py
[ { "content": "\n\nimport matplotlib.pyplot as plt\n\nimport logging\nlogger = logging.getLogger(__name__)\nimport os\nimport numpy as np\nimport theano\n\nfrom pynet.datasets.dataset import SingleBlock, DataBlocks\nfrom pynet.utils.utils import make_one_hot\n\n\n\n\n\n\n\n", "metadata": "root", "header": "['module', '___EOS___']", "index": 0 }, { "content": "class I2R_Posterior_Blocks_ClnDNN_CleanFeat(DataBlocks):\n\n", "metadata": "root.I2R_Posterior_Blocks_ClnDNN_CleanFeat", "header": "['module', '___EOS___']", "index": 16 }, { "content": " def __init__(self, feature_size, target_size, **kwargs):\n\n \"\"\"\n DESCRIPTION:\n This is class for processing blocks of data.\n PARAM:\n data_paths(list): contains the paths to the numpy data files. It's a\n list of tuples whereby the first element of the tuple\n is the X path, and the second is the y path.\n \"\"\"\n dir = '/home/stuwzhz/datasets/spectral-features/npy2'\n self.data_paths = [('%s/ClnDNN_CleanFeat.post_%.3d.npy'%(dir,i), '%s/onehot_clean.pdf_%.3d.npy'%(dir,i)) for i in xrange(1)]\n\n\n super(I2R_Posterior_Blocks_ClnDNN_CleanFeat, self).__init__(feature_size=feature_size,\n target_size=target_size,\n data_paths=self.data_paths,\n **kwargs)", "metadata": "root.I2R_Posterior_Blocks_ClnDNN_CleanFeat.__init__", "header": "['class', 'I2R_Posterior_Blocks_ClnDNN_CleanFeat', '(', 'DataBlocks', ')', ':', '___EOS___']", "index": 19 }, { "content": "class I2R_Posterior_Blocks_ClnDNN_NoisyFeat(DataBlocks):\n\n", "metadata": "root.I2R_Posterior_Blocks_ClnDNN_NoisyFeat", "header": "['module', '___EOS___']", "index": 38 }, { "content": " def __init__(self, feature_size, target_size, one_hot=True, num_blocks=30, **kwargs):\n\n \"\"\"\n DESCRIPTION:\n This is class for processing blocks of data.\n PARAM:\n data_paths(list): contains the paths to the numpy data files. It's a\n list of tuples whereby the first element of the tuple\n is the X path, and the second is the y path.\n \"\"\"\n dir = '/scratch/stuwzhz/dataset/npy'\n if one_hot:\n self.data_paths = [('%s/ClnDNN_NoisyFeat.post_%.3d.npy'%(dir,i), '%s/onehot_clean.pdf_%.3d.npy'%(dir,i)) for i in xrange(num_blocks)]\n else:\n self.data_paths = [('%s/ClnDNN_NoisyFeat.post_%.3d.npy'%(dir,i), '%s/clean.pdf_%.3d.npy'%(dir,i)) for i in xrange(num_blocks)]\n super(I2R_Posterior_Blocks_ClnDNN_NoisyFeat, self).__init__(feature_size=feature_size,\n target_size=target_size,\n data_paths=self.data_paths,\n **kwargs)", "metadata": "root.I2R_Posterior_Blocks_ClnDNN_NoisyFeat.__init__", "header": "['class', 'I2R_Posterior_Blocks_ClnDNN_NoisyFeat', '(', 'DataBlocks', ')', ':', '___EOS___']", "index": 41 }, { "content": "class I2R_Posterior_Gaussian_Noisy_Sample(SingleBlock):\n", "metadata": "root.I2R_Posterior_Gaussian_Noisy_Sample", "header": "['module', '___EOS___']", "index": 61 }, { "content": " def __init__(self, **kwargs):\n dir = '/home/stuwzhz/datasets/spectral-features/npy2'\n\n with open('%s/sample_y.npy'%dir) as yin:\n y = np.load(yin)\n y_tmp = []\n for e in y:\n if e > 150:\n y_tmp.append(e)\n\n y_tmp = np.asarray(y_tmp)\n y_tmp = make_one_hot(y_tmp, 1998)\n\n super(I2R_Posterior_Gaussian_Noisy_Sample, self).__init__(X=y_tmp, y=y_tmp, **kwargs)", "metadata": "root.I2R_Posterior_Gaussian_Noisy_Sample.__init__", "header": "['class', 'I2R_Posterior_Gaussian_Noisy_Sample', '(', 'SingleBlock', ')', ':', '___EOS___']", "index": 63 }, { "content": "class I2R_Posterior_NoisyFeat_Sample(SingleBlock):\n", "metadata": "root.I2R_Posterior_NoisyFeat_Sample", "header": "['module', '___EOS___']", "index": 78 }, { "content": " def __init__(self, **kwargs):\n dir = '/home/stuwzhz/datasets/spectral-features/npy2'\n\n with open('%s/sample_y.npy'%dir) as yin, \\\n open('%s/sample_X.npy'%dir) as Xin:\n y = np.load(yin)\n y = make_one_hot(y, 1998)\n X = np.load(Xin)\n\n super(I2R_Posterior_NoisyFeat_Sample, self).__init__(X=X, y=y, **kwargs)", "metadata": "root.I2R_Posterior_NoisyFeat_Sample.__init__", "header": "['class', 'I2R_Posterior_NoisyFeat_Sample', '(', 'SingleBlock', ')', ':', '___EOS___']", "index": 80 } ]
[ { "span": "import matplotlib.pyplot as plt", "start_line": 2, "start_column": 0, "end_line": 2, "end_column": 31 }, { "span": "import os", "start_line": 6, "start_column": 0, "end_line": 6, "end_column": 9 }, { "span": "import theano", "start_line": 8, "start_column": 0, "end_line": 8, "end_column": 13 } ]
[]
1
false
[ "[CLS]_", "Un", "used_", "import_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "import_", "matplotlib_", "._", "pyplot_", "as_", "plt_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "import_", "logging_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "logger_", "=_", "logging_", "._", "get", "Logger_", "(_", "\\u\\u", "name\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "os_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "numpy_", "as_", "np_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "theano_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "from_", "pyn", "et_", "._", "datasets_", "._", "dataset_", "import_", "Sing", "le", "Block_", ",_", "Data", "Blocks_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "pyn", "et_", "._", "utils_", "._", "utils_", "import_", "make", "\\u", "one", "\\u", "hot_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "class_", "I2", "R", "\\u", "Poster", "ior", "\\u", "Block", "s", "\\u", "Cl", "n", "DNN", "\\u", "Clean", "Feat", "_", "(_", "Data", "Blocks_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "[SEP]_", "class_", "I2", "R", "\\u", "Poster", "ior", "\\u", "Block", "s", "\\u", "Cl", "n", "DNN", "\\u", "Clean", "Feat", "_", "(_", "Data", "Blocks_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "def_", "\\u\\u", "init\\u\\u_", "(_", "self_", ",_", "feature", "\\u", "size_", ",_", "target", "\\u", "size_", ",_", "**_", "kwargs_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "DESCRIPT", "ION", ":", "\\", "10", ";", " ", " ", " ", " ", "Thi", "s", " ", "is", " ", "class", " ", "for", " ", "process", "ing", " ", "blocks", " ", "of", " ", "data", ".", "\\", "10", ";", " ", " ", " ", " ", "PARAM", ":", "\\", "10", ";", " ", " ", " ", " ", "data\\u", "path", "s", "(", "list", "):", " ", "contain", "s", " ", "the", " ", "path", "s", " ", "to", " ", "the", " ", "nump", "y", " ", "data", " ", "files", ".", " ", "It", "'", "s", " ", "a", "\\", "10", ";", " ", " ", " ", " ", " ", " ", "list", " ", "of", " ", "tuple", "s", " ", "where", "by", " ", "the", " ", "first", " ", "element", " ", "of", " ", "the", " ", "tuple", "\\", "10", ";", " ", " ", " ", " ", " ", " ", "is", " ", "the", " ", "X", " ", "path", ",", " ", "and", " ", "the", " ", "second", " ", "is", " ", "the", " ", "y", " ", "path", ".", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "dir_", "=_", "'/", "home", "/", "stu", "wz", "hz", "/", "dataset", "s", "/", "spectral", "-", "features", "/", "npy", "2", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "data\\u", "paths_", "=_", "[_", "(_", "'%", "s", "/", "Cl", "n", "DNN", "\\u", "Clean", "Feat", ".", "post", "\\u", "%", ".3", "d", ".", "npy", "'_", "%_", "(_", "dir_", ",_", "i_", ")_", ",_", "'%", "s", "/", "one", "hot", "\\u", "clean", ".", "pdf", "\\u", "%", ".3", "d", ".", "npy", "'_", "%_", "(_", "dir_", ",_", "i_", ")_", ")_", "for_", "i_", "in_", "xrange_", "(_", "1_", ")_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "super_", "(_", "I2", "R", "\\u", "Poster", "ior", "\\u", "Block", "s", "\\u", "Cl", "n", "DNN", "\\u", "Clean", "Feat", "_", ",_", "self_", ")_", "._", "\\u\\u", "init\\u\\u_", "(_", "feature", "\\u", "size_", "=_", "feature", "\\u", "size_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "target", "\\u", "size_", "=_", "target", "\\u", "size_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "data\\u", "paths_", "=_", "self_", "._", "data\\u", "paths_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "**_", "kwargs_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "class_", "I2", "R", "\\u", "Poster", "ior", "\\u", "Block", "s", "\\u", "Cl", "n", "DNN", "\\u", "No", "isy", "Feat", "_", "(_", "Data", "Blocks_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "[SEP]_", "class_", "I2", "R", "\\u", "Poster", "ior", "\\u", "Block", "s", "\\u", "Cl", "n", "DNN", "\\u", "No", "isy", "Feat", "_", "(_", "Data", "Blocks_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "def_", "\\u\\u", "init\\u\\u_", "(_", "self_", ",_", "feature", "\\u", "size_", ",_", "target", "\\u", "size_", ",_", "one", "\\u", "hot_", "=_", "True_", ",_", "num", "\\u", "blocks_", "=_", "30_", ",_", "**_", "kwargs_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "DESCRIPT", "ION", ":", "\\", "10", ";", " ", " ", " ", " ", "Thi", "s", " ", "is", " ", "class", " ", "for", " ", "process", "ing", " ", "blocks", " ", "of", " ", "data", ".", "\\", "10", ";", " ", " ", " ", " ", "PARAM", ":", "\\", "10", ";", " ", " ", " ", " ", "data\\u", "path", "s", "(", "list", "):", " ", "contain", "s", " ", "the", " ", "path", "s", " ", "to", " ", "the", " ", "nump", "y", " ", "data", " ", "files", ".", " ", "It", "'", "s", " ", "a", "\\", "10", ";", " ", " ", " ", " ", " ", " ", "list", " ", "of", " ", "tuple", "s", " ", "where", "by", " ", "the", " ", "first", " ", "element", " ", "of", " ", "the", " ", "tuple", "\\", "10", ";", " ", " ", " ", " ", " ", " ", "is", " ", "the", " ", "X", " ", "path", ",", " ", "and", " ", "the", " ", "second", " ", "is", " ", "the", " ", "y", " ", "path", ".", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "dir_", "=_", "'/", "scratch", "/", "stu", "wz", "hz", "/", "dataset", "/", "npy", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "one", "\\u", "hot_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "data\\u", "paths_", "=_", "[_", "(_", "'%", "s", "/", "Cl", "n", "DNN", "\\u", "No", "isy", "Feat", ".", "post", "\\u", "%", ".3", "d", ".", "npy", "'_", "%_", "(_", "dir_", ",_", "i_", ")_", ",_", "'%", "s", "/", "one", "hot", "\\u", "clean", ".", "pdf", "\\u", "%", ".3", "d", ".", "npy", "'_", "%_", "(_", "dir_", ",_", "i_", ")_", ")_", "for_", "i_", "in_", "xrange_", "(_", "num", "\\u", "blocks_", ")_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "data\\u", "paths_", "=_", "[_", "(_", "'%", "s", "/", "Cl", "n", "DNN", "\\u", "No", "isy", "Feat", ".", "post", "\\u", "%", ".3", "d", ".", "npy", "'_", "%_", "(_", "dir_", ",_", "i_", ")_", ",_", "'%", "s", "/", "clean", ".", "pdf", "\\u", "%", ".3", "d", ".", "npy", "'_", "%_", "(_", "dir_", ",_", "i_", ")_", ")_", "for_", "i_", "in_", "xrange_", "(_", "num", "\\u", "blocks_", ")_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "super_", "(_", "I2", "R", "\\u", "Poster", "ior", "\\u", "Block", "s", "\\u", "Cl", "n", "DNN", "\\u", "No", "isy", "Feat", "_", ",_", "self_", ")_", "._", "\\u\\u", "init\\u\\u_", "(_", "feature", "\\u", "size_", "=_", "feature", "\\u", "size_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "target", "\\u", "size_", "=_", "target", "\\u", "size_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "data\\u", "paths_", "=_", "self_", "._", "data\\u", "paths_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "**_", "kwargs_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "class_", "I2", "R", "\\u", "Poster", "ior", "\\u", "Gaussian", "\\u", "No", "isy", "\\u", "Sample_", "(_", "Sing", "le", "Block_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "[SEP]_", "class_", "I2", "R", "\\u", "Poster", "ior", "\\u", "Gaussian", "\\u", "No", "isy", "\\u", "Sample_", "(_", "Sing", "le", "Block_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "def_", "\\u\\u", "init\\u\\u_", "(_", "self_", ",_", "**_", "kwargs_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "dir_", "=_", "'/", "home", "/", "stu", "wz", "hz", "/", "dataset", "s", "/", "spectral", "-", "features", "/", "npy", "2", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "with_", "open_", "(_", "'%", "s", "/", "sample", "\\u", "y", ".", "npy", "'_", "%_", "dir_", ")_", "as_", "yin", "_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "y_", "=_", "np_", "._", "load_", "(_", "yin", "_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "y", "\\u", "tmp_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "e_", "in_", "y_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "e_", ">_", "150_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "y", "\\u", "tmp_", "._", "append_", "(_", "e_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "y", "\\u", "tmp_", "=_", "np_", "._", "asarray_", "(_", "y", "\\u", "tmp_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "y", "\\u", "tmp_", "=_", "make", "\\u", "one", "\\u", "hot_", "(_", "y", "\\u", "tmp_", ",_", "199", "8_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "super_", "(_", "I2", "R", "\\u", "Poster", "ior", "\\u", "Gaussian", "\\u", "No", "isy", "\\u", "Sample_", ",_", "self_", ")_", "._", "\\u\\u", "init\\u\\u_", "(_", "X_", "=_", "y", "\\u", "tmp_", ",_", "y_", "=_", "y", "\\u", "tmp_", ",_", "**_", "kwargs_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "class_", "I2", "R", "\\u", "Poster", "ior", "\\u", "No", "isy", "Feat", "\\u", "Sample_", "(_", "Sing", "le", "Block_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "[SEP]_", "class_", "I2", "R", "\\u", "Poster", "ior", "\\u", "No", "isy", "Feat", "\\u", "Sample_", "(_", "Sing", "le", "Block_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "def_", "\\u\\u", "init\\u\\u_", "(_", "self_", ",_", "**_", "kwargs_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "dir_", "=_", "'/", "home", "/", "stu", "wz", "hz", "/", "dataset", "s", "/", "spectral", "-", "features", "/", "npy", "2", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "with_", "open_", "(_", "'%", "s", "/", "sample", "\\u", "y", ".", "npy", "'_", "%_", "dir_", ")_", "as_", "yin", "_", ",_", "open_", "(_", "'%", "s", "/", "sample", "\\u", "X", ".", "npy", "'_", "%_", "dir_", ")_", "as_", "Xin", "_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "y_", "=_", "np_", "._", "load_", "(_", "yin", "_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "y_", "=_", "make", "\\u", "one", "\\u", "hot_", "(_", "y_", ",_", "199", "8_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "X_", "=_", "np_", "._", "load_", "(_", "Xin", "_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "super_", "(_", "I2", "R", "\\u", "Poster", "ior", "\\u", "No", "isy", "Feat", "\\u", "Sample_", ",_", "self_", ")_", "._", "\\u\\u", "init\\u\\u_", "(_", "X_", "=_", "X_", ",_", "y_", "=_", "y_", ",_", "**_", "kwargs_", ")_" ]
[ 4, 4, 4, 4, 4, 2, 2, 2, 2, 0, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 1, 2, 2, 2, 2, 2, 2, 0, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 ]
Unused import
karesansui/karesansui/karesansui/gadget/guestby1currentsnapshot.py
[ { "content": "# -*- coding: utf-8 -*-\n#\n# This file is part of Karesansui.\n#\n# Copyright (C) 2009-2012 HDE, Inc.\n#\n# Permission is hereby granted, free of charge, to any person obtaining a copy\n# of this software and associated documentation files (the \"Software\"), to deal\n# in the Software without restriction, including without limitation the rights\n# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n# copies of the Software, and to permit persons to whom the Software is\n# furnished to do so, subject to the following conditions:\n#\n# The above copyright notice and this permission notice shall be included in\n# all copies or substantial portions of the Software.\n#\n# THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n# THE SOFTWARE.\n#\n\nimport os\n\nimport web\nimport simplejson as json\n\nimport karesansui\nfrom karesansui.lib.rest import Rest, auth\nfrom karesansui.lib.const import VIRT_COMMAND_APPLY_SNAPSHOT\nfrom karesansui.lib.utils import is_param, is_int\n\nfrom karesansui.lib.virt.snapshot import KaresansuiVirtSnapshot\n\nfrom karesansui.db.access.machine import findbyguest1\nfrom karesansui.db.access.snapshot import findbyname_guestby1 as s_findbyname_guestby1\nfrom karesansui.db.access._2pysilhouette import save_job_collaboration\nfrom karesansui.db.access.machine2jobgroup import new as m2j_new\n\nfrom karesansui.db.model._2pysilhouette import Job, JobGroup\nfrom pysilhouette.command import dict2command\n\n\nurls = (\n '/host/(\\d+)/guest/(\\d+)/currentsnapshot/?(\\.part)?$', GuestBy1CurrentSnapshot,\n )\n", "metadata": "root", "header": "['module', '___EOS___']", "index": 0 }, { "content": "class GuestBy1CurrentSnapshot(Rest):\n", "metadata": "root.GuestBy1CurrentSnapshot", "header": "['module', '___EOS___']", "index": 45 }, { "content": " @auth\n def _PUT(self, *param, **params):\n (host_id, guest_id) = self.chk_guestby1(param)\n if guest_id is None: return web.notfound()\n\n if is_param(self.input, 'id') is False \\\n or is_int(self.input.id) is False:\n return web.badrequest(\"Request data is invalid.\")\n\n snapshot_id = str(self.input.id)\n\n snapshot = s_findbyname_guestby1(self.orm, snapshot_id, guest_id)\n if snapshot is None:\n pass\n # ignore snapshots that is not in database.\n #return web.badrequest(\"Request data is invalid.\")\n\n model = findbyguest1(self.orm, guest_id)\n\n kvs = KaresansuiVirtSnapshot(readonly=False)\n snapshot_list = []\n try:\n domname = kvs.kvc.uuid_to_domname(model.uniq_key)\n if not domname: return web.notfound()\n self.view.is_creatable = kvs.isSupportedDomain(domname)\n try:\n snapshot_list = kvs.listNames(domname)[domname]\n except:\n pass\n\n finally:\n kvs.finish()\n\n if not snapshot_id in snapshot_list:\n self.logger.debug(_(\"The specified snapshot does not exist in database. - %s\") % snapshot_id)\n # ignore snapshots that is not in database.\n #return web.notfound()\n\n action_cmd = dict2command(\n \"%s/%s\" % (karesansui.config['application.bin.dir'],\n VIRT_COMMAND_APPLY_SNAPSHOT),\n {\"name\" : domname, \"id\" : snapshot_id})\n\n cmdname = 'Apply Snapshot'\n\n _jobgroup = JobGroup(cmdname, karesansui.sheconf['env.uniqkey'])\n _job = Job('%s command' % cmdname, 0, action_cmd)\n _jobgroup.jobs.append(_job)\n\n _machine2jobgroup = m2j_new(machine=model,\n jobgroup_id=-1,\n uniq_key=karesansui.sheconf['env.uniqkey'],\n created_user=self.me,\n modified_user=self.me,\n )\n \n save_job_collaboration(self.orm,\n self.pysilhouette.orm,\n _machine2jobgroup,\n _jobgroup,\n ) \n\n self.view.currentsnapshot = snapshot\n\n return web.accepted(url=web.ctx.path)", "metadata": "root.GuestBy1CurrentSnapshot._PUT", "header": "['class', 'GuestBy1CurrentSnapshot', '(', 'Rest', ')', ':', '___EOS___']", "index": 47 } ]
[ { "span": "import os", "start_line": 25, "start_column": 0, "end_line": 25, "end_column": 9 }, { "span": "import simplejson as json", "start_line": 28, "start_column": 0, "end_line": 28, "end_column": 25 } ]
[]
1
false
[ "[CLS]_", "Un", "used_", "import_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "#", " ", "-*-", " ", "codi", "ng", ":", " ", "utf", "-", "8", " ", "-*-", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Thi", "s", " ", "file", " ", "is", " ", "part", " ", "of", " ", "Kar", "esa", "nsu", "i", "._", "\\u\\u\\uNL\\u\\u\\u_", "#", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Copy", "right", " ", "(", "C", ")", " ", "200", "9", "-", "2012", " ", "HD", "E", ",", " ", "Inc", "._", "\\u\\u\\uNL\\u\\u\\u_", "#", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Permi", "ssion", " ", "is", " ", "here", "by", " ", "grant", "ed", ",", " ", "free", " ", "of", " ", "charge", ",", " ", "to", " ", "any", " ", "person", " ", "obtain", "ing", " ", "a", " ", "copy_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "of", " ", "this", " ", "software", " ", "and", " ", "associate", "d", " ", "documentation", " ", "files", " ", "(", "the", " ", "\"", "Sof", "twa", "re", "\")", ",", " ", "to", " ", "deal", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "in", " ", "the", " ", "Sof", "twa", "re", " ", "with", "out", " ", "restriction", ",", " ", "inclu", "ding", " ", "with", "out", " ", "limit", "ation", " ", "the", " ", "rights_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "to", " ", "use", ",", " ", "copy", ",", " ", "modif", "y", ",", " ", "merge", ",", " ", "publi", "sh", ",", " ", "distribute", ",", " ", "subli", "cens", "e", ",", " ", "and", "/", "or", " ", "sell", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "copie", "s", " ", "of", " ", "the", " ", "Sof", "twa", "re", ",", " ", "and", " ", "to", " ", "permit", " ", "person", "s", " ", "to", " ", "who", "m", " ", "the", " ", "Sof", "twa", "re", " ", "is_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "fur", "nish", "ed", " ", "to", " ", "do", " ", "so", ",", " ", "subject", " ", "to", " ", "the", " ", "follow", "ing", " ", "condition", "s", ":_", "\\u\\u\\uNL\\u\\u\\u_", "#", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "The", " ", "above", " ", "copyr", "ight", " ", "notice", " ", "and", " ", "this", " ", "permissi", "on", " ", "notice", " ", "sha", "ll", " ", "be", " ", "include", "d", " ", "in_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "all", " ", "copie", "s", " ", "or", " ", "substa", "nti", "al", " ", "porti", "ons", " ", "of", " ", "the", " ", "Sof", "twa", "re", "._", "\\u\\u\\uNL\\u\\u\\u_", "#", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "THE", " ", "SOFT", "WARE", " ", "IS", " ", "PROVI", "DED", " ", "\"", "AS", " ", "IS", "\",", " ", "WITH", "OUT", " ", "WAR", "RAN", "TY", " ", "OF", " ", "ANY", " ", "KIND", ",", " ", "EXPR", "ESS", " ", "OR_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "IMPL", "IED", ",", " ", "INC", "LU", "DING", " ", "BUT", " ", "NOT", " ", "LIMIT", "ED", " ", "TO", " ", "THE", " ", "WAR", "RAN", "TIES", " ", "OF", " ", "MER", "CHAN", "TAB", "ILI", "TY", ",_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "FIT", "NESS", " ", "FOR", " ", "A", " ", "PARTI", "CUL", "AR", " ", "PUR", "POS", "E", " ", "AND", " ", "NON", "INF", "RING", "EME", "NT", ".", " ", "IN", " ", "NO", " ", "EVENT", " ", "SHA", "LL", " ", "THE", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "AUTHOR", "S", " ", "OR", " ", "COPY", "RIG", "HT", " ", "HOLD", "ERS", " ", "BE", " ", "LI", "AB", "LE", " ", "FOR", " ", "ANY", " ", "CLA", "IM", ",", " ", "DA", "MAGE", "S", " ", "OR", " ", "OTHER", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "LI", "ABI", "LIT", "Y", ",", " ", "WHE", "THER", " ", "IN", " ", "AN", " ", "ACTI", "ON", " ", "OF", " ", "CONTR", "ACT", ",", " ", "TOR", "T", " ", "OR", " ", "OTHER", "WI", "SE", ",", " ", "ARI", "SIN", "G", " ", "FROM", ",_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "OUT", " ", "OF", " ", "OR", " ", "IN", " ", "CONNECTION", " ", "WITH", " ", "THE", " ", "SOFT", "WARE", " ", "OR", " ", "THE", " ", "USE", " ", "OR", " ", "OTHER", " ", "DEA", "LING", "S", " ", "IN_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "THE", " ", "SOFT", "WARE", "._", "\\u\\u\\uNL\\u\\u\\u_", "#", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "import_", "os_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "import_", "web_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "simplejson_", "as_", "json_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "import_", "kar", "esa", "nsu", "i_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "kar", "esa", "nsu", "i_", "._", "lib_", "._", "rest_", "import_", "Rest", "_", ",_", "auth_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "kar", "esa", "nsu", "i_", "._", "lib_", "._", "const_", "import_", "VIR", "T", "\\u", "COMMA", "ND", "\\u", "APPL", "Y", "\\u", "SNAPSHOT", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "kar", "esa", "nsu", "i_", "._", "lib_", "._", "utils_", "import_", "is", "\\u", "param_", ",_", "is", "\\u", "int_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "from_", "kar", "esa", "nsu", "i_", "._", "lib_", "._", "virt_", "._", "snapshot_", "import_", "Kar", "esa", "nsu", "i", "Virt", "Snapshot_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "from_", "kar", "esa", "nsu", "i_", "._", "db_", "._", "access_", "._", "machine_", "import_", "find", "by", "guest", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "kar", "esa", "nsu", "i_", "._", "db_", "._", "access_", "._", "snapshot_", "import_", "find", "by", "name", "\\u", "guest", "by", "1_", "as_", "s", "\\u", "find", "by", "name", "\\u", "guest", "by", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "kar", "esa", "nsu", "i_", "._", "db_", "._", "access_", "._", "\\u", "2py", "sil", "hou", "ette", "_", "import_", "save", "\\u", "job", "\\u", "collaborat", "ion_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "kar", "esa", "nsu", "i_", "._", "db_", "._", "access_", "._", "machine", "2j", "ob", "group_", "import_", "new_", "as_", "m2", "j", "\\u", "new_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "from_", "kar", "esa", "nsu", "i_", "._", "db_", "._", "model_", "._", "\\u", "2py", "sil", "hou", "ette", "_", "import_", "Job_", ",_", "Jo", "b", "Group_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "pys", "il", "hou", "ette", "_", "._", "command_", "import_", "dict2", "command_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "urls_", "=_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "'/", "host", "/(", "\\\\", "d", "+)", "/", "guest", "/(", "\\\\", "d", "+)", "/", "currents", "nap", "sho", "t", "/?", "(\\\\", ".", "part", ")?", "$'_", ",_", "Gue", "st", "By", "1", "Curr", "ent", "Snapshot_", ",_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "class_", "Gue", "st", "By", "1", "Curr", "ent", "Snapshot_", "(_", "Rest", "_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "[SEP]_", "class_", "Gue", "st", "By", "1", "Curr", "ent", "Snapshot_", "(_", "Rest", "_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "@_", "auth_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "\\u", "PUT_", "(_", "self_", ",_", "*_", "param_", ",_", "**_", "params_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "(_", "host", "\\u", "id_", ",_", "guest", "\\u", "id_", ")_", "=_", "self_", "._", "chk", "\\u", "guest", "by", "1_", "(_", "param_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "guest", "\\u", "id_", "is_", "None_", ":_", "return_", "web_", "._", "notfound", "_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "is", "\\u", "param_", "(_", "self_", "._", "input_", ",_", "'", "id", "'_", ")_", "is_", "False_", "or_", "is", "\\u", "int_", "(_", "self_", "._", "input_", "._", "id_", ")_", "is_", "False_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "web_", "._", "bad", "request_", "(_", "\"", "Request", " ", "data", " ", "is", " ", "invalid", ".\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "snapshot", "\\u", "id_", "=_", "str_", "(_", "self_", "._", "input_", "._", "id_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "snapshot_", "=_", "s", "\\u", "find", "by", "name", "\\u", "guest", "by", "1_", "(_", "self_", "._", "orm_", ",_", "snapshot", "\\u", "id_", ",_", "guest", "\\u", "id_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "snapshot_", "is_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "pass_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "ignore", " ", "snapshot", "s", " ", "tha", "t", " ", "is", " ", "not", " ", "in", " ", "databa", "se", "._", "\\u\\u\\uNL\\u\\u\\u_", "#", "return", " ", "web", ".", "bad", "request", "(\"", "Request", " ", "data", " ", "is", " ", "invalid", ".\"", ")_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "model_", "=_", "find", "by", "guest", "1_", "(_", "self_", "._", "orm_", ",_", "guest", "\\u", "id_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "kvs", "_", "=_", "Kar", "esa", "nsu", "i", "Virt", "Snapshot_", "(_", "readonly_", "=_", "False_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "snapshot", "\\u", "list_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "dom", "name_", "=_", "kvs", "_", "._", "kv", "c_", "._", "uuid", "\\u", "to", "\\u", "dom", "name_", "(_", "model_", "._", "uniq", "\\u", "key_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "not_", "dom", "name_", ":_", "return_", "web_", "._", "notfound", "_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "view_", "._", "is", "\\u", "creat", "able_", "=_", "kvs", "_", "._", "is", "Supp", "orte", "d", "Domain_", "(_", "dom", "name_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "snapshot", "\\u", "list_", "=_", "kvs", "_", "._", "list", "Names_", "(_", "dom", "name_", ")_", "[_", "dom", "name_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "pass_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "finally_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "kvs", "_", "._", "finish_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "not_", "snapshot", "\\u", "id_", "in_", "snapshot", "\\u", "list_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "logger_", "._", "debug_", "(_", "\\u_", "(_", "\"", "The", " ", "specified", " ", "snapshot", " ", "doe", "s", " ", "not", " ", "exist", " ", "in", " ", "databa", "se", ".", " ", "-", " ", "%", "s", "\"_", ")_", "%_", "snapshot", "\\u", "id_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "ignore", " ", "snapshot", "s", " ", "tha", "t", " ", "is", " ", "not", " ", "in", " ", "databa", "se", "._", "\\u\\u\\uNL\\u\\u\\u_", "#", "return", " ", "web", ".", "notfound", "()", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "action", "\\u", "cmd_", "=_", "dict2", "command_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "\"%", "s", "/", "%", "s", "\"_", "%_", "(_", "kar", "esa", "nsu", "i_", "._", "config_", "[_", "'", "applica", "tion", ".", "bin", ".", "dir", "'_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "VIR", "T", "\\u", "COMMA", "ND", "\\u", "APPL", "Y", "\\u", "SNAPSHOT", "_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "{_", "\"", "name", "\"_", ":_", "dom", "name_", ",_", "\"", "id", "\"_", ":_", "snapshot", "\\u", "id_", "}_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "cmd", "name_", "=_", "'", "Apply", " ", "Snapshot", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u", "job", "group_", "=_", "Jo", "b", "Group_", "(_", "cmd", "name_", ",_", "kar", "esa", "nsu", "i_", "._", "she", "conf_", "[_", "'", "env", ".", "uniq", "key", "'_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u", "job_", "=_", "Job_", "(_", "'%", "s", " ", "command", "'_", "%_", "cmd", "name_", ",_", "0_", ",_", "action", "\\u", "cmd_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u", "job", "group_", "._", "jobs_", "._", "append_", "(_", "\\u", "job_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u", "machine", "2j", "ob", "group_", "=_", "m2", "j", "\\u", "new_", "(_", "machine_", "=_", "model_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "job", "group", "\\u", "id_", "=_", "-_", "1_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "uniq", "\\u", "key_", "=_", "kar", "esa", "nsu", "i_", "._", "she", "conf_", "[_", "'", "env", ".", "uniq", "key", "'_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "created", "\\u", "user_", "=_", "self_", "._", "me_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "modifi", "ed", "\\u", "user_", "=_", "self_", "._", "me_", ",_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "save", "\\u", "job", "\\u", "collaborat", "ion_", "(_", "self_", "._", "orm_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "pys", "il", "hou", "ette", "_", "._", "orm_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\\u", "machine", "2j", "ob", "group_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\\u", "job", "group_", ",_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "view_", "._", "currents", "nap", "shot_", "=_", "snapshot_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "return_", "web_", "._", "accepted_", "(_", "url_", "=_", "web_", "._", "ctx_", "._", "path_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_" ]
[ 4, 4, 4, 4, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2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 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 ]
Imprecise assert
Crystalnix/omaha-server/omaha_server/omaha/tests/test_views.py
[ { "content": " @temporary_media_root(MEDIA_URL='http://cache.pack.google.com/edgedl/chrome/install/782.112/')\n @patch('omaha.models.version_upload_to', lambda o, f: f)\n def test_userid_counting(self):\n now = datetime.utcnow()\n userid = '{D0BBD725-742D-44ae-8D46-0231E881D58E}'\n user_id = get_id(userid)\n appid1 = '{430FD4D0-B729-4F61-AA34-91526481799D}'\n appid2 = '{D0AB2EBC-931B-4013-9FEB-C9C4C2225C8C}'\n install_date = datetime(year=2014, month=1, day=1, hour=15, minute=41, second=48)\n update_date = install_date + timedelta(days=31)\n\n request_events = DayEvents('request', install_date.year, install_date.month, install_date.day)\n app1_install_events = DayEvents('new_install:%s' % appid1, install_date.year, install_date.month, install_date.day)\n app2_install_events = DayEvents('new_install:%s' % appid2, install_date.year, install_date.month, install_date.day)\n app1_update_events = DayEvents('request:%s' % appid1, update_date.year, update_date.month, update_date.day)\n app2_update_events = DayEvents('request:%s' % appid2, update_date.year, update_date.month, update_date.day)\n\n self.assertEqual(len(request_events), 0)\n self.assertEqual(len(app1_install_events), 0)\n self.assertEqual(len(app2_install_events), 0)\n\n app = ApplicationFactory.create(id='{D0AB2EBC-931B-4013-9FEB-C9C4C2225C8C}', name='chrome')\n platform = PlatformFactory.create(name='win')\n channel = ChannelFactory.create(name='stable')\n obj = VersionFactory.create(\n app=app,\n platform=platform,\n channel=channel,\n version='13.0.782.112',\n file=SimpleUploadedFile('./chrome_installer.exe', b'_' * 23963192))\n obj.file_hash = 'VXriGUVI0TNqfLlU02vBel4Q3Zo='\n obj.save()\n\n Action.objects.create(\n version=obj,\n arguments='--do-not-launch-chrome',\n event=EVENT_DICT_CHOICES['install'],\n run='chrome_installer.exe'\n )\n\n Action.objects.create(\n version=obj,\n event=EVENT_DICT_CHOICES['postinstall'],\n other=dict(\n version='13.0.782.112',\n onsuccess='exitsilentlyonlaunchcmd',\n )\n )\n\n with freeze_time(install_date): # 56508 sec\n self.client.post(reverse('update'),\n fixtures.request_update_check, content_type='text/xml')\n\n self.assertEqual(len(request_events), 1)\n self.assertEqual(len(app1_install_events), 1)\n self.assertEqual(len(app2_install_events), 1)\n self.assertTrue(user_id in request_events)\n self.assertTrue(user_id in app1_install_events)\n self.assertTrue(user_id in app2_install_events)\n\n with freeze_time(update_date):\n self.client.post(reverse('update'),\n fixtures.request_update_check, content_type='text/xml')\n\n self.assertEqual(len(app1_update_events), 1)\n self.assertEqual(len(app2_update_events), 1)\n self.assertTrue(user_id in app1_update_events)\n self.assertTrue(user_id in app2_update_events)", "metadata": "root.UpdateViewTest.test_userid_counting", "header": "['class', 'UpdateViewTest', '(', 'TestCase', ',', 'XmlTestMixin', ')', ':', '___EOS___']", "index": 101 } ]
[ { "span": "self.assertTrue(user_id in request_events)", "start_line": 157, "start_column": 8, "end_line": 157, "end_column": 50 }, { "span": "self.assertTrue(user_id in app1_install_events)", "start_line": 158, "start_column": 8, "end_line": 158, "end_column": 55 }, { "span": "self.assertTrue(user_id in app2_install_events)", "start_line": 159, "start_column": 8, "end_line": 159, "end_column": 55 }, { "span": "self.assertTrue(user_id in app1_update_events)", "start_line": 167, "start_column": 8, "end_line": 167, "end_column": 54 }, { "span": "self.assertTrue(user_id in app2_update_events)", "start_line": 168, "start_column": 8, "end_line": 168, "end_column": 54 } ]
[]
1
true
[ "[CLS]_", "Imp", "reci", "se_", "assert_", "[SEP]_", "class_", "Update", "View", "Test_", "(_", "Test", "Case_", ",_", "Xm", "l", "Test", "Mixin_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "@_", "temporar", "y", "\\u", "media", "\\u", "root_", "(_", "MEDIA", "\\u", "URL_", "=_", "'", "http", "://", "cache", ".", "pack", ".", "google", ".", "com", "/", "edge", "dl", "/", "chrome", "/", "install", "/", "782", ".1", "1", "2", "/'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "@_", "patch_", "(_", "'", "oma", "ha", ".", "model", "s", ".", "version", "\\u", "upload", "\\u", "to", "'_", ",_", "lambda_", "o_", ",_", "f_", ":_", "f_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "test\\u", "user", "id", "\\u", "counti", "ng_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "now_", "=_", "datetime_", "._", "utcnow_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "userid_", "=_", "'{", "D0", "BB", "D7", "25", "-", "742", "D", "-", "4", "4a", "e-", "8", "D4", "6", "-0", "231", "E", "881", "D5", "8", "E", "}'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "user", "\\u", "id_", "=_", "get", "\\u", "id_", "(_", "userid_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "appid", "1_", "=_", "'{", "430", "FD", "4", "D0", "-", "B", "729", "-", "4", "F6", "1", "-", "AA", "3", "4", "-", "915", "264", "817", "9", "9", "D", "}'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "appid", "2_", "=_", "'{", "D0", "AB", "2E", "BC", "-", "931", "B", "-", "401", "3", "-", "9", "FE", "B", "-", "C", "9", "C4", "C2", "225", "C8", "C", "}'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "install", "\\u", "date_", "=_", "datetime_", "(_", "year_", "=_", "2014_", ",_", "month_", "=_", "1_", ",_", "day_", "=_", "1_", ",_", "hour_", "=_", "15_", ",_", "minute_", "=_", "41_", ",_", "second_", "=_", "48_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "update", "\\u", "date_", "=_", "install", "\\u", "date_", "+_", "timedelta_", "(_", "days_", "=_", "31_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "request", "\\u", "events_", "=_", "Day", "Events_", "(_", "'", "request", "'_", ",_", "install", "\\u", "date_", "._", "year_", ",_", "install", "\\u", "date_", "._", "month_", ",_", "install", "\\u", "date_", "._", "day_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "app", "1", "\\u", "install", "\\u", "events_", "=_", "Day", "Events_", "(_", "'", "new", "\\u", "install", ":", "%", "s", "'_", "%_", "appid", "1_", ",_", "install", "\\u", "date_", "._", "year_", ",_", "install", "\\u", "date_", "._", "month_", ",_", "install", "\\u", "date_", "._", "day_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "app", "2", "\\u", "install", "\\u", "events_", "=_", "Day", "Events_", "(_", "'", "new", "\\u", "install", ":", "%", "s", "'_", "%_", "appid", "2_", ",_", "install", "\\u", "date_", "._", "year_", ",_", "install", "\\u", "date_", "._", "month_", ",_", "install", "\\u", "date_", "._", "day_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "app", "1", "\\u", "update", "\\u", "events_", "=_", "Day", "Events_", "(_", "'", "request", ":", "%", "s", "'_", "%_", "appid", "1_", ",_", "update", "\\u", "date_", "._", "year_", ",_", "update", "\\u", "date_", "._", "month_", ",_", "update", "\\u", "date_", "._", "day_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "app", "2", "\\u", "update", "\\u", "events_", "=_", "Day", "Events_", "(_", "'", "request", ":", "%", "s", "'_", "%_", "appid", "2_", ",_", "update", "\\u", "date_", "._", "year_", ",_", "update", "\\u", "date_", "._", "month_", ",_", "update", "\\u", "date_", "._", "day_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "len_", "(_", "request", "\\u", "events_", ")_", ",_", "0_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "len_", "(_", "app", "1", "\\u", "install", "\\u", "events_", ")_", ",_", "0_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "len_", "(_", "app", "2", "\\u", "install", "\\u", "events_", ")_", ",_", "0_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "app_", "=_", "Applica", "tion", "Factory_", "._", "create_", "(_", "id_", "=_", "'{", "D0", "AB", "2E", "BC", "-", "931", "B", "-", "401", "3", "-", "9", "FE", "B", "-", "C", "9", "C4", "C2", "225", "C8", "C", "}'_", ",_", "name_", "=_", "'", "chrome", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "platform_", "=_", "Plat", "form", "Factory_", "._", "create_", "(_", "name_", "=_", "'", "win", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "channel_", "=_", "Chan", "nel", "Factory_", "._", "create_", "(_", "name_", "=_", "'", "stable", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "obj_", "=_", "Version", "Factory_", "._", "create_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "app_", "=_", "app_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "platform_", "=_", "platform_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "channel_", "=_", "channel_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "version_", "=_", "'", "13.", "0.78", "2.1", "1", "2", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "file_", "=_", "Simple", "Upload", "ed", "File_", "(_", "'./", "chrome", "\\u", "installer", ".", "exe", "'_", ",_", "b", "'\\u'_", "*_", "239", "631", "92_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "obj_", "._", "file", "\\u", "hash_", "=_", "'", "VX", "ri", "GU", "VI", "0", "TN", "qf", "Ll", "U", "02", "v", "Bel", "4", "Q", "3", "Zo", "='_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "obj_", "._", "save_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "Action_", "._", "objects_", "._", "create_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "version_", "=_", "obj_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "arguments_", "=_", "'--", "do", "-", "not", "-", "launch", "-", "chrome", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "event_", "=_", "EVENT", "\\u", "DICT", "\\u", "CHOICES_", "[_", "'", "install", "'_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "run_", "=_", "'", "chrome", "\\u", "installer", ".", "exe", "'_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "Action_", "._", "objects_", "._", "create_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "version_", "=_", "obj_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "event_", "=_", "EVENT", "\\u", "DICT", "\\u", "CHOICES_", "[_", "'", "posti", "nstal", "l", "'_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "other_", "=_", "dict_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "version_", "=_", "'", "13.", "0.78", "2.1", "1", "2", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "ons", "ucc", "ess_", "=_", "'", "exits", "ilen", "tl", "yon", "launch", "cmd", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "with_", "freez", "e\\u", "time_", "(_", "install", "\\u", "date_", ")_", ":_", "#", " ", "565", "0", "8", " ", "sec_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "client_", "._", "post_", "(_", "reverse_", "(_", "'", "update", "'_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "fixtures_", "._", "request", "\\u", "update", "\\u", "check_", ",_", "content", "\\u", "type_", "=_", "'", "text", "/", "xml", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "len_", "(_", "request", "\\u", "events_", ")_", ",_", "1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "len_", "(_", "app", "1", "\\u", "install", "\\u", "events_", ")_", ",_", "1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "len_", "(_", "app", "2", "\\u", "install", "\\u", "events_", ")_", ",_", "1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "user", "\\u", "id_", "in_", "request", "\\u", "events_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "user", "\\u", "id_", "in_", "app", "1", "\\u", "install", "\\u", "events_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "user", "\\u", "id_", "in_", "app", "2", "\\u", "install", "\\u", "events_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "with_", "freez", "e\\u", "time_", "(_", "update", "\\u", "date_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "client_", "._", "post_", "(_", "reverse_", "(_", "'", "update", "'_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "fixtures_", "._", "request", "\\u", "update", "\\u", "check_", ",_", "content", "\\u", "type_", "=_", "'", "text", "/", "xml", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "len_", "(_", "app", "1", "\\u", "update", "\\u", "events_", ")_", ",_", "1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "len_", "(_", "app", "2", "\\u", "update", "\\u", "events_", ")_", ",_", "1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "user", "\\u", "id_", "in_", "app", "1", "\\u", "update", "\\u", "events_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "user", "\\u", "id_", "in_", "app", "2", "\\u", "update", "\\u", "events_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_" ]
[ 4, 4, 4, 4, 4, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,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, 2, 2, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2 ]
Unused import
rwl/muntjac/muntjac/demo/sampler/features/dates/__init__.py
[ { "content": "\nfrom muntjac.demo.sampler.features.dates.DateLocale import DateLocale\nfrom muntjac.demo.sampler.features.dates.DatePopupInputPrompt import DatePopupInputPrompt\nfrom muntjac.demo.sampler.features.dates.DateInline import DateInline\nfrom muntjac.demo.sampler.features.dates.DatePopup import DatePopup\nfrom muntjac.demo.sampler.features.dates.DateResolution import DateResolution\nfrom muntjac.demo.sampler.features.dates.DatePopupKeyboardNavigation import DatePopupKeyboardNavigation\n", "metadata": "root", "header": "['module', '___EOS___']", "index": 0 } ]
[ { "span": "from muntjac.demo.sampler.features.dates.DateLocale import DateLocale", "start_line": 1, "start_column": 0, "end_line": 1, "end_column": 69 }, { "span": "from muntjac.demo.sampler.features.dates.DatePopupInputPrompt import DatePopupInputPrompt", "start_line": 2, "start_column": 0, "end_line": 2, "end_column": 89 }, { "span": "from muntjac.demo.sampler.features.dates.DateInline import DateInline", "start_line": 3, "start_column": 0, "end_line": 3, "end_column": 69 }, { "span": "from muntjac.demo.sampler.features.dates.DatePopup import DatePopup", "start_line": 4, "start_column": 0, "end_line": 4, "end_column": 67 }, { "span": "from muntjac.demo.sampler.features.dates.DateResolution import DateResolution", "start_line": 5, "start_column": 0, "end_line": 5, "end_column": 77 }, { "span": "from muntjac.demo.sampler.features.dates.DatePopupKeyboardNavigation import DatePopupKeyboardNavigation", "start_line": 6, "start_column": 0, "end_line": 6, "end_column": 103 } ]
[]
1
false
[ "[CLS]_", "Un", "used_", "import_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "from_", "mun", "tj", "ac_", "._", "demo_", "._", "sampler_", "._", "features_", "._", "dates_", "._", "Date", "Locale_", "import_", "Date", "Locale_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "mun", "tj", "ac_", "._", "demo_", "._", "sampler_", "._", "features_", "._", "dates_", "._", "Date", "Pop", "up", "Inp", "ut", "Prompt_", "import_", "Date", "Pop", "up", "Inp", "ut", "Prompt_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "mun", "tj", "ac_", "._", "demo_", "._", "sampler_", "._", "features_", "._", "dates_", "._", "Date", "Inline_", "import_", "Date", "Inline_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "mun", "tj", "ac_", "._", "demo_", "._", "sampler_", "._", "features_", "._", "dates_", "._", "Date", "Popup_", "import_", "Date", "Popup_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "mun", "tj", "ac_", "._", "demo_", "._", "sampler_", "._", "features_", "._", "dates_", "._", "Date", "Resolution_", "import_", "Date", "Resolution_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "mun", "tj", "ac_", "._", "demo_", "._", "sampler_", "._", "features_", "._", "dates_", "._", "Date", "Pop", "up", "Key", "board", "Navigat", "ion_", "import_", "Date", "Pop", "up", "Key", "board", "Navigat", "ion_" ]
[ 4, 4, 4, 4, 4, 2, 2, 2, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
First parameter of a method is not named 'self'
CollabQ/CollabQ/.google_appengine/google/appengine/ext/db/polymodel.py
[ { "content": " def __init__(cls, name, bases, dct):\n \"\"\"Initializes a class that belongs to a polymorphic hierarchy.\n\n This method configures a few built-in attributes of polymorphic\n models:\n\n __root_class__: If the new class is a root class, __root_class__ is set to\n itself so that it subclasses can quickly know what the root of\n their hierarchy is and what kind they are stored in.\n __class_hierarchy__: List of classes describing the new model's place\n in the class hierarchy in reverse MRO order. The first element is\n always the root class while the last element is always the new class.\n\n MRO documentation: http://www.python.org/download/releases/2.3/mro/\n\n For example:\n class Foo(PolymorphicClass): ...\n\n class Bar(Foo): ...\n\n class Baz(Bar): ...\n\n Foo.__class_hierarchy__ == [Foo]\n Bar.__class_hierarchy__ == [Foo, Bar]\n Baz.__class_hierarchy__ == [Foo, Bar, Baz]\n\n Unless the class is a root class or PolyModel itself, it is not\n inserted in to the kind-map like other models. However, all polymorphic\n classes, are inserted in to the class-map which maps the class-key to\n implementation. This class key is consulted using the polymorphic instances\n discriminator (the 'class' property of the entity) when loading from the\n datastore.\n \"\"\"\n if name == 'PolyModel':\n super(PolymorphicClass, cls).__init__(name, bases, dct, map_kind=False)\n return\n\n elif PolyModel in bases:\n if getattr(cls, '__class_hierarchy__', None):\n raise db.ConfigurationError(('%s cannot derive from PolyModel as '\n '__class_hierarchy__ is already defined.') % cls.__name__)\n cls.__class_hierarchy__ = [cls]\n cls.__root_class__ = cls\n super(PolymorphicClass, cls).__init__(name, bases, dct)\n else:\n super(PolymorphicClass, cls).__init__(name, bases, dct, map_kind=False)\n\n cls.__class_hierarchy__ = [c for c in reversed(cls.mro())\n if issubclass(c, PolyModel) and c != PolyModel]\n\n if cls.__class_hierarchy__[0] != cls.__root_class__:\n raise db.ConfigurationError(\n '%s cannot be derived from both root classes %s and %s' %\n (cls.__name__,\n cls.__class_hierarchy__[0].__name__,\n cls.__root_class__.__name__))\n\n _class_map[cls.class_key()] = cls", "metadata": "root.PolymorphicClass.__init__", "header": "['class', 'PolymorphicClass', '(', 'db', '.', 'PropertiedClass', ')', ':', '___EOS___']", "index": 79 } ]
[ { "span": "def __init__(cls, name, bases, dct):", "start_line": 79, "start_column": 2, "end_line": 79, "end_column": 38 } ]
[]
1
true
[ "[CLS]_", "First_", "parameter_", "of_", "a_", "method_", "is_", "not_", "named_", "'", "self", "'_", "[SEP]_", "class_", "Poly", "morphi", "c", "Class_", "(_", "db_", "._", "Proper", "tied", "Class_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "\\u\\u", "init\\u\\u_", "(_", "cls_", ",_", "name_", ",_", "bases_", ",_", "dct_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "Initializ", "es", " ", "a", " ", "class", " ", "tha", "t", " ", "belo", "ngs", " ", "to", " ", "a", " ", "polymorphic", " ", "hier", "arch", "y", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "Thi", "s", " ", "method", " ", "configur", "es", " ", "a", " ", "few", " ", "bui", "lt", "-", "in", " ", "attribute", "s", " ", "of", " ", "polymorphic", "\\", "10", ";", " ", " ", " ", " ", "model", "s", ":", "\\", "10", ";", "\\", "10", ";", " ", " ", "\\u\\u", "root", "\\u", "class", "\\u\\u:", " ", "If", " ", "the", " ", "new", " ", "class", " ", "is", " ", "a", " ", "root", " ", "class", ",", " ", "\\u\\u", "root", "\\u", "class", "\\u\\u", " ", "is", " ", "set", " ", "to", "\\", "10", ";", " ", " ", " ", " ", "its", "elf", " ", "so", " ", "tha", "t", " ", "it", " ", "subclasses", " ", "can", " ", "quickl", "y", " ", "know", " ", "what", " ", "the", " ", "root", " ", "of", "\\", "10", ";", " ", " ", " ", " ", "thei", "r", " ", "hier", "arch", "y", " ", "is", " ", "and", " ", "what", " ", "kind", " ", "the", "y", " ", "are", " ", "store", "d", " ", "in", ".", "\\", "10", ";", " ", " ", "\\u\\u", "class", "\\u", "hier", "arch", "y\\u\\u", ":", " ", "List", " ", "of", " ", "classe", "s", " ", "descri", "bing", " ", "the", " ", "new", " ", "model", "'", "s", " ", "place", "\\", "10", ";", " ", " ", " ", " ", "in", " ", "the", " ", "class", " ", "hier", "arch", "y", " ", "in", " ", "reverse", " ", "MR", "O", " ", "order", ".", " ", " ", "The", " ", "first", " ", "element", " ", "is", "\\", "10", ";", " ", " ", " ", " ", "alw", "ay", "s", " ", "the", " ", "root", " ", "class", " ", "whi", "le", " ", "the", " ", "last", " ", "element", " ", "is", " ", "alw", "ay", "s", " ", "the", " ", "new", " ", "class", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "MR", "O", " ", "documentation", ":", " ", "http", "://", "www", ".", "python", ".", "org", "/", "download", "/", "release", "s", "/", "2.3", "/", "mro", "/", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "For", " ", "example", ":", "\\", "10", ";", " ", " ", "class", " ", "Foo", "(", "Poly", "morphi", "c", "Class", "):", " ", "...", "\\", "10", ";", "\\", "10", ";", " ", " ", "class", " ", "Bar", "(", "Foo", "):", " ", "...", "\\", "10", ";", "\\", "10", ";", " ", " ", "class", " ", "Baz", "(", "Bar", "):", " ", "...", "\\", "10", ";", "\\", "10", ";", " ", " ", "Foo", ".\\u", "\\u", "class", "\\u", "hier", "arch", "y\\u\\u", " ", "==", " ", "[", "Foo", "]", "\\", "10", ";", " ", " ", "Bar", ".\\u", "\\u", "class", "\\u", "hier", "arch", "y\\u\\u", " ", "==", " ", "[", "Foo", ",", " ", "Bar", "]", "\\", "10", ";", " ", " ", "Baz", ".\\u", "\\u", "class", "\\u", "hier", "arch", "y\\u\\u", " ", "==", " ", "[", "Foo", ",", " ", "Bar", ",", " ", "Baz", "]", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "Un", "less", " ", "the", " ", "class", " ", "is", " ", "a", " ", "root", " ", "class", " ", "or", " ", "Poly", "Model", " ", "its", "elf", ",", " ", "it", " ", "is", " ", "not", "\\", "10", ";", " ", " ", " ", " ", "inserted", " ", "in", " ", "to", " ", "the", " ", "kind", "-", "map", " ", "like", " ", "other", " ", "model", "s", ".", " ", " ", "Ho", "we", "ver", ",", " ", "all", " ", "polymorphic", "\\", "10", ";", " ", " ", " ", " ", "classe", "s", ",", " ", "are", " ", "inserted", " ", "in", " ", "to", " ", "the", " ", "class", "-", "map", " ", "whi", "ch", " ", "maps", " ", "the", " ", "class", "-", "key", " ", "to", "\\", "10", ";", " ", " ", " ", " ", "implementation", ".", " ", " ", "Thi", "s", " ", "class", " ", "key", " ", "is", " ", "consul", "ted", " ", "usi", "ng", " ", "the", " ", "polymorphic", " ", "instance", "s", "\\", "10", ";", " ", " ", " ", " ", "discriminator", " ", "(", "the", " ", "'", "class", "'", " ", "property", " ", "of", " ", "the", " ", "entity", ")", " ", "whe", "n", " ", "load", "ing", " ", "from", " ", "the", "\\", "10", ";", " ", " ", " ", " ", "datast", "ore", ".", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "name_", "==_", "'", "Poly", "Model", "'_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "super_", "(_", "Poly", "morphi", "c", "Class_", ",_", "cls_", ")_", "._", "\\u\\u", "init\\u\\u_", "(_", "name_", ",_", "bases_", ",_", "dct_", ",_", "map", "\\u", "kind_", "=_", "False_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "Poly", "Model_", "in_", "bases_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "getattr_", "(_", "cls_", ",_", "'\\u", "\\u", "class", "\\u", "hier", "arch", "y\\u\\u", "'_", ",_", "None_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "raise_", "db_", "._", "Configura", "tion", "Error_", "(_", "(_", "'%", "s", " ", "cann", "ot", " ", "derive", " ", "from", " ", "Poly", "Model", " ", "as", " ", "'_", "\\u\\u\\uNL\\u\\u\\u_", "'\\u", "\\u", "class", "\\u", "hier", "arch", "y\\u\\u", " ", "is", " ", "alr", "ead", "y", " ", "defin", "ed", ".'_", ")_", "%_", "cls_", "._", "\\u\\u", "name\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "cls_", "._", "\\u\\u", "class", "\\u", "hier", "arch", "y\\u\\u", "_", "=_", "[_", "cls_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "cls_", "._", "\\u\\u", "root", "\\u", "class\\u\\u_", "=_", "cls_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "super_", "(_", "Poly", "morphi", "c", "Class_", ",_", "cls_", ")_", "._", "\\u\\u", "init\\u\\u_", "(_", "name_", ",_", "bases_", ",_", "dct_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "super_", "(_", "Poly", "morphi", "c", "Class_", ",_", "cls_", ")_", "._", "\\u\\u", "init\\u\\u_", "(_", "name_", ",_", "bases_", ",_", "dct_", ",_", "map", "\\u", "kind_", "=_", "False_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "cls_", "._", "\\u\\u", "class", "\\u", "hier", "arch", "y\\u\\u", "_", "=_", "[_", "c_", "for_", "c_", "in_", "reversed_", "(_", "cls_", "._", "mro", "_", "(_", ")_", ")_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "issubclass_", "(_", "c_", ",_", "Poly", "Model_", ")_", "and_", "c_", "!=_", "Poly", "Model_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "cls_", "._", "\\u\\u", "class", "\\u", "hier", "arch", "y\\u\\u", "_", "[_", "0_", "]_", "!=_", "cls_", "._", "\\u\\u", "root", "\\u", "class\\u\\u_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "raise_", "db_", "._", "Configura", "tion", "Error_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "'%", "s", " ", "cann", "ot", " ", "be", " ", "derive", "d", " ", "from", " ", "bot", "h", " ", "root", " ", "classe", "s", " ", "%", "s", " ", "and", " ", "%", "s", "'_", "%_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "cls_", "._", "\\u\\u", "name\\u\\u_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "cls_", "._", "\\u\\u", "class", "\\u", "hier", "arch", "y\\u\\u", "_", "[_", "0_", "]_", "._", "\\u\\u", "name\\u\\u_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "cls_", "._", "\\u\\u", "root", "\\u", "class\\u\\u_", "._", "\\u\\u", "name\\u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2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 ]
Unused import
Calysto/metakernel/metakernel/magics/tests/test_jigsaw_magic.py
[ { "content": "\nfrom metakernel.tests.utils import (get_kernel, get_log_text, \n clear_log_text, EvalKernel)\nimport os\n\n\n", "metadata": "root", "header": "['module', '___EOS___']", "index": 0 }, { "content": "def test_jigsaw_magic():\n kernel = get_kernel(EvalKernel)\n kernel.do_execute(\"%jigsaw Processing --workspace workspace1\")\n text = get_log_text(kernel)\n assert os.path.isfile(\"workspace1.html\"), \"File does not exist: workspace1.html\"", "metadata": "root.test_jigsaw_magic", "header": "['module', '___EOS___']", "index": 5 }, { "content": "def teardown():\n for fname in ['workspace1.html']:\n try:\n os.remove(fname)\n except:\n pass", "metadata": "root.teardown", "header": "['module', '___EOS___']", "index": 11 } ]
[ { "span": "from metakernel.tests.utils import (get_kernel, get_log_text, \n clear_log_text, EvalKernel)", "start_line": 1, "start_column": 0, "end_line": 2, "end_column": 63 } ]
[]
1
false
[ "[CLS]_", "Un", "used_", "import_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "from_", "meta", "kernel_", "._", "tests_", "._", "utils_", "import_", "(_", "get", "\\u", "kernel_", ",_", "get", "\\u", "log", "\\u", "text_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "clear", "\\u", "log", "\\u", "text_", ",_", "Eval", "Kernel_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "os_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "test\\u", "ji", "gs", "aw", "\\u", "magic_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "kernel_", "=_", "get", "\\u", "kernel_", "(_", "Eval", "Kernel_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "kernel_", "._", "do", "\\u", "execute_", "(_", "\"%", "ji", "gs", "aw", " ", "Process", "ing", " ", "--", "works", "pace", " ", "works", "pace", "1", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "text_", "=_", "get", "\\u", "log", "\\u", "text_", "(_", "kernel_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "assert_", "os_", "._", "path_", "._", "isfile_", "(_", "\"", "works", "pace", "1", ".", "html", "\"_", ")_", ",_", "\"", "File", " ", "doe", "s", " ", "not", " ", "exist", ":", " ", "works", "pace", "1", ".", "html", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "teardown_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "for_", "fname_", "in_", "[_", "'", "works", "pace", "1", ".", "html", "'_", "]_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "os_", "._", "remove_", "(_", "fname_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "pass_" ]
[ 4, 4, 4, 4, 4, 2, 2, 2, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 ]
Unused local variable
yyuu/botornado/botornado/sqs/queue.py
[ { "content": " def set_timeout(self, visibility_timeout, callback=None):\n \"\"\"\n Set the visibility timeout for the queue.\n\n :type visibility_timeout: int\n :param visibility_timeout: The desired timeout in seconds\n \"\"\"\n def _set_timeout(retval):\n if retval:\n self.visibility_timeout = visibility_timeout\n if callable(callback):\n callback(retval)\n retval = self.set_attribute('VisibilityTimeout', visibility_timeout, callback=_set_timeout)", "metadata": "root.AsyncQueue.set_timeout", "header": "['class', 'AsyncQueue', '(', 'Queue', ')', ':', '___EOS___']", "index": 86 }, { "content": " def read(self, visibility_timeout=None, callback=None):\n \"\"\"\n Read a single message from the queue.\n \n :type visibility_timeout: int\n :param visibility_timeout: The timeout for this message in seconds\n\n :rtype: :class:`boto.sqs.message.Message`\n :return: A single message or None if queue is empty\n \"\"\"\n def _read(rs):\n if callable(callback):\n callback(rs[0] if len(rs) == 1 else None)\n self.get_messages(1, visibility_timeout, callback=callback)", "metadata": "root.AsyncQueue.read", "header": "['class', 'AsyncQueue', '(', 'Queue', ')', ':', '___EOS___']", "index": 138 } ]
[ { "span": "retval ", "start_line": 98, "start_column": 8, "end_line": 98, "end_column": 14 }, { "span": "_read(", "start_line": 148, "start_column": 12, "end_line": 148, "end_column": 17 } ]
[]
1
true
[ "[CLS]_", "Un", "used_", "local_", "variable_", "[SEP]_", "class_", "Async", "Queue_", "(_", "Queue_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "set\\u", "timeout_", "(_", "self_", ",_", "visi", "bilit", "y", "\\u", "timeout_", ",_", "callback_", "=_", "None_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Set", " ", "the", " ", "visi", "bilit", "y", " ", "timeo", "ut", " ", "for", " ", "the", " ", "queue", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", ":", "type", " ", "visi", "bilit", "y", "\\u", "timeo", "ut", ":", " ", "int", "\\", "10", ";", " ", " ", " ", " ", ":", "param", " ", "visi", "bilit", "y", "\\u", "timeo", "ut", ":", " ", "The", " ", "desi", "red", " ", "timeo", "ut", " ", "in", " ", "second", "s", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "\\u", "set\\u", "timeout_", "(_", "retval_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "retval_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "visi", "bilit", "y", "\\u", "timeout_", "=_", "visi", "bilit", "y", "\\u", "timeout_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "callable_", "(_", "callback_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "callback_", "(_", "retval_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "retval_", "=_", "self_", "._", "set\\u", "attribute_", "(_", "'", "Vis", "ibi", "lit", "y", "Time", "out", "'_", ",_", "visi", "bilit", "y", "\\u", "timeout_", ",_", "callback_", "=_", "\\u", "set\\u", "timeout_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Async", "Queue_", "(_", "Queue_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "read_", "(_", "self_", ",_", "visi", "bilit", "y", "\\u", "timeout_", "=_", "None_", ",_", "callback_", "=_", "None_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Read", " ", "a", " ", "single", " ", "message", " ", "from", " ", "the", " ", "queue", ".", "\\", "10", ";", " ", " ", " ", " ", "\\", "10", ";", " ", " ", " ", " ", ":", "type", " ", "visi", "bilit", "y", "\\u", "timeo", "ut", ":", " ", "int", "\\", "10", ";", " ", " ", " ", " ", ":", "param", " ", "visi", "bilit", "y", "\\u", "timeo", "ut", ":", " ", "The", " ", "timeo", "ut", " ", "for", " ", "this", " ", "message", " ", "in", " ", "second", "s", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", ":", "rty", "pe", ":", " ", ":", "class", ":`", "boto", ".", "sqs", ".", "message", ".", "Messag", "e", "`", "\\", "10", ";", " ", " ", " ", " ", ":", "return", ":", " ", "A", " ", "single", " ", "message", " ", "or", " ", "Non", "e", " ", "if", " ", "queue", " ", "is", " ", "empty", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "\\u", "read_", "(_", "rs_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "callable_", "(_", "callback_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "callback_", "(_", "rs_", "[_", "0_", "]_", "if_", "len_", "(_", "rs_", ")_", "==_", "1_", "else_", "None_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "get", "\\u", "messages_", "(_", "1_", ",_", "visi", "bilit", "y", "\\u", "timeout_", ",_", "callback_", "=_", "callback_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_" ]
[ 4, 4, 4, 4, 4, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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py
[ { "content": "\"\"\"\nCopyright 2009 Myles Braithwaite <[email protected]>\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n\"\"\"\nimport re\nfrom django.contrib.contenttypes.models import ContentType\nfrom django import template\nfrom django.conf import settings\nfrom django.template.loader import select_template\n\nfrom tumblelog.models import Post\n\nregister = template.Library()\n\n\nregister.filter('render_item', render_item)\n\n\n\n", "metadata": "root", "header": "['module', '___EOS___']", "index": 0 }, { "content": "def render_item(item, template_name=None):\n model_name = item.content_object._meta.verbose_name_raw\n\n template_list = [template_name,] if template_name else []\n template_list.extend([\n 'tumblelog/includes/%(model)s.html' % {'model': model_name },\n 'tumblelog/includes/default.html'\n ])\n\n t = select_template(template_list)\n\n return t.render(template.Context({\n 'object' : item.content_object,\n 'object_id' : item.id,\n 'content_type' : item.content_type,\n 'item': item,\n 'MEDIA_URL': settings.MEDIA_URL\n }))", "metadata": "root.render_item", "header": "['module', '___EOS___']", "index": 25 }, { "content": "class LatestPosts(template.Node):\n", "metadata": "root.LatestPosts", "header": "['module', '___EOS___']", "index": 46 }, { "content": " def __init__(self, limit, var_name):\n self.limit = limit\n self.var_name = var_name", "metadata": "root.LatestPosts.__init__", "header": "['class', 'LatestPosts', '(', 'template', '.', 'Node', ')', ':', '___EOS___']", "index": 47 }, { "content": " def render(self, context):\n posts = Post.objects.published()[:int(self.limit)]\n if posts and (int(self.limit) == 1):\n context[self.var_name] = posts[0]\n else:\n context[self.var_name] = posts\n return ''", "metadata": "root.LatestPosts.render", "header": "['class', 'LatestPosts', '(', 'template', '.', 'Node', ')', ':', '___EOS___']", "index": 51 }, { "content": "@register.tag\ndef get_latest_posts(parser, token):\n \"\"\"\n Gets any number of latest posts and stores them in a varable.\n\n Syntax::\n\n {% get_latest_posts [limit] as [var_name] %}\n\n Example usage::\n\n {% get_latest_posts 10 as latest_post_list %}\n \"\"\"\n try:\n tag_name, arg = token.contents.split(None, 1)\n except ValueError:\n raise template.TemplateSyntaxError, \"%s tag requires arguments\" % token.contents.split()[0]\n m = re.search(r'(.*?) as (\\w+)', arg)\n if not m:\n raise template.TemplateSyntaxError, \"%s tag had invalid arguments\" % tag_name\n format_string, var_name = m.groups()\n return LatestPosts(format_string, var_name)", "metadata": "root.get_latest_posts", "header": "['module', '___EOS___']", "index": 60 } ]
[ { "span": "from django.contrib.contenttypes.models import ContentType", "start_line": 16, "start_column": 0, "end_line": 16, "end_column": 58 } ]
[]
1
false
[ "[CLS]_", "Un", "used_", "import_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\"\"\"", "\\", "10", ";", "Copy", "right", " ", "200", "9", " ", "My", "les", " ", "Bra", "ith", "wait", "e", " ", "<", "me", "@", "myl", "es", "bra", "ith", "wait", "e", ".", "com", ">", "\\", "10", ";", "\\", "10", ";", "License", "d", " ", "under", " ", "the", " ", "Ap", "ache", " ", "License", ",", " ", "Version", " ", "2.0", " ", "(", "the", " ", "\"", "License", "\");", "\\", "10", ";", "you", " ", "may", " ", "not", " ", "use", " ", "this", " ", "file", " ", "except", " ", "in", " ", "compli", "anc", "e", " ", "with", " ", "the", " ", "License", ".", "\\", "10", ";", "You", " ", "may", " ", "obtain", " ", "a", " ", "copy", " ", "of", " ", "the", " ", "License", " ", "at", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "http", "://", "www", ".", "apa", "che", ".", "org", "/", "license", "s", "/", "LICENSE", "-", "2.0", "\\", "10", ";", "\\", "10", ";", "Un", "less", " ", "require", "d", " ", "by", " ", "applica", "ble", " ", "law", " ", "or", " ", "agree", "d", " ", "to", " ", "in", " ", "writ", "ing", ",", " ", "software", "\\", "10", ";", "distributed", " ", "under", " ", "the", " ", "License", " ", "is", " ", "distributed", " ", "on", " ", "an", " ", "\"", "AS", " ", "IS", "\"", " ", "BAS", "IS", ",", "\\", "10", ";", "WITH", "OUT", " ", "WAR", "RAN", "TIES", " ", "OR", " ", "CONDITION", "S", " ", "OF", " ", "ANY", " ", "KIND", ",", " ", "eit", "her", " ", "express", " ", "or", " ", "impli", "ed", ".", "\\", "10", ";", "See", " ", "the", " ", "License", " ", "for", " ", "the", " ", "specific", " ", "language", " ", "govern", "ing", " ", "permissi", "ons", " ", "and", "\\", "10", ";", "limit", "ation", "s", " ", "under", " ", "the", " ", "License", ".", "\\", "10", ";\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "re_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "django_", "._", "contrib_", "._", "contenttype", "s_", "._", "models_", "import_", "Conten", "t", "Type_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "django_", "import_", "template_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "django_", "._", "conf_", "import_", "settings_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "django_", "._", "template_", "._", "loader_", "import_", "select", "\\u", "template_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "from_", "tum", "ble", "log_", "._", "models_", "import_", "Post_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "register_", "=_", "template_", "._", "Library_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "register_", "._", "filter_", "(_", "'", "render", "\\u", "item", "'_", ",_", "render", "\\u", "item_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "render", "\\u", "item_", "(_", "item_", ",_", "template", "\\u", "name_", "=_", "None_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "model", "\\u", "name_", "=_", "item_", "._", "content", "\\u", "object_", "._", "\\u", "meta_", "._", "verbo", "se", "\\u", "name", "\\u", "raw_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "template", "\\u", "list_", "=_", "[_", "template", "\\u", "name_", ",_", "]_", "if_", "template", "\\u", "name_", "else_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "template", "\\u", "list_", "._", "extend_", "(_", "[_", "\\u\\u\\uNL\\u\\u\\u_", "'", "tum", "ble", "log", "/", "include", "s", "/", "%", "(", "model", ")", "s", ".", "html", "'_", "%_", "{_", "'", "model", "'_", ":_", "model", "\\u", "name_", "}_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "tum", "ble", "log", "/", "include", "s", "/", "default", ".", "html", "'_", "\\u\\u\\uNL\\u\\u\\u_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "t_", "=_", "select", "\\u", "template_", "(_", "template", "\\u", "list_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "return_", "t_", "._", "render_", "(_", "template_", "._", "Context_", "(_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "'", "object", "'_", ":_", "item_", "._", "content", "\\u", "object_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "object\\u", "id", "'_", ":_", "item_", "._", "id_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "content", "\\u", "type", "'_", ":_", "item_", "._", "content", "\\u", "type_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "item", "'_", ":_", "item_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "MEDIA", "\\u", "URL", "'_", ":_", "settings_", "._", "MEDIA", "\\u", "URL_", "\\u\\u\\uNL\\u\\u\\u_", "}_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "class_", "Late", "st", "Posts", "_", "(_", "template_", "._", "Node_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "[SEP]_", "class_", "Late", "st", "Posts", "_", "(_", "template_", "._", "Node_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "def_", "\\u\\u", "init\\u\\u_", "(_", "self_", ",_", "limit_", ",_", "var", "\\u", "name_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "limit_", "=_", "limit_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "var", "\\u", "name_", "=_", "var", "\\u", "name_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Late", "st", "Posts", "_", "(_", "template_", "._", "Node_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "render_", "(_", "self_", ",_", "context_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "posts_", "=_", "Post_", "._", "objects_", "._", "published_", "(_", ")_", "[_", ":_", "int_", "(_", "self_", "._", "limit_", ")_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "posts_", "and_", "(_", "int_", "(_", "self_", "._", "limit_", ")_", "==_", "1_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "context_", "[_", "self_", "._", "var", "\\u", "name_", "]_", "=_", "posts_", "[_", "0_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "context_", "[_", "self_", "._", "var", "\\u", "name_", "]_", "=_", "posts_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "@_", "register_", "._", "tag_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "get", "\\u", "late", "st", "\\u", "posts_", "(_", "parser_", ",_", "token_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Get", "s", " ", "any", " ", "number", " ", "of", " ", "late", "st", " ", "posts", " ", "and", " ", "store", "s", " ", "them", " ", "in", " ", "a", " ", "vara", "ble", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "Syntax", "::", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "{%", " ", "get", "\\u", "late", "st", "\\u", "posts", " ", "[", "limit", "]", " ", "as", " ", "[", "var", "\\u", "name", "]", " ", "%}", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "Exam", "ple", " ", "usage", "::", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "{%", " ", "get", "\\u", "late", "st", "\\u", "posts", " ", "10", " ", "as", " ", "late", "st", "\\u", "post", "\\u", "list", " ", "%}", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "tag", "\\u", "name_", ",_", "arg_", "=_", "token_", "._", "contents_", "._", "split_", "(_", "None_", ",_", "1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "Value", "Error_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "raise_", "template_", "._", "Templa", "te", "Syntax", "Error_", ",_", "\"%", "s", " ", "tag", " ", "require", "s", " ", "argu", "ment", "s", "\"_", "%_", "token_", "._", "contents_", "._", "split_", "(_", ")_", "[_", "0_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "m_", "=_", "re_", "._", "search_", "(_", "r", "'(.*", "?)", " ", "as", " ", "(\\\\", "w", "+)'_", ",_", "arg_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "not_", "m_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "raise_", "template_", "._", "Templa", "te", "Syntax", "Error_", ",_", "\"%", "s", " ", "tag", " ", "had", " ", "invalid", " ", "argu", "ment", "s", "\"_", "%_", "tag", "\\u", "name_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "format\\u", "string_", ",_", "var", "\\u", "name_", "=_", "m_", "._", "groups_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "Late", "st", "Posts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, 2, 2, 2, 2, 2, 2, 2 ]
Variable defined multiple times
AppScale/appscale/AppServer/lib/django-0.96/django/core/management.py
[ { "content": "def get_validation_errors(outfile, app=None):\n \"\"\"\n Validates all models that are part of the specified app. If no app name is provided,\n validates all models of all installed apps. Writes errors, if any, to outfile.\n Returns number of errors.\n \"\"\"\n from django.conf import settings\n from django.db import models, connection\n from django.db.models.loading import get_app_errors\n from django.db.models.fields.related import RelatedObject\n\n e = ModelErrorCollection(outfile)\n\n for (app_name, error) in get_app_errors().items():\n e.add(app_name, error)\n\n for cls in models.get_models(app):\n opts = cls._meta\n\n # Do field-specific validation.\n for f in opts.fields:\n if f.name == 'id' and not f.primary_key and opts.pk.name == 'id':\n e.add(opts, '\"%s\": You can\\'t use \"id\" as a field name, because each model automatically gets an \"id\" field if none of the fields have primary_key=True. You need to either remove/rename your \"id\" field or add primary_key=True to a field.' % f.name)\n if isinstance(f, models.CharField) and f.maxlength in (None, 0):\n e.add(opts, '\"%s\": CharFields require a \"maxlength\" attribute.' % f.name)\n if isinstance(f, models.FloatField):\n if f.decimal_places is None:\n e.add(opts, '\"%s\": FloatFields require a \"decimal_places\" attribute.' % f.name)\n if f.max_digits is None:\n e.add(opts, '\"%s\": FloatFields require a \"max_digits\" attribute.' % f.name)\n if isinstance(f, models.FileField) and not f.upload_to:\n e.add(opts, '\"%s\": FileFields require an \"upload_to\" attribute.' % f.name)\n if isinstance(f, models.ImageField):\n try:\n from PIL import Image\n except ImportError:\n e.add(opts, '\"%s\": To use ImageFields, you need to install the Python Imaging Library. Get it at http://www.pythonware.com/products/pil/ .' % f.name)\n if f.prepopulate_from is not None and type(f.prepopulate_from) not in (list, tuple):\n e.add(opts, '\"%s\": prepopulate_from should be a list or tuple.' % f.name)\n if f.choices:\n if not hasattr(f.choices, '__iter__'):\n e.add(opts, '\"%s\": \"choices\" should be iterable (e.g., a tuple or list).' % f.name)\n else:\n for c in f.choices:\n if not type(c) in (tuple, list) or len(c) != 2:\n e.add(opts, '\"%s\": \"choices\" should be a sequence of two-tuples.' % f.name)\n if f.db_index not in (None, True, False):\n e.add(opts, '\"%s\": \"db_index\" should be either None, True or False.' % f.name)\n\n # Check that maxlength <= 255 if using older MySQL versions.\n if settings.DATABASE_ENGINE == 'mysql':\n db_version = connection.get_server_version()\n if db_version < (5, 0, 3) and isinstance(f, (models.CharField, models.CommaSeparatedIntegerField, models.SlugField)) and f.maxlength > 255:\n e.add(opts, '\"%s\": %s cannot have a \"maxlength\" greater than 255 when you are using a version of MySQL prior to 5.0.3 (you are using %s).' % (f.name, f.__class__.__name__, '.'.join([str(n) for n in db_version[:3]])))\n\n # Check to see if the related field will clash with any\n # existing fields, m2m fields, m2m related objects or related objects\n if f.rel:\n rel_opts = f.rel.to._meta\n if f.rel.to not in models.get_models():\n e.add(opts, \"'%s' has relation with model %s, which has not been installed\" % (f.name, rel_opts.object_name))\n\n rel_name = RelatedObject(f.rel.to, cls, f).get_accessor_name()\n rel_query_name = f.related_query_name()\n for r in rel_opts.fields:\n if r.name == rel_name:\n e.add(opts, \"Accessor for field '%s' clashes with field '%s.%s'. Add a related_name argument to the definition for '%s'.\" % (f.name, rel_opts.object_name, r.name, f.name))\n if r.name == rel_query_name:\n e.add(opts, \"Reverse query name for field '%s' clashes with field '%s.%s'. Add a related_name argument to the definition for '%s'.\" % (f.name, rel_opts.object_name, r.name, f.name))\n for r in rel_opts.many_to_many:\n if r.name == rel_name:\n e.add(opts, \"Accessor for field '%s' clashes with m2m field '%s.%s'. Add a related_name argument to the definition for '%s'.\" % (f.name, rel_opts.object_name, r.name, f.name))\n if r.name == rel_query_name:\n e.add(opts, \"Reverse query name for field '%s' clashes with m2m field '%s.%s'. Add a related_name argument to the definition for '%s'.\" % (f.name, rel_opts.object_name, r.name, f.name))\n for r in rel_opts.get_all_related_many_to_many_objects():\n if r.get_accessor_name() == rel_name:\n e.add(opts, \"Accessor for field '%s' clashes with related m2m field '%s.%s'. Add a related_name argument to the definition for '%s'.\" % (f.name, rel_opts.object_name, r.get_accessor_name(), f.name))\n if r.get_accessor_name() == rel_query_name:\n e.add(opts, \"Reverse query name for field '%s' clashes with related m2m field '%s.%s'. Add a related_name argument to the definition for '%s'.\" % (f.name, rel_opts.object_name, r.get_accessor_name(), f.name))\n for r in rel_opts.get_all_related_objects():\n if r.field is not f:\n if r.get_accessor_name() == rel_name:\n e.add(opts, \"Accessor for field '%s' clashes with related field '%s.%s'. Add a related_name argument to the definition for '%s'.\" % (f.name, rel_opts.object_name, r.get_accessor_name(), f.name))\n if r.get_accessor_name() == rel_query_name:\n e.add(opts, \"Reverse query name for field '%s' clashes with related field '%s.%s'. Add a related_name argument to the definition for '%s'.\" % (f.name, rel_opts.object_name, r.get_accessor_name(), f.name))\n\n\n for i, f in enumerate(opts.many_to_many):\n # Check to see if the related m2m field will clash with any\n # existing fields, m2m fields, m2m related objects or related objects\n rel_opts = f.rel.to._meta\n if f.rel.to not in models.get_models():\n e.add(opts, \"'%s' has m2m relation with model %s, which has not been installed\" % (f.name, rel_opts.object_name))\n\n rel_name = RelatedObject(f.rel.to, cls, f).get_accessor_name()\n rel_query_name = f.related_query_name()\n # If rel_name is none, there is no reverse accessor.\n # (This only occurs for symmetrical m2m relations to self).\n # If this is the case, there are no clashes to check for this field, as\n # there are no reverse descriptors for this field.\n if rel_name is not None:\n for r in rel_opts.fields:\n if r.name == rel_name:\n e.add(opts, \"Accessor for m2m field '%s' clashes with field '%s.%s'. Add a related_name argument to the definition for '%s'.\" % (f.name, rel_opts.object_name, r.name, f.name))\n if r.name == rel_query_name:\n e.add(opts, \"Reverse query name for m2m field '%s' clashes with field '%s.%s'. Add a related_name argument to the definition for '%s'.\" % (f.name, rel_opts.object_name, r.name, f.name))\n for r in rel_opts.many_to_many:\n if r.name == rel_name:\n e.add(opts, \"Accessor for m2m field '%s' clashes with m2m field '%s.%s'. Add a related_name argument to the definition for '%s'.\" % (f.name, rel_opts.object_name, r.name, f.name))\n if r.name == rel_query_name:\n e.add(opts, \"Reverse query name for m2m field '%s' clashes with m2m field '%s.%s'. Add a related_name argument to the definition for '%s'.\" % (f.name, rel_opts.object_name, r.name, f.name))\n for r in rel_opts.get_all_related_many_to_many_objects():\n if r.field is not f:\n if r.get_accessor_name() == rel_name:\n e.add(opts, \"Accessor for m2m field '%s' clashes with related m2m field '%s.%s'. Add a related_name argument to the definition for '%s'.\" % (f.name, rel_opts.object_name, r.get_accessor_name(), f.name))\n if r.get_accessor_name() == rel_query_name:\n e.add(opts, \"Reverse query name for m2m field '%s' clashes with related m2m field '%s.%s'. Add a related_name argument to the definition for '%s'.\" % (f.name, rel_opts.object_name, r.get_accessor_name(), f.name))\n for r in rel_opts.get_all_related_objects():\n if r.get_accessor_name() == rel_name:\n e.add(opts, \"Accessor for m2m field '%s' clashes with related field '%s.%s'. Add a related_name argument to the definition for '%s'.\" % (f.name, rel_opts.object_name, r.get_accessor_name(), f.name))\n if r.get_accessor_name() == rel_query_name:\n e.add(opts, \"Reverse query name for m2m field '%s' clashes with related field '%s.%s'. Add a related_name argument to the definition for '%s'.\" % (f.name, rel_opts.object_name, r.get_accessor_name(), f.name))\n\n # Check admin attribute.\n if opts.admin is not None:\n if not isinstance(opts.admin, models.AdminOptions):\n e.add(opts, '\"admin\" attribute, if given, must be set to a models.AdminOptions() instance.')\n else:\n # list_display\n if not isinstance(opts.admin.list_display, (list, tuple)):\n e.add(opts, '\"admin.list_display\", if given, must be set to a list or tuple.')\n else:\n for fn in opts.admin.list_display:\n try:\n f = opts.get_field(fn)\n except models.FieldDoesNotExist:\n if not hasattr(cls, fn):\n e.add(opts, '\"admin.list_display\" refers to %r, which isn\\'t an attribute, method or property.' % fn)\n else:\n if isinstance(f, models.ManyToManyField):\n e.add(opts, '\"admin.list_display\" doesn\\'t support ManyToManyFields (%r).' % fn)\n # list_display_links\n if opts.admin.list_display_links and not opts.admin.list_display:\n e.add(opts, '\"admin.list_display\" must be defined for \"admin.list_display_links\" to be used.')\n if not isinstance(opts.admin.list_display_links, (list, tuple)):\n e.add(opts, '\"admin.list_display_links\", if given, must be set to a list or tuple.')\n else:\n for fn in opts.admin.list_display_links:\n try:\n f = opts.get_field(fn)\n except models.FieldDoesNotExist:\n if not hasattr(cls, fn):\n e.add(opts, '\"admin.list_display_links\" refers to %r, which isn\\'t an attribute, method or property.' % fn)\n if fn not in opts.admin.list_display:\n e.add(opts, '\"admin.list_display_links\" refers to %r, which is not defined in \"admin.list_display\".' % fn)\n # list_filter\n if not isinstance(opts.admin.list_filter, (list, tuple)):\n e.add(opts, '\"admin.list_filter\", if given, must be set to a list or tuple.')\n else:\n for fn in opts.admin.list_filter:\n try:\n f = opts.get_field(fn)\n except models.FieldDoesNotExist:\n e.add(opts, '\"admin.list_filter\" refers to %r, which isn\\'t a field.' % fn)\n # date_hierarchy\n if opts.admin.date_hierarchy:\n try:\n f = opts.get_field(opts.admin.date_hierarchy)\n except models.FieldDoesNotExist:\n e.add(opts, '\"admin.date_hierarchy\" refers to %r, which isn\\'t a field.' % opts.admin.date_hierarchy)\n\n # Check ordering attribute.\n if opts.ordering:\n for field_name in opts.ordering:\n if field_name == '?': continue\n if field_name.startswith('-'):\n field_name = field_name[1:]\n if opts.order_with_respect_to and field_name == '_order':\n continue\n if '.' in field_name: continue # Skip ordering in the format 'table.field'.\n try:\n opts.get_field(field_name, many_to_many=False)\n except models.FieldDoesNotExist:\n e.add(opts, '\"ordering\" refers to \"%s\", a field that doesn\\'t exist.' % field_name)\n\n # Check core=True, if needed.\n for related in opts.get_followed_related_objects():\n if not related.edit_inline:\n continue\n try:\n for f in related.opts.fields:\n if f.core:\n raise StopIteration\n e.add(related.opts, \"At least one field in %s should have core=True, because it's being edited inline by %s.%s.\" % (related.opts.object_name, opts.module_name, opts.object_name))\n except StopIteration:\n pass\n\n # Check unique_together.\n for ut in opts.unique_together:\n for field_name in ut:\n try:\n f = opts.get_field(field_name, many_to_many=True)\n except models.FieldDoesNotExist:\n e.add(opts, '\"unique_together\" refers to %s, a field that doesn\\'t exist. Check your syntax.' % field_name)\n else:\n if isinstance(f.rel, models.ManyToManyRel):\n e.add(opts, '\"unique_together\" refers to %s. ManyToManyFields are not supported in unique_together.' % f.name)\n\n return len(e.errors)", "metadata": "root.get_validation_errors", "header": "['module', '___EOS___']", "index": 938 } ]
[ { "span": "f ", "start_line": 1087, "start_column": 28, "end_line": 1087, "end_column": 29 }, { "span": "f ", "start_line": 1099, "start_column": 28, "end_line": 1099, "end_column": 29 }, { "span": "f ", "start_line": 1105, "start_column": 24, "end_line": 1105, "end_column": 25 } ]
[]
1
true
[ "[CLS]_", "Variable_", "defined_", "multiple_", "times_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "get", "\\u", "validation", "\\u", "errors_", "(_", "outfile_", ",_", "app_", "=_", "None_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Validate", "s", " ", "all", " ", "model", "s", " ", "tha", "t", " ", "are", " ", "part", " ", "of", " ", "the", " ", "specified", " ", "app", ".", " ", "If", " ", "no", " ", "app", " ", "name", " ", "is", " ", "provided", ",", "\\", "10", ";", " ", " ", " ", " ", "validates", " ", "all", " ", "model", "s", " ", "of", " ", "all", " ", "install", "ed", " ", "apps", ".", " ", "Write", "s", " ", "error", "s", ",", " ", "if", " ", "any", ",", " ", "to", " ", "outfile", ".", "\\", "10", ";", " ", " ", " ", " ", "Return", "s", " ", "number", " ", "of", " ", "error", "s", ".", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "django_", "._", "conf_", "import_", "settings_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "django_", "._", "db_", "import_", "models_", ",_", "connection_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "django_", "._", "db_", "._", "models_", "._", "loading_", "import_", "get", "\\u", "app", "\\u", "errors_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "django_", "._", "db_", "._", "models_", "._", "fields_", "._", "related_", "import_", "Rela", "ted", "Object_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "e_", "=_", "Model", "Error", "Collection_", "(_", "outfile_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "for_", "(_", "app", "\\u", "name_", ",_", "error_", ")_", "in_", "get", "\\u", "app", "\\u", "errors_", "(_", ")_", "._", "items_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "e_", "._", "add_", "(_", "app", "\\u", "name_", ",_", "error_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "for_", "cls_", "in_", "models_", "._", "get", "\\u", "models_", "(_", "app_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "opts_", "=_", "cls_", "._", "\\u", "meta_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Do", " ", "field", "-", "specific", " ", "validation", "._", "\\u\\u\\uNL\\u\\u\\u_", "for_", "f_", "in_", "opts_", "._", "fields_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "f_", "._", "name_", "==_", "'", "id", "'_", "and_", "not_", "f_", "._", "primary", "\\u", "key_", "and_", "opts_", "._", "pk_", "._", "name_", "==_", "'", "id", "'_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "e_", "._", "add_", "(_", "opts_", ",_", "'\"", "%", "s", "\":", " ", "You", " ", "can", "\\\\'", "t", " ", "use", " ", "\"", "id", "\"", " ", "as", " ", "a", " ", "field", " ", "name", ",", " ", "bec", "aus", "e", " ", "each", " ", "model", " ", "automati", "call", "y", " ", "gets", " ", "an", " ", "\"", "id", "\"", " ", "field", " ", "if", " ", "none", " ", "of", " ", "the", " ", "fields", " ", "have", " ", "primary", "\\u", "key", "=", "Tru", "e", ".", " ", "You", " ", "need", " ", "to", " ", "eit", "her", " ", "remove", "/", "rename", " ", "your", " ", "\"", "id", "\"", " ", "field", " ", "or", " ", "add", " ", "primary", "\\u", "key", "=", "Tru", "e", " ", "to", " ", "a", " ", "field", ".'_", "%_", "f_", "._", "name_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "isinstance_", "(_", "f_", ",_", "models_", "._", "Char", "Field_", ")_", "and_", "f_", "._", "maxlength", "_", "in_", "(_", "None_", ",_", "0_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "e_", "._", "add_", "(_", "opts_", ",_", "'\"", "%", "s", "\":", " ", "Char", "Field", "s", " ", "require", " ", "a", " ", "\"", "maxlength", "\"", " ", "attribute", ".'_", "%_", "f_", "._", "name_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "isinstance_", "(_", "f_", ",_", "models_", "._", "Float", "Field_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "f_", "._", "decima", "l\\u", "places_", "is_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "e_", "._", "add_", "(_", "opts_", ",_", "'\"", "%", "s", "\":", " ", "Float", "Field", "s", " ", "require", " ", "a", " ", "\"", "decima", "l\\u", "place", "s", "\"", " ", "attribute", ".'_", "%_", "f_", "._", "name_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "f_", "._", "max", "\\u", "digits_", "is_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "e_", "._", "add_", "(_", "opts_", ",_", "'\"", "%", "s", "\":", " ", "Float", "Field", "s", " ", "require", " ", "a", " ", "\"", "max", "\\u", "digit", "s", "\"", " ", "attribute", ".'_", "%_", "f_", "._", "name_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "isinstance_", "(_", "f_", ",_", "models_", "._", "File", "Field_", ")_", "and_", "not_", "f_", "._", "upload", "\\u", "to_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "e_", "._", "add_", "(_", "opts_", ",_", "'\"", "%", "s", "\":", " ", "File", "Field", "s", " ", "require", " ", "an", " ", "\"", "upload", "\\u", "to", "\"", " ", "attribute", ".'_", "%_", "f_", "._", "name_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "isinstance_", "(_", "f_", ",_", "models_", "._", "Image", "Field_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "from_", "PIL_", "import_", "Image_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "Import", "Error_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "e_", "._", "add_", "(_", "opts_", ",_", "'\"", "%", "s", "\":", " ", "To", " ", "use", " ", "Image", "Field", "s", ",", " ", "you", " ", "need", " ", "to", " ", "install", " ", "the", " ", "Pyth", "on", " ", "Imagin", "g", " ", "Libr", "ary", ".", " ", "Get", " ", "it", " ", "at", " ", "http", "://", "www", ".", "python", "ware", ".", "com", "/", "products", "/", "pil", "/", " ", ".'_", "%_", "f_", "._", "name_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "f_", "._", "prepo", "pulat", "e\\u", "from_", "is_", "not_", "None_", "and_", "type_", "(_", "f_", "._", "prepo", "pulat", "e\\u", "from_", ")_", "not_", "in_", "(_", "list_", ",_", "tuple_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "e_", "._", "add_", "(_", "opts_", ",_", "'\"", "%", "s", "\":", " ", "prepo", "pulat", "e\\u", "from", " ", "shou", "ld", " ", "be", " ", "a", " ", "list", " ", "or", " ", "tuple", ".'_", "%_", "f_", "._", "name_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "f_", "._", "choices_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "not_", "hasattr_", "(_", "f_", "._", "choices_", ",_", "'\\u", "\\u", "iter", "\\u\\u'_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "e_", "._", "add_", "(_", "opts_", ",_", "'\"", "%", "s", "\":", " ", "\"", "choice", "s", "\"", " ", "shou", "ld", " ", "be", " ", "iterable", " ", "(", "e", ".", "g", ".,", " ", "a", " ", "tuple", " ", "or", " ", "list", ").'_", "%_", "f_", "._", "name_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "for_", "c_", "in_", "f_", "._", "choices_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "if_", "not_", "type_", "(_", "c_", ")_", "in_", "(_", "tuple_", ",_", "list_", ")_", "or_", "len_", "(_", "c_", ")_", "!=_", "2_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "e_", "._", "add_", "(_", "opts_", ",_", "'\"", "%", "s", "\":", " ", "\"", "choice", "s", "\"", " ", "shou", "ld", " ", "be", " ", "a", " ", "sequence", " ", "of", " ", "two", "-", "tuple", "s", ".'_", "%_", "f_", "._", "name_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "f_", "._", "db", "\\u", "index_", "not_", "in_", "(_", "None_", ",_", "True_", ",_", "False_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "e_", "._", "add_", "(_", "opts_", ",_", "'\"", "%", "s", "\":", " ", "\"", "db", "\\u", "index", "\"", " ", "shou", "ld", " ", "be", " ", "eit", "her", " ", "Non", "e", ",", " ", "Tru", "e", " ", "or", " ", "Fal", "se", ".'_", "%_", "f_", "._", "name_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Check", " ", "tha", "t", " ", "maxlength", " ", "<=", " ", "255", " ", "if", " ", "usi", "ng", " ", "older", " ", "My", "SQL", " ", "version", "s", "._", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "settings_", "._", "DATA", "BASE", "\\u", "ENGINE_", "==_", "'", "mysql", "'_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "db", "\\u", "version_", "=_", "connection_", "._", "get", "\\u", "server", "\\u", "version_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "db", "\\u", "version_", "<_", "(_", "5_", ",_", "0_", ",_", "3_", ")_", "and_", "isinstance_", "(_", "f_", ",_", "(_", "models_", "._", "Char", "Field_", ",_", "models_", "._", "Comm", "a", "Separate", "d", "Integer", "Field_", ",_", "models_", "._", "Sl", "ug", "Field_", ")_", ")_", "and_", "f_", "._", "maxlength", "_", ">_", "255_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "e_", "._", "add_", "(_", "opts_", ",_", "'\"", "%", "s", "\":", " ", "%", "s", " ", "cann", "ot", " ", "have", " ", "a", " ", "\"", "maxlength", "\"", " ", "great", "er", " ", "than", " ", "255", " ", "whe", "n", " ", "you", " ", "are", " ", "usi", "ng", " ", "a", " ", "version", " ", "of", " ", "My", "SQL", " ", "prior", " ", "to", " ", "5.0", ".3", " ", "(", "you", " ", "are", " ", "usi", "ng", " ", "%", "s", ").'_", "%_", "(_", "f_", "._", "name_", ",_", "f_", "._", "\\u\\u", "class\\u\\u_", "._", "\\u\\u", "name\\u\\u_", ",_", "'.'_", "._", "join_", "(_", "[_", "str_", "(_", "n_", ")_", "for_", "n_", "in_", "db", "\\u", "version_", "[_", ":_", "3_", "]_", "]_", ")_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Check", " ", "to", " ", "see", " ", "if", " ", "the", " ", "relate", "d", " ", "field", " ", "will", " ", "clas", "h", " ", "with", " ", "any_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "exist", "ing", " ", "fields", ",", " ", "m2", "m", " ", "fields", ",", " ", "m2", "m", " ", "relate", "d", " ", "object", "s", " ", "or", " ", "relate", "d", " ", "objects_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "f_", "._", "rel_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "rel", "\\u", "opts_", "=_", "f_", "._", "rel_", "._", "to_", "._", "\\u", "meta_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "f_", "._", "rel_", "._", "to_", "not_", "in_", "models_", "._", "get", "\\u", "models_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "e_", "._", "add_", "(_", "opts_", ",_", "\"'", "%", "s", "'", " ", "has", " ", "relation", " ", "with", " ", "model", " ", "%", "s", ",", " ", "whi", "ch", " ", "has", " ", "not", " ", "bee", "n", " ", "install", "ed", "\"_", "%_", "(_", "f_", "._", "name_", ",_", "rel", "\\u", "opts_", "._", "object\\u", "name_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "rel", "\\u", "name_", "=_", "Rela", "ted", "Object_", "(_", "f_", "._", "rel_", "._", "to_", ",_", "cls_", ",_", "f_", ")_", "._", "get", "\\u", "accessor", "\\u", "name_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "rel", "\\u", "query", "\\u", "name_", "=_", "f_", "._", "relate", "d\\u", "query", "\\u", "name_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "r_", "in_", "rel", "\\u", "opts_", "._", "fields_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "if_", "r_", "._", "name_", "==_", "rel", "\\u", "name_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "e_", "._", "add_", "(_", "opts_", ",_", "\"", "Accessor", " ", "for", " ", "field", " ", "'%", "s", "'", " ", "clas", "hes", " ", "with", " ", "field", " ", "'%", "s", ".", "%", "s", "'.", " ", "Add", " ", "a", " ", "relate", "d\\u", "name", " ", "argu", "ment", " ", "to", " ", "the", " ", "definit", "ion", " ", "for", " ", "'%", "s", "'.\"_", "%_", "(_", "f_", "._", "name_", ",_", "rel", "\\u", "opts_", "._", "object\\u", "name_", ",_", "r_", "._", "name_", ",_", "f_", "._", "name_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "r_", "._", "name_", "==_", "rel", "\\u", "query", "\\u", "name_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "e_", "._", "add_", "(_", "opts_", ",_", "\"", "Revers", "e", " ", "query", " ", "name", " ", "for", " ", "field", " ", "'%", "s", "'", " ", "clas", "hes", " ", "with", " ", "field", " ", "'%", "s", ".", "%", "s", "'.", " ", "Add", " ", "a", " ", "relate", "d\\u", "name", " ", "argu", "ment", " ", "to", " ", "the", " ", "definit", "ion", " ", "for", " ", "'%", "s", "'.\"_", "%_", "(_", "f_", "._", "name_", ",_", "rel", "\\u", "opts_", "._", "object\\u", "name_", ",_", "r_", "._", "name_", ",_", "f_", "._", "name_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "for_", "r_", "in_", "rel", "\\u", "opts_", "._", "many", "\\u", "to", "\\u", "many_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "if_", "r_", "._", "name_", "==_", "rel", "\\u", "name_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "e_", "._", "add_", "(_", "opts_", ",_", "\"", "Accessor", " ", "for", " ", "field", " ", "'%", "s", "'", " ", "clas", "hes", " ", "with", " ", "m2", "m", " ", "field", " ", "'%", "s", ".", "%", "s", "'.", " ", "Add", " ", "a", " ", "relate", "d\\u", "name", " ", "argu", "ment", " ", "to", " ", "the", " ", "definit", "ion", " ", "for", " ", "'%", "s", "'.\"_", "%_", "(_", "f_", "._", "name_", ",_", "rel", "\\u", "opts_", "._", "object\\u", "name_", ",_", "r_", "._", "name_", ",_", "f_", "._", "name_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "r_", "._", "name_", "==_", "rel", "\\u", "query", "\\u", "name_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "e_", "._", "add_", "(_", "opts_", ",_", "\"", "Revers", "e", " ", "query", " ", "name", " ", "for", " ", "field", " ", "'%", "s", "'", " ", "clas", "hes", " ", "with", " ", "m2", "m", " ", "field", " ", "'%", "s", ".", "%", "s", "'.", " ", "Add", " ", "a", " ", "relate", "d\\u", "name", " ", "argu", "ment", " ", "to", " ", "the", " ", "definit", "ion", " ", "for", " ", "'%", "s", "'.\"_", "%_", "(_", "f_", "._", "name_", ",_", "rel", "\\u", "opts_", "._", "object\\u", "name_", ",_", "r_", "._", "name_", ",_", "f_", "._", "name_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "for_", "r_", "in_", "rel", "\\u", "opts_", "._", "get", "\\u", "all", "\\u", "relate", "d\\u", "many", "\\u", "to", "\\u", "many", "\\u", "objects_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "if_", "r_", "._", "get", "\\u", "accessor", "\\u", "name_", "(_", ")_", "==_", "rel", "\\u", "name_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "e_", "._", "add_", "(_", "opts_", ",_", "\"", "Accessor", " ", "for", " ", "field", " ", "'%", "s", "'", " ", "clas", "hes", " ", "with", " ", "relate", "d", " ", "m2", "m", " ", "field", " ", "'%", "s", ".", "%", "s", "'.", " ", "Add", " ", "a", " ", "relate", "d\\u", "name", " ", "argu", "ment", " ", "to", " ", "the", " ", "definit", "ion", " ", "for", " ", "'%", "s", "'.\"_", "%_", "(_", "f_", "._", "name_", ",_", "rel", "\\u", "opts_", "._", "object\\u", "name_", ",_", "r_", "._", "get", "\\u", "accessor", "\\u", "name_", "(_", ")_", ",_", "f_", "._", "name_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "r_", "._", "get", "\\u", "accessor", "\\u", "name_", "(_", ")_", "==_", "rel", "\\u", "query", "\\u", "name_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "e_", "._", "add_", "(_", "opts_", ",_", "\"", "Revers", "e", " ", "query", " ", "name", " ", "for", " ", "field", " ", "'%", "s", "'", " ", "clas", "hes", " ", "with", " ", "relate", "d", " ", "m2", "m", " ", "field", " ", "'%", "s", ".", "%", "s", "'.", " ", "Add", " ", "a", " ", "relate", "d\\u", "name", " ", "argu", "ment", " ", "to", " ", "the", " ", "definit", "ion", " ", "for", " ", "'%", "s", "'.\"_", "%_", "(_", "f_", "._", "name_", ",_", "rel", "\\u", "opts_", "._", "object\\u", "name_", ",_", "r_", "._", "get", "\\u", "accessor", "\\u", "name_", "(_", ")_", ",_", "f_", "._", "name_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "for_", "r_", "in_", "rel", "\\u", "opts_", "._", "get", "\\u", "all", "\\u", "relate", "d\\u", "objects_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "if_", "r_", "._", "field_", "is_", "not_", "f_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "if_", "r_", "._", "get", "\\u", "accessor", "\\u", "name_", "(_", ")_", "==_", "rel", "\\u", "name_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "e_", "._", "add_", "(_", "opts_", ",_", "\"", "Accessor", " ", "for", " ", "field", " ", "'%", "s", "'", " ", "clas", "hes", " ", "with", " ", "relate", "d", " ", "field", " ", "'%", "s", ".", "%", "s", "'.", " ", "Add", " ", "a", " ", "relate", "d\\u", "name", " ", "argu", "ment", " ", "to", " ", "the", " ", "definit", "ion", " ", "for", " ", "'%", "s", "'.\"_", "%_", "(_", "f_", "._", "name_", ",_", "rel", "\\u", "opts_", "._", "object\\u", "name_", ",_", "r_", "._", "get", "\\u", "accessor", "\\u", "name_", "(_", ")_", ",_", "f_", "._", "name_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "r_", "._", "get", "\\u", "accessor", "\\u", "name_", "(_", ")_", "==_", "rel", "\\u", "query", "\\u", "name_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "e_", "._", "add_", "(_", "opts_", ",_", "\"", "Revers", "e", " ", "query", " ", "name", " ", "for", " ", "field", " ", "'%", "s", "'", " ", "clas", "hes", " ", "with", " ", "relate", "d", " ", "field", " ", "'%", "s", ".", "%", "s", "'.", " ", "Add", " ", "a", " ", "relate", "d\\u", "name", " ", "argu", "ment", " ", "to", " ", "the", " ", "definit", "ion", " ", "for", " ", "'%", "s", "'.\"_", "%_", "(_", "f_", "._", "name_", ",_", "rel", "\\u", "opts_", "._", "object\\u", "name_", ",_", "r_", "._", "get", "\\u", "accessor", "\\u", "name_", "(_", ")_", ",_", "f_", "._", "name_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "for_", "i_", ",_", "f_", "in_", "enumerate_", "(_", "opts_", "._", "many", "\\u", "to", "\\u", "many_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Check", " ", "to", " ", "see", " ", "if", " ", "the", " ", "relate", "d", " ", "m2", "m", " ", "field", " ", "will", " ", "clas", "h", " ", "with", " ", "any_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "exist", "ing", " ", "fields", ",", " ", "m2", "m", " ", "fields", ",", " ", "m2", "m", " ", "relate", "d", " ", "object", "s", " ", "or", " ", "relate", "d", " ", "objects_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "rel", "\\u", "opts_", "=_", "f_", "._", "rel_", "._", "to_", "._", "\\u", "meta_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "f_", "._", "rel_", "._", "to_", "not_", "in_", "models_", "._", "get", "\\u", "models_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "e_", "._", "add_", "(_", "opts_", ",_", "\"'", "%", "s", "'", " ", "has", " ", "m2", "m", " ", "relation", " ", "with", " ", "model", " ", "%", "s", ",", " ", "whi", "ch", " ", "has", " ", "not", " ", "bee", "n", " ", "install", "ed", "\"_", "%_", "(_", "f_", "._", "name_", ",_", "rel", "\\u", "opts_", "._", "object\\u", "name_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "rel", "\\u", "name_", "=_", "Rela", "ted", "Object_", "(_", "f_", "._", "rel_", "._", "to_", ",_", "cls_", ",_", "f_", ")_", "._", "get", "\\u", "accessor", "\\u", "name_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "rel", "\\u", "query", "\\u", "name_", "=_", "f_", "._", "relate", "d\\u", "query", "\\u", "name_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "If", " ", "rel", "\\u", "name", " ", "is", " ", "none", ",", " ", "there", " ", "is", " ", "no", " ", "reverse", " ", "accessor", "._", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "(", "Thi", "s", " ", "only", " ", "occur", "s", " ", "for", " ", "symmetric", "al", " ", "m2", "m", " ", "relation", "s", " ", "to", " ", "self", ").", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "If", " ", "this", " ", "is", " ", "the", " ", "case", ",", " ", "there", " ", "are", " ", "no", " ", "clas", "hes", " ", "to", " ", "check", " ", "for", " ", "this", " ", "field", ",", " ", "as_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "there", " ", "are", " ", "no", " ", "reverse", " ", "descrip", "tors", " ", "for", " ", "this", " ", "field", "._", "\\u\\u\\uNL\\u\\u\\u_", "if_", "rel", "\\u", "name_", "is_", "not_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "for_", "r_", "in_", "rel", "\\u", "opts_", "._", "fields_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "if_", "r_", "._", "name_", "==_", "rel", "\\u", "name_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "e_", "._", "add_", "(_", "opts_", ",_", "\"", "Accessor", " ", "for", " ", "m2", "m", " ", "field", " ", "'%", "s", "'", " ", "clas", "hes", " ", "with", " ", "field", " ", "'%", "s", ".", "%", "s", "'.", " ", "Add", " ", "a", " ", "relate", "d\\u", "name", " ", "argu", "ment", " ", "to", " ", "the", " ", "definit", "ion", " ", "for", " ", "'%", "s", "'.\"_", "%_", "(_", "f_", "._", "name_", ",_", "rel", "\\u", "opts_", "._", "object\\u", "name_", ",_", "r_", "._", "name_", ",_", "f_", "._", "name_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "r_", "._", "name_", "==_", "rel", "\\u", "query", "\\u", "name_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "e_", "._", "add_", "(_", "opts_", ",_", "\"", "Revers", "e", " ", "query", " ", "name", " ", "for", " ", "m2", "m", " ", "field", " ", "'%", "s", "'", " ", "clas", "hes", " ", "with", " ", "field", " ", "'%", "s", ".", "%", "s", "'.", " ", "Add", " ", "a", " ", "relate", "d\\u", "name", " ", "argu", "ment", " ", "to", " ", "the", " ", "definit", "ion", " ", "for", " ", "'%", "s", "'.\"_", "%_", "(_", "f_", "._", "name_", ",_", "rel", "\\u", "opts_", "._", "object\\u", "name_", ",_", "r_", "._", "name_", ",_", "f_", "._", "name_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "for_", "r_", "in_", "rel", "\\u", "opts_", "._", "many", "\\u", "to", "\\u", "many_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "if_", "r_", "._", "name_", "==_", "rel", "\\u", "name_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "e_", "._", "add_", "(_", "opts_", ",_", "\"", "Accessor", " ", "for", " ", "m2", "m", " ", "field", " ", "'%", "s", "'", " ", "clas", "hes", " ", "with", " ", "m2", "m", " ", "field", " ", "'%", "s", ".", "%", "s", "'.", " ", "Add", " ", "a", " ", "relate", "d\\u", "name", " ", "argu", "ment", " ", "to", " ", "the", " ", "definit", "ion", " ", "for", " ", "'%", "s", "'.\"_", "%_", "(_", "f_", "._", "name_", ",_", "rel", "\\u", "opts_", "._", "object\\u", "name_", ",_", "r_", "._", "name_", ",_", "f_", "._", "name_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "r_", "._", "name_", "==_", "rel", "\\u", "query", "\\u", "name_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "e_", "._", "add_", "(_", "opts_", ",_", "\"", "Revers", "e", " ", "query", " ", "name", " ", "for", " ", "m2", "m", " ", "field", " ", "'%", "s", "'", " ", "clas", "hes", " ", "with", " ", "m2", "m", " ", "field", " ", "'%", "s", ".", "%", "s", "'.", " ", "Add", " ", "a", " ", "relate", "d\\u", "name", " ", "argu", "ment", " ", "to", " ", "the", " ", "definit", "ion", " ", "for", " ", "'%", "s", "'.\"_", "%_", "(_", "f_", "._", "name_", ",_", "rel", "\\u", "opts_", "._", "object\\u", "name_", ",_", "r_", "._", "name_", ",_", "f_", "._", "name_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "for_", "r_", "in_", "rel", "\\u", "opts_", "._", "get", "\\u", "all", "\\u", "relate", "d\\u", "many", "\\u", "to", "\\u", "many", "\\u", "objects_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "if_", "r_", "._", "field_", "is_", "not_", "f_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "if_", "r_", "._", "get", "\\u", "accessor", "\\u", "name_", "(_", ")_", "==_", "rel", "\\u", "name_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "e_", "._", "add_", "(_", "opts_", ",_", "\"", "Accessor", " ", "for", " ", "m2", "m", " ", "field", " ", "'%", "s", "'", " ", "clas", "hes", " ", "with", " ", "relate", "d", " ", "m2", "m", " ", "field", " ", "'%", "s", ".", "%", "s", "'.", " ", "Add", " ", "a", " ", "relate", "d\\u", "name", " ", "argu", "ment", " ", "to", " ", "the", " ", "definit", "ion", " ", "for", " ", "'%", "s", "'.\"_", "%_", "(_", "f_", "._", "name_", ",_", "rel", "\\u", "opts_", "._", "object\\u", "name_", ",_", "r_", "._", "get", "\\u", "accessor", "\\u", "name_", "(_", ")_", ",_", "f_", "._", "name_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "r_", "._", "get", "\\u", "accessor", "\\u", "name_", "(_", ")_", "==_", "rel", "\\u", "query", "\\u", "name_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "e_", "._", "add_", "(_", "opts_", ",_", "\"", "Revers", "e", " ", "query", " ", "name", " ", "for", " ", "m2", "m", " ", "field", " ", "'%", "s", "'", " ", "clas", "hes", " ", "with", " ", "relate", "d", " ", "m2", "m", " ", "field", " ", "'%", "s", ".", "%", "s", "'.", " ", "Add", " ", "a", " ", "relate", "d\\u", "name", " ", "argu", "ment", " ", "to", " ", "the", " ", "definit", "ion", " ", "for", " ", "'%", "s", "'.\"_", "%_", "(_", "f_", "._", "name_", ",_", "rel", "\\u", "opts_", "._", "object\\u", "name_", ",_", "r_", "._", "get", "\\u", "accessor", "\\u", "name_", "(_", ")_", ",_", "f_", "._", "name_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "for_", "r_", "in_", "rel", "\\u", "opts_", "._", "get", "\\u", "all", "\\u", "relate", "d\\u", "objects_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "if_", "r_", "._", "get", "\\u", "accessor", "\\u", "name_", "(_", ")_", "==_", "rel", "\\u", "name_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "e_", "._", "add_", "(_", "opts_", ",_", "\"", "Accessor", " ", "for", " ", "m2", "m", " ", "field", " ", "'%", "s", "'", " ", "clas", "hes", " ", "with", " ", "relate", "d", " ", "field", " ", "'%", "s", ".", "%", "s", "'.", " ", "Add", " ", "a", " ", "relate", "d\\u", "name", " ", "argu", "ment", " ", "to", " ", "the", " ", "definit", "ion", " ", "for", " ", "'%", "s", "'.\"_", "%_", "(_", "f_", "._", "name_", ",_", "rel", "\\u", "opts_", "._", "object\\u", "name_", ",_", "r_", "._", "get", "\\u", "accessor", "\\u", "name_", "(_", ")_", ",_", "f_", "._", "name_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "r_", "._", "get", "\\u", "accessor", "\\u", "name_", "(_", ")_", "==_", "rel", "\\u", "query", "\\u", "name_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "e_", "._", "add_", "(_", "opts_", ",_", "\"", "Revers", "e", " ", "query", " ", "name", " ", "for", " ", "m2", "m", " ", "field", " ", "'%", "s", "'", " ", "clas", "hes", " ", "with", " ", "relate", "d", " ", "field", " ", "'%", "s", ".", "%", "s", "'.", " ", "Add", " ", "a", " ", "relate", "d\\u", "name", " ", "argu", "ment", " ", "to", " ", "the", " ", "definit", "ion", " ", "for", " ", "'%", "s", "'.\"_", "%_", "(_", "f_", "._", "name_", ",_", "rel", "\\u", "opts_", "._", "object\\u", "name_", ",_", "r_", "._", "get", "\\u", "accessor", "\\u", "name_", "(_", ")_", ",_", "f_", "._", "name_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Check", " ", "admin", " ", "attribute", "._", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "opts_", "._", "admin_", "is_", "not_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "not_", "isinstance_", "(_", "opts_", "._", "admin_", ",_", "models_", "._", "Admi", "n", "Options_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "e_", "._", "add_", "(_", "opts_", ",_", "'\"", "admin", "\"", " ", "attribute", ",", " ", "if", " ", "give", "n", ",", " ", "must", " ", "be", " ", "set", " ", "to", " ", "a", " ", "model", "s", ".", "Admi", "n", "Optio", "ns", "()", " ", "instance", ".'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "list", "\\u", "display_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "not_", "isinstance_", "(_", "opts_", "._", "admin_", "._", "list", "\\u", "display_", ",_", "(_", "list_", ",_", "tuple_", ")_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "e_", "._", "add_", "(_", "opts_", ",_", "'\"", "admin", ".", "list", "\\u", "display", "\",", " ", "if", " ", "give", "n", ",", " ", "must", " ", "be", " ", "set", " ", "to", " ", "a", " ", "list", " ", "or", " ", "tuple", ".'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "for_", "fn_", "in_", "opts_", "._", "admin_", "._", "list", "\\u", "display_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "f_", "=_", "opts_", "._", "get", "\\u", "field_", "(_", "fn_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "models_", "._", "Field", "Do", "es", "Not", "Exist_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "if_", "not_", "hasattr_", "(_", "cls_", ",_", "fn_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "e_", "._", "add_", "(_", "opts_", ",_", "'\"", "admin", ".", "list", "\\u", "display", "\"", " ", "refer", "s", " ", "to", " ", "%", "r", ",", " ", "whi", "ch", " ", "isn", "\\\\'", "t", " ", "an", " ", "attribute", ",", " ", "method", " ", "or", " ", "property", ".'_", "%_", "fn_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "if_", "isinstance_", "(_", "f_", ",_", "models_", "._", "Many", "To", "Many", "Field_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "e_", "._", "add_", "(_", "opts_", ",_", "'\"", "admin", ".", "list", "\\u", "display", "\"", " ", "doe", "sn", "\\\\'", "t", " ", "support", " ", "Many", "To", "Many", "Field", "s", " ", "(%", "r", ").'_", "%_", "fn_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "list", "\\u", "display", "\\u", "links_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "opts_", "._", "admin_", "._", "list", "\\u", "display", "\\u", "links_", "and_", "not_", "opts_", "._", "admin_", "._", "list", "\\u", "display_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "e_", "._", "add_", "(_", "opts_", ",_", "'\"", "admin", ".", "list", "\\u", "display", "\"", " ", "must", " ", "be", " ", "defin", "ed", " ", "for", " ", "\"", "admin", ".", "list", "\\u", "display", "\\u", "link", "s", "\"", " ", "to", " ", "be", " ", "used", ".'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "not_", "isinstance_", "(_", "opts_", "._", "admin_", "._", "list", "\\u", "display", "\\u", "links_", ",_", "(_", "list_", ",_", "tuple_", ")_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "e_", "._", "add_", "(_", "opts_", ",_", "'\"", "admin", ".", "list", "\\u", "display", "\\u", "link", "s", "\",", " ", "if", " ", "give", "n", ",", " ", "must", " ", "be", " ", "set", " ", "to", " ", "a", " ", "list", " ", "or", " ", "tuple", ".'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "for_", "fn_", "in_", "opts_", "._", "admin_", "._", "list", "\\u", "display", "\\u", "links_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "f_", "=_", "opts_", "._", "get", "\\u", "field_", "(_", "fn_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "models_", "._", "Field", "Do", "es", "Not", "Exist_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "if_", "not_", "hasattr_", "(_", "cls_", ",_", "fn_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "e_", "._", "add_", "(_", "opts_", ",_", "'\"", "admin", ".", "list", "\\u", "display", "\\u", "link", "s", "\"", " ", "refer", "s", " ", "to", " ", "%", "r", ",", " ", "whi", "ch", " ", "isn", "\\\\'", "t", " ", "an", " ", "attribute", ",", " ", "method", " ", "or", " ", "property", ".'_", "%_", "fn_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "fn_", "not_", "in_", "opts_", "._", "admin_", "._", "list", "\\u", "display_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "e_", "._", "add_", "(_", "opts_", ",_", "'\"", "admin", ".", "list", "\\u", "display", "\\u", "link", "s", "\"", " ", "refer", "s", " ", "to", " ", "%", "r", ",", " ", "whi", "ch", " ", "is", " ", "not", " ", "defin", "ed", " ", "in", " ", "\"", "admin", ".", "list", "\\u", "display", "\".'_", "%_", "fn_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "list", "\\u", "filter_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "not_", "isinstance_", "(_", "opts_", "._", "admin_", "._", "list", "\\u", "filter_", ",_", "(_", "list_", ",_", "tuple_", ")_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "e_", "._", "add_", "(_", "opts_", ",_", "'\"", "admin", ".", "list", "\\u", "filter", "\",", " ", "if", " ", "give", "n", ",", " ", "must", " ", "be", " ", "set", " ", "to", " ", "a", " ", "list", " ", "or", " ", "tuple", ".'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "for_", "fn_", "in_", "opts_", "._", "admin_", "._", "list", "\\u", "filter_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "f_", "=_", "opts_", "._", "get", "\\u", "field_", "(_", "fn_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "models_", "._", "Field", "Do", "es", "Not", "Exist_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "e_", "._", "add_", "(_", "opts_", ",_", "'\"", "admin", ".", "list", "\\u", "filter", "\"", " ", "refer", "s", " ", "to", " ", "%", "r", ",", " ", "whi", "ch", " ", "isn", "\\\\'", "t", " ", "a", " ", "field", ".'_", "%_", "fn_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "date", "\\u", "hierarchy_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "opts_", "._", "admin_", "._", "date", "\\u", "hierarchy_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "f_", "=_", "opts_", "._", "get", "\\u", "field_", "(_", "opts_", "._", "admin_", "._", "date", "\\u", "hierarchy_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "models_", "._", "Field", "Do", "es", "Not", "Exist_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "e_", "._", "add_", "(_", "opts_", ",_", "'\"", "admin", ".", "date", "\\u", "hier", "arch", "y", "\"", " ", "refer", "s", " ", "to", " ", "%", "r", ",", " ", "whi", "ch", " ", "isn", "\\\\'", "t", " ", "a", " ", "field", ".'_", "%_", "opts_", "._", "admin_", "._", "date", "\\u", "hierarchy_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Check", " ", "orderi", "ng", " ", "attribute", "._", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "opts_", "._", "ordering_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "for_", "field", "\\u", "name_", "in_", "opts_", "._", "ordering_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "field", "\\u", "name_", "==_", "'?'_", ":_", "continue_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "field", "\\u", "name_", "._", "startswith_", "(_", "'-'_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "field", "\\u", "name_", "=_", "field", "\\u", "name_", "[_", "1_", ":_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "opts_", "._", "order", "\\u", "with", "\\u", "respec", "t", "\\u", "to_", "and_", "field", "\\u", "name_", "==_", "'\\u", "order", "'_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "continue_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "'.'_", "in_", "field", "\\u", "name_", ":_", "continue_", "#", " ", "Ski", "p", " ", "orderi", "ng", " ", "in", " ", "the", " ", "format", " ", "'", "table", ".", "field", "'.", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "opts_", "._", "get", "\\u", "field_", "(_", "field", "\\u", "name_", ",_", "many", "\\u", "to", "\\u", "many_", "=_", "False_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "models_", "._", "Field", "Do", "es", "Not", "Exist_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "e_", "._", "add_", "(_", "opts_", ",_", "'\"", "orderi", "ng", "\"", " ", "refer", "s", " ", "to", " ", "\"%", "s", "\",", " ", "a", " ", "field", " ", "tha", "t", " ", "doe", "sn", "\\\\'", "t", " ", "exist", ".'_", "%_", "field", "\\u", "name_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Check", " ", "core", "=", "Tru", "e", ",", " ", "if", " ", "need", "ed", "._", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "for_", "related_", "in_", "opts_", "._", "get", "\\u", "followe", "d\\u", "relate", "d\\u", "objects_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "not_", "related_", "._", "edit", "\\u", "inline_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "continue_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "for_", "f_", "in_", "related_", "._", "opts_", "._", "fields_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "if_", "f_", "._", "core_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "raise_", "Sto", "p", "Iteration_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "e_", "._", "add_", "(_", "related_", "._", "opts_", ",_", "\"", "At", " ", "leas", "t", " ", "one", " ", "field", " ", "in", " ", "%", "s", " ", "shou", "ld", " ", "have", " ", "core", "=", "Tru", "e", ",", " ", "bec", "aus", "e", " ", "it", "'", "s", " ", "bei", "ng", " ", "edited", " ", "inline", " ", "by", " ", "%", "s", ".", "%", "s", ".\"_", "%_", "(_", "related_", "._", "opts_", "._", "object\\u", "name_", ",_", "opts_", "._", "module", "\\u", "name_", ",_", "opts_", "._", "object\\u", "name_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "Sto", "p", "Iteration_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "pass_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Check", " ", "unique", "\\u", "tog", "ether", "._", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "for_", "ut_", "in_", "opts_", "._", "unique", "\\u", "together_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "for_", "field", "\\u", "name_", "in_", "ut_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "f_", "=_", "opts_", "._", "get", "\\u", "field_", "(_", "field", "\\u", "name_", ",_", "many", "\\u", "to", "\\u", "many_", "=_", "True_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "models_", "._", "Field", "Do", "es", "Not", "Exist_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "e_", "._", "add_", "(_", "opts_", ",_", "'\"", "unique", "\\u", "tog", "ether", "\"", " ", "refer", "s", " ", "to", " ", "%", "s", ",", " ", "a", " ", "field", " ", "tha", "t", " ", "doe", "sn", "\\\\'", "t", " ", "exist", ".", " ", "Check", " ", "your", " ", "synta", "x", ".'_", "%_", "field", "\\u", "name_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "if_", "isinstance_", "(_", "f_", "._", "rel_", ",_", "models_", "._", "Many", "To", "Many", "Rel", "_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "e_", "._", "add_", "(_", "opts_", ",_", "'\"", "unique", "\\u", "tog", "ether", "\"", " ", "refer", "s", " ", "to", " ", "%", "s", ".", " ", "Many", "To", "Many", "Field", "s", " ", "are", " ", "not", " ", "support", "ed", " ", "in", " ", "unique", "\\u", "tog", "ether", ".'_", "%_", "f_", "._", "name_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "len_", "(_", "e_", "._", "errors_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_" ]
[ 4, 4, 4, 4, 4, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2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k/winsys/winsys/accounts.py
[ { "content": "# -*- coding: utf-8 -*-\n\"\"\"All security in windows is handled via Security Principals. These can\nbe a user (the most common case), a group of users, a computer, or something\nelse. Security principals are uniquely identified by their SID: a binary code\nrepresented by a string S-a-b-cd-efg... where each of the segments represents\nan aspect of the security authorities involved. (A computer, a domain etc.).\nCertain of the SIDs are considered well-known such as the AuthenticatedUsers\naccount on each machine which will always have the same SID.\n\nMost of the access to this module will be via the :func:`principal`\nor :func:`me` functions. Although the module is designed to be used\nstandalone, it is imported directly into the :mod:`security` module's\nnamespace so its functionality can also be accessed from there.\n\"\"\"\nfrom __future__ import unicode_literals\n\nimport os, sys\nimport contextlib\nimport socket\n\nimport ntsecuritycon\nimport pywintypes\nimport win32con\nimport win32security\nimport win32api\nimport win32cred\nimport win32event\nimport win32net\nimport win32netcon\nimport winerror\n\nfrom winsys._compat import *\nfrom winsys import constants, core, exc, utils\nfrom winsys import _advapi32\n\n__all__ = ['LOGON', 'EXTENDED_NAME', 'x_accounts', 'principal', 'Principal', 'User', 'Group', 'me']\n\nLOGON = constants.Constants.from_pattern(\"LOGON32_*\", namespace=win32security)\nLOGON.doc(\"Types of logon used by LogonUser and related APIs\")\nEXTENDED_NAME = constants.Constants.from_pattern(\"Name*\", namespace=win32con)\nEXTENDED_NAME.doc(\"Extended display formats for usernames\")\nWELL_KNOWN_SID = constants.Constants.from_pattern(\"Win*Sid\", namespace=win32security)\nWELL_KNOWN_SID.doc(\"Well-known SIDs common to all computers\")\nUSER_PRIV = constants.Constants.from_list([\"USER_PRIV_GUEST\", \"USER_PRIV_USER\", \"USER_PRIV_ADMIN\"], pattern=\"USER_PRIV_*\", namespace=win32netcon)\nUSER_PRIV.doc(\"User-types for creating new users\")\nUF = constants.Constants.from_pattern(\"UF_*\", namespace=win32netcon)\nUF.doc(\"Flags for creating new users\")\nSID_NAME_USE = constants.Constants.from_pattern(\"SidType*\", namespace=ntsecuritycon)\nSID_NAME_USE.doc(\"Types of accounts for which SIDs exist\")\nFILTER = constants.Constants.from_pattern(\"FILTER_*\", namespace=win32netcon)\nFILTER.doc(\"Filters when enumerating users\")\n\nPySID = pywintypes.SIDType\n\n\nWINERROR_MAP = {\n winerror.ERROR_NONE_MAPPED : exc.x_not_found\n}\nwrapped = exc.wrapper(WINERROR_MAP, x_accounts)\n\n\n\n\n\n\n\n\n_domain = None\n\n\n\n\n\n\n\n\nPrincipal.SID_NAME_USE_MAP = {\n SID_NAME_USE.User : User,\n SID_NAME_USE.Group : Group,\n SID_NAME_USE.WellKnownGroup : Group\n}\n\n\n\n", "metadata": "root", "header": "['module', '___EOS___']", "index": 0 }, { "content": "class x_accounts(exc.x_winsys):\n \"Base for all accounts-related exceptions\"", "metadata": "root.x_accounts", "header": "['module', '___EOS___']", "index": 54 }, { "content": "def _win32net_enum(win32_fn, system_or_domain):\n resume = 0\n while True:\n items, total, resume = wrapped(win32_fn, system_or_domain, 0, resume)\n for item in items:\n yield item\n if resume == 0: break", "metadata": "root._win32net_enum", "header": "['module', '___EOS___']", "index": 62 }, { "content": "def principal(principal, cls=core.UNSET):\n \"\"\"Factory function for the :class:`Principal` class. This is the most\n common way to create a :class:`Principal` object::\n\n from winsys import accounts\n service_account = accounts.principal (accounts.WELL_KNOWN_SID.Service)\n local_admin = accounts.principal (\"Administrator\")\n domain_users = accounts.principal (r\"DOMAIN\\Domain Users\")\n\n :param principal: any of None, a :class:`Principal`, a `PySID`,\n a :const:`WELL_KNOWN_SID` or a string\n :returns: a :class:`Principal` object corresponding to `principal`\n \"\"\"\n cls = Principal if cls is core.UNSET else cls\n if principal is None:\n return None\n elif type(principal) == PySID:\n return cls.from_sid(principal)\n elif isinstance(principal, int):\n return cls.from_well_known(principal)\n elif isinstance(principal, cls):\n return principal\n else:\n return cls.from_string(unicode(principal))", "metadata": "root.principal", "header": "['module', '___EOS___']", "index": 70 }, { "content": "def user(name):\n \"\"\"If you know you're after a user, use this. Particularly\n useful when a system user is defined as an alias type\n \"\"\"\n return principal(name, cls=User)", "metadata": "root.user", "header": "['module', '___EOS___']", "index": 95 }, { "content": "def group(name):\n \"\"\"If you know you're after a group, use this. Particularly\n useful when a system group is defined as an alias type\n \"\"\"\n return principal(name, cls=Group)", "metadata": "root.group", "header": "['module', '___EOS___']", "index": 101 }, { "content": "def local_group(name):\n \"\"\"If you know you're after a local group, use this.\n \"\"\"\n return principal(name, cls=LocalGroup)", "metadata": "root.local_group", "header": "['module', '___EOS___']", "index": 107 }, { "content": "def global_group(name):\n \"\"\"If you know you're after a global group, use this.\n \"\"\"\n return principal(name, cls=GlobalGroup)", "metadata": "root.global_group", "header": "['module', '___EOS___']", "index": 112 }, { "content": "def me():\n \"\"\"Convenience function for the common case of getting the\n logged-on user's account.\n \"\"\"\n return Principal.me()", "metadata": "root.me", "header": "['module', '___EOS___']", "index": 117 }, { "content": "def domain(system=None):\n global _domain\n if _domain is None:\n _domain = wrapped(win32net.NetWkstaGetInfo, system, 100)['langroup']\n return _domain", "metadata": "root.domain", "header": "['module', '___EOS___']", "index": 124 }, { "content": "def domain_controller(domain=None):\n return wrapped(win32net.NetGetAnyDCName, None, domain)", "metadata": "root.domain_controller", "header": "['module', '___EOS___']", "index": 130 }, { "content": "def users(system=None):\n \"\"\"Convenience function to yield each of the local users\n on a system.\n\n :param system: optional security authority\n :returns: yield :class:`User` objects\n \"\"\"\n return iter(_LocalUsers(system))", "metadata": "root.users", "header": "['module', '___EOS___']", "index": 133 }, { "content": "class Principal(core._WinSysObject):\n \"\"\"Object wrapping a Windows security principal, represented by a SID\n and, where possible, a name. :class:`Principal` compares and hashes\n by SID so can be sorted and used as a dictionary key, set element, etc.\n\n A :class:`Principal` is its own context manager, impersonating the\n corresponding user::\n\n from winsys import accounts\n with accounts.principal(\"python\"):\n print accounts.me()\n\n Note, though, that this will prompt for a password using the\n Win32 password UI. To logon with a password, use the :meth:`impersonate`\n context-managed function. TODO: allow password to be set securely.\n \"\"\"\n\n\n\n\n\n\n\n\n\n\n\n\n\n", "metadata": "root.Principal", "header": "['module', '___EOS___']", "index": 142 }, { "content": " def __init__(self, sid, system=None):\n \"\"\"Initialise a Principal from and (optionally) a system name. The sid\n must be a PySID and the system name, if present must be a security\n authority, eg a machine or a domain.\n \"\"\"\n core._WinSysObject.__init__(self)\n self.sid = sid\n self.system = system\n try:\n self.name, self.domain, self.type = wrapped(win32security.LookupAccountSid, self.system, self.sid)\n except exc.x_not_found:\n self.name = str(self.sid)\n self.domain = self.type = None\n #~ if self.system is None:\n #~ self.system = domain_controller(self.domain)", "metadata": "root.Principal.__init__", "header": "['class', 'Principal', '(', 'core', '.', '_WinSysObject', ')', ':', '___EOS___']", "index": 158 }, { "content": " def __hash__(self):\n return hash(str(self.sid))", "metadata": "root.Principal.__hash__", "header": "['class', 'Principal', '(', 'core', '.', '_WinSysObject', ')', ':', '___EOS___']", "index": 174 }, { "content": " def __eq__(self, other):\n return self.sid == principal(other).sid", "metadata": "root.Principal.__eq__", "header": "['class', 'Principal', '(', 'core', '.', '_WinSysObject', ')', ':', '___EOS___']", "index": 177 }, { "content": " def __lt__(self, other):\n return self.sid < principal(other).sid", "metadata": "root.Principal.__lt__", "header": "['class', 'Principal', '(', 'core', '.', '_WinSysObject', ')', ':', '___EOS___']", "index": 180 }, { "content": " def pyobject(self):\n \"\"\"Return the internal representation of this object.\n\n :returns: pywin32 SID\n \"\"\"\n return self.sid", "metadata": "root.Principal.pyobject", "header": "['class', 'Principal', '(', 'core', '.', '_WinSysObject', ')', ':', '___EOS___']", "index": 183 }, { "content": " def as_string(self):\n if self.domain:\n return \"%s\\%s\" % (self.domain, self.name)\n else:\n return self.name or str(self.sid)", "metadata": "root.Principal.as_string", "header": "['class', 'Principal', '(', 'core', '.', '_WinSysObject', ')', ':', '___EOS___']", "index": 190 }, { "content": " def dumped(self, level):\n return utils.dumped(\"user: %s\\nsid: %s\" % (\n self.as_string(),\n wrapped(win32security.ConvertSidToStringSid, self.sid)\n ), level)", "metadata": "root.Principal.dumped", "header": "['class', 'Principal', '(', 'core', '.', '_WinSysObject', ')', ':', '___EOS___']", "index": 196 }, { "content": " def logon(self, password=core.UNSET, logon_type=core.UNSET):\n \"\"\"Log on as an authenticated user, returning that\n user's token. This is used by security.impersonate\n which wraps the token in a Token object and manages\n its lifetime in a context.\n\n (EXPERIMENTAL) If no password is given, a UI pops up\n to ask for a password.\n\n :param password: the password for this account\n :param logon_type: one of the :const:`LOGON` values\n :returns: a pywin32 handle to a token\n \"\"\"\n if logon_type is core.UNSET:\n logon_type = LOGON.LOGON_NETWORK\n else:\n logon_type = LOGON.constant(logon_type)\n #~ if password is core.UNSET:\n #~ password = dialogs.get_password(self.name, self.domain)\n hUser = wrapped(\n win32security.LogonUser,\n self.name,\n self.domain,\n password,\n logon_type,\n LOGON.PROVIDER_DEFAULT\n )\n return hUser", "metadata": "root.Principal.logon", "header": "['class', 'Principal', '(', 'core', '.', '_WinSysObject', ')', ':', '___EOS___']", "index": 202 }, { "content": " @classmethod\n def from_string(cls, string, system=None):\n r\"\"\"Return a :class:`Principal` based on a name and a\n security authority. If `string` is blank, the logged-on user is assumed.\n\n :param string: name of an account in the form \"domain\\name\". domain is optional so the simplest form is simply \"name\"\n :param system: name of a security authority (typically a machine or a domain)\n :returns: a :class:`Principal` object for `string`\n \"\"\"\n if string == \"\":\n string = wrapped(win32api.GetUserNameEx, win32con.NameSamCompatible)\n sid, domain, type = wrapped(\n win32security.LookupAccountName,\n None if system is None else unicode(system),\n unicode(string)\n )\n cls = cls.SID_NAME_USE_MAP.get(type, cls)\n return cls(sid, None if system is None else unicode(system))", "metadata": "root.Principal.from_string", "header": "['class', 'Principal', '(', 'core', '.', '_WinSysObject', ')', ':', '___EOS___']", "index": 231 }, { "content": " @classmethod\n def from_sid(cls, sid, system=None):\n \"\"\"Return a :class:`Principal` based on a sid and a security authority.\n\n :param sid: a PySID\n :param system_name: optional name of a security authority\n :returns: a :class:`Principal` object for `sid`\n \"\"\"\n try:\n name, domain, type = wrapped(\n win32security.LookupAccountSid,\n None if system is None else unicode(system),\n sid\n )\n except exc.x_not_found:\n name = domain = type = core.UNSET\n cls = cls.SID_NAME_USE_MAP.get(type, cls)\n return cls(sid, None if system is None else unicode(system))", "metadata": "root.Principal.from_sid", "header": "['class', 'Principal', '(', 'core', '.', '_WinSysObject', ')', ':', '___EOS___']", "index": 250 }, { "content": " @classmethod\n def from_well_known(cls, well_known, domain=None):\n \"\"\"Return a :class:`Principal` based on one of the :const:`WELL_KNOWN_SID` values.\n\n :param well_known: one of the :const:`WELL_KNOWN_SID`\n :param domain: anything accepted by :func:`principal` and corresponding to a domain\n \"\"\"\n return cls.from_sid(wrapped(win32security.CreateWellKnownSid, well_known, principal(domain)))", "metadata": "root.Principal.from_well_known", "header": "['class', 'Principal', '(', 'core', '.', '_WinSysObject', ')', ':', '___EOS___']", "index": 269 }, { "content": " @classmethod\n def me(cls):\n \"\"\"Convenience factory method for the common case of referring to the\n logged-on user\n \"\"\"\n return cls.from_string(wrapped(win32api.GetUserNameEx, EXTENDED_NAME.SamCompatible))", "metadata": "root.Principal.me", "header": "['class', 'Principal', '(', 'core', '.', '_WinSysObject', ')', ':', '___EOS___']", "index": 278 }, { "content": " @contextlib.contextmanager\n def impersonate(self, password=core.UNSET, logon_type=core.UNSET):\n \"\"\"Context-managed function to impersonate this user and then\n revert::\n\n from winsys import accounts, security\n print accounts.me()\n python = accounts.principal(\"python\")\n with python.impersonate(\"Pa55w0rd\"):\n print accounts.me()\n open(\"temp.txt\", \"w\").close()\n print accounts.me()\n security.security(\"temp.txt\").owner == python\n\n Note that the :class:`Principal` class is also its own\n context manager but does not allow the password to be specified.\n\n :param password: password for this account\n :param logon_type: one of the :const:`LOGON` values\n \"\"\"\n hLogon = self.logon(password, logon_type)\n wrapped(win32security.ImpersonateLoggedOnUser, hLogon)\n yield hLogon\n wrapped(win32security.RevertToSelf)", "metadata": "root.Principal.impersonate", "header": "['class', 'Principal', '(', 'core', '.', '_WinSysObject', ')', ':', '___EOS___']", "index": 285 }, { "content": " def __enter__(self):\n wrapped(win32security.ImpersonateLoggedOnUser, self.logon(logon_type=LOGON.LOGON_INTERACTIVE))", "metadata": "root.Principal.__enter__", "header": "['class', 'Principal', '(', 'core', '.', '_WinSysObject', ')', ':', '___EOS___']", "index": 310 }, { "content": " def __exit__(self, *exc_info):\n wrapped(win32security.RevertToSelf)", "metadata": "root.Principal.__exit__", "header": "['class', 'Principal', '(', 'core', '.', '_WinSysObject', ')', ':', '___EOS___']", "index": 313 }, { "content": "class User(Principal):\n\n\n\n\n\n", "metadata": "root.User", "header": "['module', '___EOS___']", "index": 316 }, { "content": " @classmethod\n def create(cls, username, password, system=None):\n \"\"\"Create a new user with `username` and `password`. Return\n a :class:`User` for the new user.\n\n :param username: username of the new user. Must not already exist on `system`\n :param password: password for the new user. Must meet security policy on `system`\n :param system: optional system name\n :returns: a :class:`User` for `username`\n \"\"\"\n user_info = dict(\n name = username,\n password = password,\n priv = USER_PRIV.USER,\n home_dir = None,\n comment = None,\n flags = UF.SCRIPT,\n script_path = None\n )\n wrapped(win32net.NetUserAdd, system, 1, user_info)\n return cls.from_string(username, system)", "metadata": "root.User.create", "header": "['class', 'User', '(', 'Principal', ')', ':', '___EOS___']", "index": 318 }, { "content": " def delete(self):\n \"\"\"Delete this user from `system`.\n\n :param system: optional security authority\n \"\"\"\n wrapped(win32net.NetUserDel, self.system, self.name)", "metadata": "root.User.delete", "header": "['class', 'User', '(', 'Principal', ')', ':', '___EOS___']", "index": 340 }, { "content": " def groups(self):\n \"\"\"Yield the groups this user belongs to\n\n :param system: optional security authority\n \"\"\"\n for group_name, attributes in wrapped(win32net.NetUserGetGroups, self.system, self.name):\n yield group(group_name)\n for group_name in wrapped(win32net.NetUserGetLocalGroups, self.system, self.name):\n yield group(group_name)", "metadata": "root.User.groups", "header": "['class', 'User', '(', 'Principal', ')', ':', '___EOS___']", "index": 347 }, { "content": " def join(self, other_group):\n \"\"\"Add this user to a group\n\n :param other_group: anything accepted by :func:`group`\n :returns: self\n \"\"\"\n return group(other_group).add(self)", "metadata": "root.User.join", "header": "['class', 'User', '(', 'Principal', ')', ':', '___EOS___']", "index": 357 }, { "content": " def leave(self, other_group):\n \"\"\"Remove this user from a group\n\n :param other_group: anything accepted by :func:`group`\n :returns: self\n \"\"\"\n return group(other_group).remove(self)", "metadata": "root.User.leave", "header": "['class', 'User', '(', 'Principal', ')', ':', '___EOS___']", "index": 365 }, { "content": " def runas(self, command_line, password=core.UNSET, load_profile=False):\n \"\"\"Run a command logged on as this user\n\n :param command_line: command line to run, quoted as necessary\n :param password: password; if not supplied, standard Windows prompt\n :param with_profile: if True, HKEY_CURRENT_USER is loaded [False]\n \"\"\"\n #~ if not password:\n #~ password = dialogs.get_password(self.name, self.domain)\n logon_flags = 0\n if load_profile: logon_flags |= _advapi32.LOGON_FLAGS.WITH_PROFILE\n process_info = _advapi32.CreateProcessWithLogonW(\n username=self.name,\n domain=self.domain,\n password=password,\n command_line=command_line,\n logon_flags=logon_flags\n )\n #\n # Wait for up to 20 secs\n #\n #~ if wrapped(win32event.WaitForInputIdle, process_info.hProcess, 10000) == win32event.WAIT_TIMEOUT:\n #~ raise x_accounts(errctx=\"runas\", errmsg=\"runas process not created with 10 secs\")", "metadata": "root.User.runas", "header": "['class', 'User', '(', 'Principal', ')', ':', '___EOS___']", "index": 373 }, { "content": "class Group(Principal):\n\n SID_NAME_USE_MAP = {}\n", "metadata": "root.Group", "header": "['module', '___EOS___']", "index": 397 }, { "content": " def __contains__(self, member):\n \"\"\"Crudely, iterate over the group's members until you hit `member`\n \"\"\"\n member = principal(member)\n return any(member == m for m in self)", "metadata": "root.Group.__contains__", "header": "['class', 'Group', '(', 'Principal', ')', ':', '___EOS___']", "index": 401 }, { "content": "class GlobalGroup(Group):\n\n _enumerator = win32net.NetGroupEnum\n\n\n\n\n", "metadata": "root.GlobalGroup", "header": "['module', '___EOS___']", "index": 407 }, { "content": " @classmethod\n def create(cls, groupname, domain=None):\n \"\"\"Create a new group. Return a :class:`Group` for the new group.\n\n :param groupname: name of the new group. Must not already exist on `system`\n :param system: optional security authority\n :returns: a :class:`Group` for `groupname`\n \"\"\"\n system = domain_controller(domain)\n wrapped(win32net.NetGroupAdd, system, 0, dict(name=groupname))\n return cls.from_string(groupname, system)", "metadata": "root.GlobalGroup.create", "header": "['class', 'GlobalGroup', '(', 'Group', ')', ':', '___EOS___']", "index": 411 }, { "content": " def delete(self):\n \"\"\"Delete this group from `system`.\n\n :param system: optional security authority\n \"\"\"\n wrapped(win32net.NetGroupDel, self.system, self.name)", "metadata": "root.GlobalGroup.delete", "header": "['class', 'GlobalGroup', '(', 'Group', ')', ':', '___EOS___']", "index": 423 }, { "content": " def add(self, member):\n \"\"\"Add a :class:`Principal` to this local group\n\n :param member: anything accepted by :func:`principal`\n :returns: :class:`Principal` for `member`\n \"\"\"\n member = principal(member)\n wrapped(win32net.NetGroupAddUser, self.system, self.name, r\"%s\\%s\" % (member.domain, member.name))\n return member", "metadata": "root.GlobalGroup.add", "header": "['class', 'GlobalGroup', '(', 'Group', ')', ':', '___EOS___']", "index": 430 }, { "content": " def remove(self, member):\n \"\"\"Remove a :class:`Principal` from this local group. The\n principal must already be a member of the group.\n\n :param member: anything accepted by :func:`principal`\n :returns: :class:`Principal` for `member`\n \"\"\"\n member = principal(member)\n wrapped(win32net.NetGroupDelUser, self.system, self.name, r\"%s\\%s\" % (member.domain, member.name))\n return member", "metadata": "root.GlobalGroup.remove", "header": "['class', 'GlobalGroup', '(', 'Group', ')', ':', '___EOS___']", "index": 440 }, { "content": " def __iter__(self):\n \"\"\"Yield the list of members of this group.\n\n :returns: yield a :class:`Principal` or subclass corresponding to each member\n of this group\n \"\"\"\n resume = 0\n while True:\n members, total, resume = wrapped(win32net.NetGroupGetUsers, self.system, self.name, 1, resume)\n for member in members:\n yield principal(member['name'])\n if resume == 0: break", "metadata": "root.GlobalGroup.__iter__", "header": "['class', 'GlobalGroup', '(', 'Group', ')', ':', '___EOS___']", "index": 451 }, { "content": "class LocalGroup(Group):\n\n\n\n\n", "metadata": "root.LocalGroup", "header": "['module', '___EOS___']", "index": 464 }, { "content": " @classmethod\n def create(cls, groupname, system=None):\n \"\"\"Create a new group. Return a :class:`Group` for the new group.\n\n :param groupname: name of the new group. Must not already exist on `system`\n :param system: optional security authority\n :returns: a :class:`Group` for `groupname`\n \"\"\"\n wrapped(win32net.NetLocalGroupAdd, system, 0, dict(name=groupname))\n return cls.from_string(groupname, system)", "metadata": "root.LocalGroup.create", "header": "['class', 'LocalGroup', '(', 'Group', ')', ':', '___EOS___']", "index": 466 }, { "content": " def delete(self):\n \"\"\"Delete this group from `system`.\n\n :param system: optional security authority\n \"\"\"\n wrapped(win32net.NetLocalGroupDel, self.system, self.name)", "metadata": "root.LocalGroup.delete", "header": "['class', 'LocalGroup', '(', 'Group', ')', ':', '___EOS___']", "index": 477 }, { "content": " def add(self, member):\n \"\"\"Add a :class:`Principal` to this local group\n\n :param member: anything accepted by :func:`principal`\n :returns: :class:`Principal` for `member`\n \"\"\"\n member = principal(member)\n wrapped(win32net.NetLocalGroupAddMembers, self.system, self.name, 0, [dict(sid=member.sid)])\n return member", "metadata": "root.LocalGroup.add", "header": "['class', 'LocalGroup', '(', 'Group', ')', ':', '___EOS___']", "index": 484 }, { "content": " def remove(self, member):\n \"\"\"Remove a :class:`Principal` from this local group. The\n principal must already be a member of the group.\n\n :param member: anything accepted by :func:`principal`\n :returns: :class:`Principal` for `member`\n \"\"\"\n member = principal(member)\n wrapped(win32net.NetLocalGroupDelMembers, self.system, self.name, [\"%s\\\\%s\" % (member.domain, member.name)])\n return member", "metadata": "root.LocalGroup.remove", "header": "['class', 'LocalGroup', '(', 'Group', ')', ':', '___EOS___']", "index": 494 }, { "content": " def __iter__(self):\n \"\"\"Yield the list of members of this group.\n\n :returns: yield a :class:`Principal` or subclass corresponding to each member\n of this group\n \"\"\"\n resume = 0\n while True:\n members, total, resume = wrapped(win32net.NetLocalGroupGetMembers, self.system, self.name, resume)\n for member in members:\n yield principal(member['sid'])\n if resume == 0: break", "metadata": "root.LocalGroup.__iter__", "header": "['class', 'LocalGroup', '(', 'Group', ')', ':', '___EOS___']", "index": 505 }, { "content": "def local_groups(system=None):\n \"\"\"Convenience function to yield each of the local users\n on a system.\n\n :param system: optional security authority\n :returns: yield :class:`LocalGroup` objects\n \"\"\"\n for group in _win32net_enum(win32net.NetLocalGroupEnum, system):\n yield LocalGroup.from_string(group['name'])", "metadata": "root.local_groups", "header": "['module', '___EOS___']", "index": 524 }, { "content": "def global_groups(domain=None):\n \"\"\"Convenience function to yield each of the local users\n on a system.\n\n :param domain: optional security domain\n :returns: yield :class:`GlobalGroup` objects\n \"\"\"\n for group in _win32net_enum(win32net.NetGroupEnum, domain_controller(domain)):\n yield GlobalGroup.from_string(group['name'])", "metadata": "root.global_groups", "header": "['module', '___EOS___']", "index": 534 }, { "content": "class _LocalUsers(object):\n\n\n\n", "metadata": "root._LocalUsers", "header": "['module', '___EOS___']", "index": 544 }, { "content": " def __init__(self, system=None):\n self.system = system", "metadata": "root._LocalUsers.__init__", "header": "['class', '_LocalUsers', '(', 'object', ')', ':', '___EOS___']", "index": 546 }, { "content": " def __iter__(self):\n resume = 0\n while True:\n users, total, resume = wrapped(win32net.NetUserEnum, self.system, 0, FILTER.NORMAL_ACCOUNT, resume)\n for user in users:\n yield User.from_string(user['name'])\n if resume == 0: break", "metadata": "root._LocalUsers.__iter__", "header": "['class', '_LocalUsers', '(', 'object', ')', ':', '___EOS___']", "index": 549 }, { "content": " def add(self, username, password):\n return User.create(username, password)", "metadata": "root._LocalUsers.add", "header": "['class', '_LocalUsers', '(', 'object', ')', ':', '___EOS___']", "index": 557 }, { "content": " def remove(self, local_user):\n return user(local_user).delete()", "metadata": "root._LocalUsers.remove", "header": "['class', '_LocalUsers', '(', 'object', ')', ':', '___EOS___']", "index": 560 } ]
[ { "span": "import os, sys", "start_line": 16, "start_column": 0, "end_line": 16, "end_column": 14 }, { "span": "import socket", "start_line": 18, "start_column": 0, "end_line": 18, "end_column": 13 }, { "span": "import win32cred", "start_line": 25, "start_column": 0, "end_line": 25, "end_column": 16 }, { "span": "import win32event", "start_line": 26, "start_column": 0, "end_line": 26, "end_column": 17 } ]
[]
1
false
[ "[CLS]_", "Un", "used_", "import_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "#", " ", "-*-", " ", "codi", "ng", ":", " ", "utf", "-", "8", " ", "-*-", "_", "\\u\\u\\uNL\\u\\u\\u_", "\"\"\"", "All", " ", "security", " ", "in", " ", "windows", " ", "is", " ", "handle", "d", " ", "via", " ", "Secur", "it", "y", " ", "Princip", "als", ".", " ", "The", "se", " ", "can", "\\", "10", ";", "be", " ", "a", " ", "user", " ", "(", "the", " ", "most", " ", "common", " ", "case", "),", " ", "a", " ", "group", " ", "of", " ", "users", ",", " ", "a", " ", "computer", ",", " ", "or", " ", "somet", "hing", "\\", "10", ";", "else", ".", " ", "Secur", "it", "y", " ", "principal", "s", " ", "are", " ", "unique", "ly", " ", "identifi", "ed", " ", "by", " ", "thei", "r", " ", "SID", ":", " ", "a", " ", "binar", "y", " ", "code", "\\", "10", ";", "represent", "ed", " ", "by", " ", "a", " ", "string", " ", "S", "-", "a", "-", "b", "-", "cd", "-", "efg", "...", " ", "where", " ", "each", " ", "of", " ", "the", " ", "segments", " ", "represent", "s", "\\", "10", ";", "an", " ", "aspect", " ", "of", " ", "the", " ", "security", " ", "authorities", " ", "involved", ".", " ", "(", "A", " ", "computer", ",", " ", "a", " ", "domain", " ", "etc", ".)", ".", "\\", "10", ";", "Cert", "ain", " ", "of", " ", "the", " ", "SID", "s", " ", "are", " ", "consider", "ed", " ", "well", "-", "know", "n", " ", "suc", "h", " ", "as", " ", "the", " ", "Auth", "entica", "ted", "User", "s", "\\", "10", ";", "account", " ", "on", " ", "each", " ", "machine", " ", "whi", "ch", " ", "will", " ", "alw", "ay", "s", " ", "have", " ", "the", " ", "same", " ", "SID", ".", "\\", "10", ";", "\\", "10", ";", "Mos", "t", " ", "of", " ", "the", " ", "access", " ", "to", " ", "this", " ", "module", " ", "will", " ", "be", " ", "via", " ", "the", " ", ":", "func", ":`", "principal", "`", "\\", "10", ";", "or", " ", ":", "func", ":`", "me", "`", " ", "function", "s", ".", " ", "Alt", "hou", "gh", " ", "the", " ", "module", " ", "is", " ", "design", "ed", " ", "to", " ", "be", " ", "used", "\\", "10", ";", "standalone", ",", " ", "it", " ", "is", " ", "import", "ed", " ", "direct", "ly", " ", "int", "o", " ", "the", " ", ":", "mod", ":`", "security", "`", " ", "module", "'", "s", "\\", "10", ";", "namespace", " ", "so", " ", "its", " ", "functional", "it", "y", " ", "can", " ", "als", "o", " ", "be", " ", "accesse", "d", " ", "from", " ", "there", ".", "\\", "10", ";\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "\\u\\u", "future\\u\\u_", "import_", "unicode", "\\u", "literals_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "import_", "os_", ",_", "sys_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "contextlib_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "socket_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "import_", "nts", "ecu", "rity", "con_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "pywi", "ntype", "s_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "win32con_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "win32", "security_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "win32", "api_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "win32", "cred_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "win32", "event_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "win32", "net_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "win32", "netc", "on_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "wine", "rror_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "from_", "wins", "ys_", "._", "\\u", "compat_", "import_", "*_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "wins", "ys_", "import_", "constants_", ",_", "core_", ",_", "exc_", ",_", "utils_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "wins", "ys_", "import_", "\\u", "adv", "api", "32_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u", "all\\u\\u_", "=_", "[_", "'", "LOGO", "N", "'_", ",_", "'", "EXTEND", "ED", "\\u", "NAME", "'_", ",_", "'", "x", "\\u", "account", "s", "'_", ",_", "'", "principal", "'_", ",_", "'", "Princip", "al", "'_", ",_", "'", "User", "'_", ",_", "'", "Group", "'_", ",_", "'", "me", "'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "LOGO", "N_", "=_", "constants_", "._", "Constants_", "._", "from", "\\u", "pattern_", "(_", "\"", "LOGO", "N3", "2", "\\u*", "\"_", ",_", "namespace_", "=_", "win32", "security_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "LOGO", "N_", "._", "doc_", "(_", "\"", "Type", "s", " ", "of", " ", "logo", "n", " ", "used", " ", "by", " ", "Logo", "n", "User", " ", "and", " ", "relate", "d", " ", "API", "s", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "EXTEND", "ED", "\\u", "NAME_", "=_", "constants_", "._", "Constants_", "._", "from", "\\u", "pattern_", "(_", "\"", "Name", "*\"_", ",_", "namespace_", "=_", "win32con_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "EXTEND", "ED", "\\u", "NAME_", "._", "doc_", "(_", "\"", "Extend", "ed", " ", "display", " ", "formats", " ", "for", " ", "usernames", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "WEL", "L", "\\u", "KNOWN", "\\u", "SID", "_", "=_", "constants_", "._", "Constants_", "._", "from", "\\u", "pattern_", "(_", "\"", "Win", "*", "Si", "d", "\"_", ",_", "namespace_", "=_", "win32", "security_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "WEL", "L", "\\u", "KNOWN", "\\u", "SID", "_", "._", "doc_", "(_", "\"", "Wel", "l", "-", "know", "n", " ", "SID", "s", " ", "common", " ", "to", " ", "all", " ", "computer", "s", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "USER", "\\u", "PRIV", "_", "=_", "constants_", "._", "Constants_", "._", "from", "\\u", "list_", "(_", "[_", "\"", "USER", "\\u", "PRIV", "\\u", "GUE", "ST", "\"_", ",_", "\"", "USER", "\\u", "PRIV", "\\u", "USER", "\"_", ",_", "\"", "USER", "\\u", "PRIV", "\\u", "ADM", "IN", "\"_", "]_", ",_", "pattern_", "=_", "\"", "USER", "\\u", "PRIV", "\\u*", "\"_", ",_", "namespace_", "=_", "win32", "netc", "on_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "USER", "\\u", "PRIV", "_", "._", "doc_", "(_", "\"", "User", "-", "types", " ", "for", " ", "creati", "ng", " ", "new", " ", "users", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "UF", "_", "=_", "constants_", "._", "Constants_", "._", "from", "\\u", "pattern_", "(_", "\"", "UF", "\\u*", "\"_", ",_", "namespace_", "=_", "win32", "netc", "on_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "UF", "_", "._", "doc_", "(_", "\"", "Fla", "gs", " ", "for", " ", "creati", "ng", " ", "new", " ", "users", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "SID", "\\u", "NAME", "\\u", "USE", "_", "=_", "constants_", "._", "Constants_", "._", "from", "\\u", "pattern_", "(_", "\"", "Si", "d", "Type", "*\"_", ",_", "namespace_", "=_", "nts", "ecu", "rity", "con_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "SID", "\\u", "NAME", "\\u", "USE", "_", "._", "doc_", "(_", "\"", "Type", "s", " ", "of", " ", "account", "s", " ", "for", " ", "whi", "ch", " ", "SID", "s", " ", "exist", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "FILTER_", "=_", "constants_", "._", "Constants_", "._", "from", "\\u", "pattern_", "(_", "\"", "FILTER", "\\u*", "\"_", ",_", "namespace_", "=_", "win32", "netc", "on_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "FILTER_", "._", "doc_", "(_", "\"", "Filter", "s", " ", "whe", "n", " ", "enumerati", "ng", " ", "users", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "Py", "SID", "_", "=_", "pywi", "ntype", "s_", "._", "SID", "Type_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "WIN", "ERROR", "\\u", "MAP_", "=_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "wine", "rror_", "._", "ERROR", "\\u", "NON", "E", "\\u", "MAP", "PED", "_", ":_", "exc_", "._", "x", "\\u", "not", "\\u", "found_", "\\u\\u\\uNL\\u\\u\\u_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "wrapped_", "=_", "exc_", "._", "wrapper_", "(_", "WIN", "ERROR", "\\u", "MAP_", ",_", "x", "\\u", "accounts_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u", "domain_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "Princip", "al_", "._", "SID", "\\u", "NAME", "\\u", "USE", "\\u", "MAP_", "=_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "SID", "\\u", "NAME", "\\u", "USE", "_", "._", "User_", ":_", "User_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "SID", "\\u", "NAME", "\\u", "USE", "_", "._", "Group_", ":_", "Group_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "SID", "\\u", "NAME", "\\u", "USE", "_", "._", "Wel", "l", "Kno", "wn", "Group_", ":_", "Group_", "\\u\\u\\uNL\\u\\u\\u_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "class_", "x", "\\u", "accounts_", "(_", "exc_", "._", "x", "\\u", "wins", "ys_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"", "Base", " ", "for", " ", "all", " ", "account", "s", "-", "relate", "d", " ", "exception", "s", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "\\u", "win32", "net", "\\u", "enum_", "(_", "win32", "\\u", "fn_", ",_", "system", "\\u", "or", "\\u", "domain_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "resume_", "=_", "0_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "while_", "True_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "items_", ",_", "total_", ",_", "resume_", "=_", "wrapped_", "(_", "win32", "\\u", "fn_", ",_", "system", "\\u", "or", "\\u", "domain_", ",_", "0_", ",_", "resume_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "item_", "in_", "items_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "yield_", "item_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "resume_", "==_", "0_", ":_", "break_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "principal_", "(_", "principal_", ",_", "cls_", "=_", "core_", "._", "UNS", "ET_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "Factor", "y", " ", "function", " ", "for", " ", "the", " ", ":", "class", ":`", "Princip", "al", "`", " ", "class", ".", " ", "Thi", "s", " ", "is", " ", "the", " ", "most", "\\", "10", ";", " ", " ", " ", " ", "common", " ", "way", " ", "to", " ", "create", " ", "a", " ", ":", "class", ":`", "Princip", "al", "`", " ", "object", "::", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "from", " ", "wins", "ys", " ", "import", " ", "account", "s", "\\", "10", ";", " ", " ", " ", " ", "service", "\\u", "account", " ", "=", " ", "account", "s", ".", "principal", " ", "(", "account", "s", ".", "WEL", "L", "\\u", "KNOWN", "\\u", "SID", ".", "Service", ")", "\\", "10", ";", " ", " ", " ", " ", "local", "\\u", "admin", " ", "=", " ", "account", "s", ".", "principal", " ", "(\"", "Administra", "tor", "\")", "\\", "10", ";", " ", " ", " ", " ", "domain", "\\u", "users", " ", "=", " ", "account", "s", ".", "principal", " ", "(", "r", "\"", "DOM", "AIN", "\\\\", "Doma", "in", " ", "User", "s", "\")", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", ":", "param", " ", "principal", ":", " ", "any", " ", "of", " ", "Non", "e", ",", " ", "a", " ", ":", "class", ":`", "Princip", "al", "`", ",", " ", "a", " ", "`", "Py", "SID", "`", ",", "\\", "10", ";", " ", " ", " ", " ", "a", " ", ":", "const", ":`", "WEL", "L", "\\u", "KNOWN", "\\u", "SID", "`", " ", "or", " ", "a", " ", "string", "\\", "10", ";", " ", " ", " ", " ", ":", "return", "s", ":", " ", "a", " ", ":", "class", ":`", "Princip", "al", "`", " ", "object", " ", "correspond", "ing", " ", "to", " ", "`", "principal", "`", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "cls_", "=_", "Princip", "al_", "if_", "cls_", "is_", "core_", "._", "UNS", "ET_", "else_", "cls_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "principal_", "is_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "type_", "(_", "principal_", ")_", "==_", "Py", "SID", "_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "cls_", "._", "from", "\\u", "sid_", "(_", "principal_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "isinstance_", "(_", "principal_", ",_", "int_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "cls_", "._", "from", "\\u", "well", "\\u", "known_", "(_", "principal_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "isinstance_", "(_", "principal_", ",_", "cls_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "principal_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "cls_", "._", "from", "\\u", "string_", "(_", "unicode_", "(_", "principal_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "user_", "(_", "name_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "If", " ", "you", " ", "know", " ", "you", "'", "re", " ", "after", " ", "a", " ", "user", ",", " ", "use", " ", "this", ".", " ", "Parti", "cula", "rl", "y", "\\", "10", ";", " ", " ", " ", " ", "usef", "ul", " ", "whe", "n", " ", "a", " ", "system", " ", "user", " ", "is", " ", "defin", "ed", " ", "as", " ", "an", " ", "alias", " ", "type", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "principal_", "(_", "name_", ",_", "cls_", "=_", "User_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "group_", "(_", "name_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "If", " ", "you", " ", "know", " ", "you", "'", "re", " ", "after", " ", "a", " ", "group", ",", " ", "use", " ", "this", ".", " ", "Parti", "cula", "rl", "y", "\\", "10", ";", " ", " ", " ", " ", "usef", "ul", " ", "whe", "n", " ", "a", " ", "system", " ", "group", " ", "is", " ", "defin", "ed", " ", "as", " ", "an", " ", "alias", " ", "type", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "principal_", "(_", "name_", ",_", "cls_", "=_", "Group_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "local", "\\u", "group_", "(_", "name_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "If", " ", "you", " ", "know", " ", "you", "'", "re", " ", "after", " ", "a", " ", "local", " ", "group", ",", " ", "use", " ", "this", ".", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "principal_", "(_", "name_", ",_", "cls_", "=_", "Local", "Group_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "global", "\\u", "group_", "(_", "name_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "If", " ", "you", " ", "know", " ", "you", "'", "re", " ", "after", " ", "a", " ", "global", " ", "group", ",", " ", "use", " ", "this", ".", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "principal_", "(_", "name_", ",_", "cls_", "=_", "Global", "Group_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "me_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "Conve", "nie", "nce", " ", "function", " ", "for", " ", "the", " ", "common", " ", "case", " ", "of", " ", "getti", "ng", " ", "the", "\\", "10", ";", " ", " ", " ", " ", "logged", "-", "on", " ", "user", "'", "s", " ", "account", ".", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "Princip", "al_", "._", "me_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "domain_", "(_", "system_", "=_", "None_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "global_", "\\u", "domain_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "\\u", "domain_", "is_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\\u", "domain_", "=_", "wrapped_", "(_", "win32", "net_", "._", "Net", "Wk", "sta", "Get", "Info_", ",_", "system_", ",_", "100_", ")_", "[_", "'", "lang", "roup", "'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "\\u", "domain_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "domain", "\\u", "controller_", "(_", "domain_", "=_", "None_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "wrapped_", "(_", "win32", "net_", "._", "Net", "Get", "Any", "DC", "Name_", ",_", "None_", ",_", "domain_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "users_", "(_", "system_", "=_", "None_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "Conve", "nie", "nce", " ", "function", " ", "to", " ", "yield", " ", "each", " ", "of", " ", "the", " ", "local", " ", "users", "\\", "10", ";", " ", " ", " ", " ", "on", " ", "a", " ", "system", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", ":", "param", " ", "system", ":", " ", "option", "al", " ", "security", " ", "authori", "ty", "\\", "10", ";", " ", " ", " ", " ", ":", "return", "s", ":", " ", "yield", " ", ":", "class", ":`", "User", "`", " ", "object", "s", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "iter_", "(_", "\\u", "Local", "Users_", "(_", "system_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "class_", "Princip", "al_", "(_", "core_", "._", "\\u", "Win", "Sys", "Object_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "Object", " ", "wrapp", "ing", " ", "a", " ", "Window", "s", " ", "security", " ", "principal", ",", " ", "represent", "ed", " ", "by", " ", "a", " ", "SID", "\\", "10", ";", " ", " ", " ", " ", "and", ",", " ", "where", " ", "possib", "le", ",", " ", "a", " ", "name", ".", " ", ":", "class", ":`", "Princip", "al", "`", " ", "compare", "s", " ", "and", " ", "hashe", "s", "\\", "10", ";", " ", " ", " ", " ", "by", " ", "SID", " ", "so", " ", "can", " ", "be", " ", "sorte", "d", " ", "and", " ", "used", " ", "as", " ", "a", " ", "dictionar", "y", " ", "key", ",", " ", "set", " ", "element", ",", " ", "etc", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "A", " ", ":", "class", ":`", "Princip", "al", "`", " ", "is", " ", "its", " ", "own", " ", "context", " ", "manage", "r", ",", " ", "impersonat", "ing", " ", "the", "\\", "10", ";", " ", " ", " ", " ", "correspond", "ing", " ", "user", "::", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "from", " ", "wins", "ys", " ", "import", " ", "account", "s", "\\", "10", ";", " ", " ", " ", " ", "with", " ", "account", "s", ".", "principal", "(\"", "python", "\"):", "\\", "10", ";", " ", " ", " ", " ", "print", " ", "account", "s", ".", "me", "()", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "Not", "e", ",", " ", "tho", "ugh", ",", " ", "tha", "t", " ", "this", " ", "will", " ", "prompt", " ", "for", " ", "a", " ", "password", " ", "usi", "ng", " ", "the", "\\", "10", ";", " ", " ", " ", " ", "Win", "32", " ", "password", " ", "UI", ".", " ", "To", " ", "logo", "n", " ", "with", " ", "a", " ", "password", ",", " ", "use", " ", "the", " ", ":", "meth", ":`", "impersonat", "e", "`", "\\", "10", ";", " ", " ", " ", " ", "context", "-", "manage", "d", " ", "function", ".", " ", "TOD", "O", ":", " ", "allow", " ", "password", " ", "to", " ", "be", " ", "set", " ", "secure", "ly", ".", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "[SEP]_", "class_", "Princip", "al_", "(_", "core_", "._", "\\u", "Win", "Sys", "Object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "\\u\\u", "init\\u\\u_", "(_", "self_", ",_", "sid_", ",_", "system_", "=_", "None_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "Initialise", " ", "a", " ", "Princip", "al", " ", "from", " ", "and", " ", "(", "option", "ally", ")", " ", "a", " ", "system", " ", "name", ".", " ", "The", " ", "sid", "\\", "10", ";", " ", " ", " ", " ", "must", " ", "be", " ", "a", " ", "Py", "SID", " ", "and", " ", "the", " ", "system", " ", "name", ",", " ", "if", " ", "presen", "t", " ", "must", " ", "be", " ", "a", " ", "security", "\\", "10", ";", " ", " ", " ", " ", "authori", "ty", ",", " ", "eg", " ", "a", " ", "machine", " ", "or", " ", "a", " ", "domain", ".", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "core_", "._", "\\u", "Win", "Sys", "Object_", "._", "\\u\\u", "init\\u\\u_", "(_", "self_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "sid_", "=_", "sid_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "system_", "=_", "system_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "name_", ",_", "self_", "._", "domain_", ",_", "self_", "._", "type_", "=_", "wrapped_", "(_", "win32", "security_", "._", "Look", "up", "Account", "Si", "d_", ",_", "self_", "._", "system_", ",_", "self_", "._", "sid_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "exc_", "._", "x", "\\u", "not", "\\u", "found_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "name_", "=_", "str_", "(_", "self_", "._", "sid_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "domain_", "=_", "self_", "._", "type_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", "~", " ", "if", " ", "self", ".", "system", " ", "is", " ", "Non", "e", ":_", "\\u\\u\\uNL\\u\\u\\u_", "#", "~", " ", "self", ".", "system", " ", "=", " ", "domain", "\\u", "controlle", "r", "(", "self", ".", "domain", ")_", "\\u\\u\\uNL\\u\\u\\u_", "[SEP]_", "class_", "Princip", "al_", "(_", "core_", "._", "\\u", "Win", "Sys", "Object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "\\u\\u", "hash\\u\\u_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "hash_", "(_", "str_", "(_", "self_", "._", "sid_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Princip", "al_", "(_", "core_", "._", "\\u", "Win", "Sys", "Object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "\\u\\u", "eq\\u\\u_", "(_", "self_", ",_", "other_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "self_", "._", "sid_", "==_", "principal_", "(_", "other_", ")_", "._", "sid_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Princip", "al_", "(_", "core_", "._", "\\u", "Win", "Sys", "Object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "\\u\\u", "lt\\u\\u_", "(_", "self_", ",_", "other_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "self_", "._", "sid_", "<_", "principal_", "(_", "other_", ")_", "._", "sid_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Princip", "al_", "(_", "core_", "._", "\\u", "Win", "Sys", "Object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "pyobj", "ect_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "Return", " ", "the", " ", "internal", " ", "represent", "ation", " ", "of", " ", "this", " ", "object", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", ":", "return", "s", ":", " ", "pywi", "n", "32", " ", "SID", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "self_", "._", "sid_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Princip", "al_", "(_", "core_", "._", "\\u", "Win", "Sys", "Object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "as", "\\u", "string_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "self_", "._", "domain_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "\"%", "s", "\\\\", "%", "s", "\"_", "%_", "(_", "self_", "._", "domain_", ",_", "self_", "._", "name_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "self_", "._", "name_", "or_", "str_", "(_", "self_", "._", "sid_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Princip", "al_", "(_", "core_", "._", "\\u", "Win", "Sys", "Object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "dumped", "_", "(_", "self_", ",_", "level_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "utils_", "._", "dumped", "_", "(_", "\"", "user", ":", " ", "%", "s", "\\\\", "nsi", "d", ":", " ", "%", "s", "\"_", "%_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "as", "\\u", "string_", "(_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "wrapped_", "(_", "win32", "security_", "._", "Convert", "Si", "d", "To", "String", "Si", "d_", ",_", "self_", "._", "sid_", ")_", "\\u\\u\\uNL\\u\\u\\u_", ")_", ",_", "level_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Princip", "al_", "(_", "core_", "._", "\\u", "Win", "Sys", "Object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "logo", "n_", "(_", "self_", ",_", "password_", "=_", "core_", "._", "UNS", "ET_", ",_", "logo", "n", "\\u", "type_", "=_", "core_", "._", "UNS", "ET_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "Log", " ", "on", " ", "as", " ", "an", " ", "authenticat", "ed", " ", "user", ",", " ", "return", "ing", " ", "tha", "t", "\\", "10", ";", " ", " ", " ", " ", "user", "'", "s", " ", "token", ".", " ", "Thi", "s", " ", "is", " ", "used", " ", "by", " ", "security", ".", "impersonat", "e", "\\", "10", ";", " ", " ", " ", " ", "whi", "ch", " ", "wrap", "s", " ", "the", " ", "token", " ", "in", " ", "a", " ", "Token", " ", "object", " ", "and", " ", "manage", "s", "\\", "10", ";", " ", " ", " ", " ", "its", " ", "life", "time", " ", "in", " ", "a", " ", "context", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "(", "EXPERIMENT", "AL", ")", " ", "If", " ", "no", " ", "password", " ", "is", " ", "give", "n", ",", " ", "a", " ", "UI", " ", "pops", " ", "up", "\\", "10", ";", " ", " ", " ", " ", "to", " ", "ask", " ", "for", " ", "a", " ", "password", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", ":", "param", " ", "password", ":", " ", "the", " ", "password", " ", "for", " ", "this", " ", "account", "\\", "10", ";", " ", " ", " ", " ", ":", "param", " ", "logo", "n", "\\u", "type", ":", " ", "one", " ", "of", " ", "the", " ", ":", "const", ":`", "LOGO", "N", "`", " ", "values", "\\", "10", ";", " ", " ", " ", " ", ":", "return", "s", ":", " ", "a", " ", "pywi", "n", "32", " ", "handle", " ", "to", " ", "a", " ", "token", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "logo", "n", "\\u", "type_", "is_", "core_", "._", "UNS", "ET_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "logo", "n", "\\u", "type_", "=_", "LOGO", "N_", "._", "LOGO", "N", "\\u", "NETWORK_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "logo", "n", "\\u", "type_", "=_", "LOGO", "N_", "._", "constant_", "(_", "logo", "n", "\\u", "type_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", "~", " ", "if", " ", "password", " ", "is", " ", "core", ".", "UNS", "ET", ":_", "\\u\\u\\uNL\\u\\u\\u_", "#", "~", " ", "password", " ", "=", " ", "dialog", "s", ".", "get", "\\u", "password", "(", "self", ".", "name", ",", " ", "self", ".", "domain", ")_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "h", "User_", "=_", "wrapped_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "win32", "security_", "._", "Logo", "n", "User_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "name_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "domain_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "password_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "logo", "n", "\\u", "type_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "LOGO", "N_", "._", "PROVIDER", "\\u", "DEFAULT_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "h", "User_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Princip", "al_", "(_", "core_", "._", "\\u", "Win", "Sys", "Object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "@_", "classmethod_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "from", "\\u", "string_", "(_", "cls_", ",_", "string_", ",_", "system_", "=_", "None_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "r", "\"\"\"", "Return", " ", "a", " ", ":", "class", ":`", "Princip", "al", "`", " ", "based", " ", "on", " ", "a", " ", "name", " ", "and", " ", "a", "\\", "10", ";", " ", " ", " ", " ", "security", " ", "authori", "ty", ".", " ", "If", " ", "`", "string", "`", " ", "is", " ", "blank", ",", " ", "the", " ", "logged", "-", "on", " ", "user", " ", "is", " ", "assume", "d", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", ":", "param", " ", "string", ":", " ", "name", " ", "of", " ", "an", " ", "account", " ", "in", " ", "the", " ", "form", " ", "\"", "domain", "\\\\", "name", "\".", " ", "domain", " ", "is", " ", "option", "al", " ", "so", " ", "the", " ", "simple", "st", " ", "form", " ", "is", " ", "simp", "ly", " ", "\"", "name", "\"", "\\", "10", ";", " ", " ", " ", " ", ":", "param", " ", "system", ":", " ", "name", " ", "of", " ", "a", " ", "security", " ", "authori", "ty", " ", "(", "typical", "ly", " ", "a", " ", "machine", " ", "or", " ", "a", " ", "domain", ")", "\\", "10", ";", " ", " ", " ", " ", ":", "return", "s", ":", " ", "a", " ", ":", "class", ":`", "Princip", "al", "`", " ", "object", " ", "for", " ", "`", "string", "`", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "string_", "==_", "\"\"_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "string_", "=_", "wrapped_", "(_", "win32", "api_", "._", "Get", "User", "Name", "Ex_", ",_", "win32con_", "._", "Name", "Sam", "Compatible", "_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "sid_", ",_", "domain_", ",_", "type_", "=_", "wrapped_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "win32", "security_", "._", "Look", "up", "Account", "Name_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "None_", "if_", "system_", "is_", "None_", "else_", "unicode_", "(_", "system_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "unicode_", "(_", "string_", ")_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "cls_", "=_", "cls_", "._", "SID", "\\u", "NAME", "\\u", "USE", "\\u", "MAP_", "._", "get_", "(_", "type_", ",_", "cls_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "cls_", "(_", "sid_", ",_", "None_", "if_", "system_", "is_", "None_", "else_", "unicode_", "(_", "system_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Princip", "al_", "(_", "core_", "._", "\\u", "Win", "Sys", "Object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "@_", "classmethod_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "from", "\\u", "sid_", "(_", "cls_", ",_", "sid_", ",_", "system_", "=_", "None_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "Return", " ", "a", " ", ":", "class", ":`", "Princip", "al", "`", " ", "based", " ", "on", " ", "a", " ", "sid", " ", "and", " ", "a", " ", "security", " ", "authori", "ty", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", ":", "param", " ", "sid", ":", " ", "a", " ", "Py", "SID", "\\", "10", ";", " ", " ", " ", " ", ":", "param", " ", "system", "\\u", "name", ":", " ", "option", "al", " ", "name", " ", "of", " ", "a", " ", "security", " ", "authori", "ty", "\\", "10", ";", " ", " ", " ", " ", ":", "return", "s", ":", " ", "a", " ", ":", "class", ":`", "Princip", "al", "`", " ", "object", " ", "for", " ", "`", "sid", "`", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "name_", ",_", "domain_", ",_", "type_", "=_", "wrapped_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "win32", "security_", "._", "Look", "up", "Account", "Si", "d_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "None_", "if_", "system_", "is_", "None_", "else_", "unicode_", "(_", "system_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "sid_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "exc_", "._", "x", "\\u", "not", "\\u", "found_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "name_", "=_", "domain_", "=_", "type_", "=_", "core_", "._", "UNS", "ET_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "cls_", "=_", "cls_", "._", "SID", "\\u", "NAME", "\\u", "USE", "\\u", "MAP_", "._", "get_", "(_", "type_", ",_", "cls_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "cls_", "(_", "sid_", ",_", "None_", "if_", "system_", "is_", "None_", "else_", "unicode_", "(_", "system_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Princip", "al_", "(_", "core_", "._", "\\u", "Win", "Sys", "Object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "@_", "classmethod_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "from", "\\u", "well", "\\u", "known_", "(_", "cls_", ",_", "well", "\\u", "known_", ",_", "domain_", "=_", "None_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "Return", " ", "a", " ", ":", "class", ":`", "Princip", "al", "`", " ", "based", " ", "on", " ", "one", " ", "of", " ", "the", " ", ":", "const", ":`", "WEL", "L", "\\u", "KNOWN", "\\u", "SID", "`", " ", "values", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", ":", "param", " ", "well", "\\u", "know", "n", ":", " ", "one", " ", "of", " ", "the", " ", ":", "const", ":`", "WEL", "L", "\\u", "KNOWN", "\\u", "SID", "`", "\\", "10", ";", " ", " ", " ", " ", ":", "param", " ", "domain", ":", " ", "anyt", "hing", " ", "accept", "ed", " ", "by", " ", ":", "func", ":`", "principal", "`", " ", "and", " ", "correspond", "ing", " ", "to", " ", "a", " ", "domain", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "cls_", "._", "from", "\\u", "sid_", "(_", "wrapped_", "(_", "win32", "security_", "._", "Creat", "e", "Wel", "l", "Kno", "wn", "Si", "d_", ",_", "well", "\\u", "known_", ",_", "principal_", "(_", "domain_", ")_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Princip", "al_", "(_", "core_", "._", "\\u", "Win", "Sys", "Object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "@_", "classmethod_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "me_", "(_", "cls_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "Conve", "nie", "nce", " ", "factor", "y", " ", "method", " ", "for", " ", "the", " ", "common", " ", "case", " ", "of", " ", "refer", "ring", " ", "to", " ", "the", "\\", "10", ";", " ", " ", " ", " ", "logged", "-", "on", " ", "user", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "cls_", "._", "from", "\\u", "string_", "(_", "wrapped_", "(_", "win32", "api_", "._", "Get", "User", "Name", "Ex_", ",_", "EXTEND", "ED", "\\u", "NAME_", "._", "Sam", "Compatible", "_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Princip", "al_", "(_", "core_", "._", "\\u", "Win", "Sys", "Object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "@_", "contextlib_", "._", "contextmanager_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "impersonat", "e_", "(_", "self_", ",_", "password_", "=_", "core_", "._", "UNS", "ET_", ",_", "logo", "n", "\\u", "type_", "=_", "core_", "._", "UNS", "ET_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "Context", "-", "manage", "d", " ", "function", " ", "to", " ", "impersonat", "e", " ", "this", " ", "user", " ", "and", " ", "then", "\\", "10", ";", " ", " ", " ", " ", "revert", "::", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "from", " ", "wins", "ys", " ", "import", " ", "account", "s", ",", " ", "security", "\\", "10", ";", " ", " ", " ", " ", "print", " ", "account", "s", ".", "me", "()", "\\", "10", ";", " ", " ", " ", " ", "python", " ", "=", " ", "account", "s", ".", "principal", "(\"", "python", "\")", "\\", "10", ";", " ", " ", " ", " ", "with", " ", "python", ".", "impersonat", "e", "(\"", "Pa", "5", "5", "w", "0", "rd", "\"):", "\\", "10", ";", " ", " ", " ", " ", "print", " ", "account", "s", ".", "me", "()", "\\", "10", ";", " ", " ", " ", " ", "open", "(\"", "temp", ".", "txt", "\",", " ", "\"", "w", "\")", ".", "close", "()", "\\", "10", ";", " ", " ", " ", " ", "print", " ", "account", "s", ".", "me", "()", "\\", "10", ";", " ", " ", " ", " ", "security", ".", "security", "(\"", "temp", ".", "txt", "\")", ".", "owner", " ", "==", " ", "python", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "Not", "e", " ", "tha", "t", " ", "the", " ", ":", "class", ":`", "Princip", "al", "`", " ", "class", " ", "is", " ", "als", "o", " ", "its", " ", "own", "\\", "10", ";", " ", " ", " ", " ", "context", " ", "manage", "r", " ", "but", " ", "doe", "s", " ", "not", " ", "allow", " ", "the", " ", "password", " ", "to", " ", "be", " ", "specified", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", ":", "param", " ", "password", ":", " ", "password", " ", "for", " ", "this", " ", "account", "\\", "10", ";", " ", " ", " ", " ", ":", "param", " ", "logo", "n", "\\u", "type", ":", " ", "one", " ", "of", " ", "the", " ", ":", "const", ":`", "LOGO", "N", "`", " ", "values", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "h", "Logo", "n_", "=_", "self_", "._", "logo", "n_", "(_", "password_", ",_", "logo", "n", "\\u", "type_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "wrapped_", "(_", "win32", "security_", "._", "Impe", "rson", "ate", "Log", "ged", "On", "User_", ",_", "h", "Logo", "n_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "yield_", "h", "Logo", "n_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "wrapped_", "(_", "win32", "security_", "._", "Rever", "t", "To", "Self", "_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Princip", "al_", "(_", "core_", "._", "\\u", "Win", "Sys", "Object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "\\u\\u", "enter\\u\\u_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "wrapped_", "(_", "win32", "security_", "._", "Impe", "rson", "ate", "Log", "ged", "On", "User_", ",_", "self_", "._", "logo", "n_", "(_", "logo", "n", "\\u", "type_", "=_", "LOGO", "N_", "._", "LOGO", "N", "\\u", "INTER", "ACTIVE_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Princip", "al_", "(_", "core_", "._", "\\u", "Win", "Sys", "Object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "\\u\\u", "exit\\u\\u_", "(_", "self_", ",_", "*_", "exc", "\\u", "info_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "wrapped_", "(_", "win32", "security_", "._", "Rever", "t", "To", "Self", "_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "class_", "User_", "(_", "Princip", "al_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "[SEP]_", "class_", "User_", "(_", "Princip", "al_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "@_", "classmethod_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "create_", "(_", "cls_", ",_", "username_", ",_", "password_", ",_", "system_", "=_", "None_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "Creat", "e", " ", "a", " ", "new", " ", "user", " ", "with", " ", "`", "user", "name", "`", " ", "and", " ", "`", "password", "`.", " ", "Return", "\\", "10", ";", " ", " ", " ", " ", "a", " ", ":", "class", ":`", "User", "`", " ", "for", " ", "the", " ", "new", " ", "user", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", ":", "param", " ", "user", "name", ":", " ", "user", "name", " ", "of", " ", "the", " ", "new", " ", "user", ".", " ", "Mus", "t", " ", "not", " ", "alr", "ead", "y", " ", "exist", " ", "on", " ", "`", "system", "`", "\\", "10", ";", " ", " ", " ", " ", ":", "param", " ", "password", ":", " ", "password", " ", "for", " ", "the", " ", "new", " ", "user", ".", " ", "Mus", "t", " ", "meet", " ", "security", " ", "policy", " ", "on", " ", "`", "system", "`", "\\", "10", ";", " ", " ", " ", " ", ":", "param", " ", "system", ":", " ", "option", "al", " ", "system", " ", "name", "\\", "10", ";", " ", " ", " ", " ", ":", "return", "s", ":", " ", "a", " ", ":", "class", ":`", "User", "`", " ", "for", " ", "`", "user", "name", "`", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "user", "\\u", "info_", "=_", "dict_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "name_", "=_", "username_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "password_", "=_", "password_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "priv_", "=_", "USER", "\\u", "PRIV", "_", "._", "USER_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "home", "\\u", "dir_", "=_", "None_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "comment_", "=_", "None_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "flags_", "=_", "UF", "_", "._", "SCRIPT_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "script", "\\u", "path_", "=_", "None_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "wrapped_", "(_", "win32", "net_", "._", "Net", "User", "Add_", ",_", "system_", ",_", "1_", ",_", "user", "\\u", "info_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "cls_", "._", "from", "\\u", "string_", "(_", "username_", ",_", "system_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "User_", "(_", "Princip", "al_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "delete_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "Delete", " ", "this", " ", "user", " ", "from", " ", "`", "system", "`.", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", ":", "param", " ", "system", ":", " ", "option", "al", " ", "security", " ", "authori", "ty", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "wrapped_", "(_", "win32", "net_", "._", "Net", "User", "Del", "_", ",_", "self_", "._", "system_", ",_", "self_", "._", "name_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "User_", "(_", "Princip", "al_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "groups_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "Yi", "eld", " ", "the", " ", "group", "s", " ", "this", " ", "user", " ", "belo", "ngs", " ", "to", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", ":", "param", " ", "system", ":", " ", "option", "al", " ", "security", " ", "authori", "ty", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "group", "\\u", "name_", ",_", "attributes_", "in_", "wrapped_", "(_", "win32", "net_", "._", "Net", "User", "Get", "Groups_", ",_", "self_", "._", "system_", ",_", "self_", "._", "name_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "yield_", "group_", "(_", "group", "\\u", "name_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "for_", "group", "\\u", "name_", "in_", "wrapped_", "(_", "win32", "net_", "._", "Net", "User", "Get", "Local", "Groups_", ",_", "self_", "._", "system_", ",_", "self_", "._", "name_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "yield_", "group_", "(_", "group", "\\u", "name_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "User_", "(_", "Princip", "al_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "join_", "(_", "self_", ",_", "other", "\\u", "group_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "Add", " ", "this", " ", "user", " ", "to", " ", "a", " ", "group", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", ":", "param", " ", "other", "\\u", "group", ":", " ", "anyt", "hing", " ", "accept", "ed", " ", "by", " ", ":", "func", ":`", "group", "`", "\\", "10", ";", " ", " ", " ", " ", ":", "return", "s", ":", " ", "self", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "group_", "(_", "other", "\\u", "group_", ")_", "._", "add_", "(_", "self_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "User_", "(_", "Princip", "al_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "leave_", "(_", "self_", ",_", "other", "\\u", "group_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "Remove", " ", "this", " ", "user", " ", "from", " ", "a", " ", "group", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", ":", "param", " ", "other", "\\u", "group", ":", " ", "anyt", "hing", " ", "accept", "ed", " ", "by", " ", ":", "func", ":`", "group", "`", "\\", "10", ";", " ", " ", " ", " ", ":", "return", "s", ":", " ", "self", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "group_", "(_", "other", "\\u", "group_", ")_", "._", "remove_", "(_", "self_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "User_", "(_", "Princip", "al_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "runa", "s_", "(_", "self_", ",_", "command", "\\u", "line_", ",_", "password_", "=_", "core_", "._", "UNS", "ET_", ",_", "load", "\\u", "profile_", "=_", "False_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "Run", " ", "a", " ", "command", " ", "logged", " ", "on", " ", "as", " ", "this", " ", "user", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", ":", "param", " ", "command", "\\u", "line", ":", " ", "command", " ", "line", " ", "to", " ", "run", ",", " ", "quoted", " ", "as", " ", "necessar", "y", "\\", "10", ";", " ", " ", " ", " ", ":", "param", " ", "password", ":", " ", "password", ";", " ", "if", " ", "not", " ", "supplie", "d", ",", " ", "standard", " ", "Window", "s", " ", "prompt", "\\", "10", ";", " ", " ", " ", " ", ":", "param", " ", "with", "\\u", "profile", ":", " ", "if", " ", "Tru", "e", ",", " ", "HKEY", "\\u", "CURREN", "T", "\\u", "USER", " ", "is", " ", "load", "ed", " ", "[", "Fal", "se", "]", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", "~", " ", "if", " ", "not", " ", "password", ":_", "\\u\\u\\uNL\\u\\u\\u_", "#", "~", " ", "password", " ", "=", " ", "dialog", "s", ".", "get", "\\u", "password", "(", "self", ".", "name", ",", " ", "self", ".", "domain", ")_", "\\u\\u\\uNL\\u\\u\\u_", "logo", "n", "\\u", "flags_", "=_", "0_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "load", "\\u", "profile_", ":_", "logo", "n", "\\u", "flags_", "|=_", "\\u", "adv", "api", "32_", "._", "LOGO", "N", "\\u", "FLAGS_", "._", "WITH", "\\u", "PROFILE", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "process", "\\u", "info_", "=_", "\\u", "adv", "api", "32_", "._", "Creat", "e", "Process", "With", "Logo", "n", "W_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "username_", "=_", "self_", "._", "name_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "domain_", "=_", "self_", "._", "domain_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "password_", "=_", "password_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "command", "\\u", "line_", "=_", "command", "\\u", "line_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "logo", "n", "\\u", "flags_", "=_", "logo", "n", "\\u", "flags_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Wait", " ", "for", " ", "up", " ", "to", " ", "20", " ", "secs_", "\\u\\u\\uNL\\u\\u\\u_", "#", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", "~", " ", "if", " ", "wrapp", "ed", "(", "win32", "event", ".", "Wait", "For", "Inp", "ut", "Id", "le", ",", " ", "process", "\\u", "info", ".", "h", "Process", ",", " ", "10000", ")", " ", "==", " ", "win32", "event", ".", "WAIT", "\\u", "TIME", "OUT", ":_", "\\u\\u\\uNL\\u\\u\\u_", "#", "~", " ", "raise", " ", "x", "\\u", "account", "s", "(", "errc", "tx", "=\"", "runa", "s", "\",", " ", "err", "msg", "=\"", "runa", "s", " ", "process", " ", "not", " ", "created", " ", "with", " ", "10", " ", "secs", "\")", "_", "\\u\\u\\uNL\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "class_", "Group_", "(_", "Princip", "al_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "SID", "\\u", "NAME", "\\u", "USE", "\\u", "MAP_", "=_", "{_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "[SEP]_", "class_", "Group_", "(_", "Princip", "al_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "\\u\\u", "contains\\u\\u_", "(_", "self_", ",_", "member_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "Cru", "del", "y", ",", " ", "iterate", " ", "over", " ", "the", " ", "group", "'", "s", " ", "member", "s", " ", "unti", "l", " ", "you", " ", "hit", " ", "`", "member", "`", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "member_", "=_", "principal_", "(_", "member_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "any_", "(_", "member_", "==_", "m_", "for_", "m_", "in_", "self_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "class_", "Global", "Group_", "(_", "Group_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\\u", "enum", "erator", "_", "=_", "win32", "net_", "._", "Net", "Group", "Enum_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "[SEP]_", "class_", "Global", "Group_", "(_", "Group_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "@_", "classmethod_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "create_", "(_", "cls_", ",_", "groupname_", ",_", "domain_", "=_", "None_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "Creat", "e", " ", "a", " ", "new", " ", "group", ".", " ", "Return", " ", "a", " ", ":", "class", ":`", "Group", "`", " ", "for", " ", "the", " ", "new", " ", "group", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", ":", "param", " ", "group", "name", ":", " ", "name", " ", "of", " ", "the", " ", "new", " ", "group", ".", " ", "Mus", "t", " ", "not", " ", "alr", "ead", "y", " ", "exist", " ", "on", " ", "`", "system", "`", "\\", "10", ";", " ", " ", " ", " ", ":", "param", " ", "system", ":", " ", "option", "al", " ", "security", " ", "authori", "ty", "\\", "10", ";", " ", " ", " ", " ", ":", "return", "s", ":", " ", "a", " ", ":", "class", ":`", "Group", "`", " ", "for", " ", "`", "group", "name", "`", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "system_", "=_", "domain", "\\u", "controller_", "(_", "domain_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "wrapped_", "(_", "win32", "net_", "._", "Net", "Group", "Add_", ",_", "system_", ",_", "0_", ",_", "dict_", "(_", "name_", "=_", "groupname_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "cls_", "._", "from", "\\u", "string_", "(_", "groupname_", ",_", "system_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Global", "Group_", "(_", "Group_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "delete_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "Delete", " ", "this", " ", "group", " ", "from", " ", "`", "system", "`.", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", ":", "param", " ", "system", ":", " ", "option", "al", " ", "security", " ", "authori", "ty", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "wrapped_", "(_", "win32", "net_", "._", "Net", "Group", "Del", "_", ",_", "self_", "._", "system_", ",_", "self_", "._", "name_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Global", "Group_", "(_", "Group_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "add_", "(_", "self_", ",_", "member_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "Add", " ", "a", " ", ":", "class", ":`", "Princip", "al", "`", " ", "to", " ", "this", " ", "local", " ", "group", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", ":", "param", " ", "member", ":", " ", "anyt", "hing", " ", "accept", "ed", " ", "by", " ", ":", "func", ":`", "principal", "`", "\\", "10", ";", " ", " ", " ", " ", ":", "return", "s", ":", " ", ":", "class", ":`", "Princip", "al", "`", " ", "for", " ", "`", "member", "`", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "member_", "=_", "principal_", "(_", "member_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "wrapped_", "(_", "win32", "net_", "._", "Net", "Group", "Add", "User_", ",_", "self_", "._", "system_", ",_", "self_", "._", "name_", ",_", "r", "\"%", "s", "\\\\", "%", "s", "\"_", "%_", "(_", "member_", "._", "domain_", ",_", "member_", "._", "name_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "member_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Global", "Group_", "(_", "Group_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "remove_", "(_", "self_", ",_", "member_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "Remove", " ", "a", " ", ":", "class", ":`", "Princip", "al", "`", " ", "from", " ", "this", " ", "local", " ", "group", ".", " ", "The", "\\", "10", ";", " ", " ", " ", " ", "principal", " ", "must", " ", "alr", "ead", "y", " ", "be", " ", "a", " ", "member", " ", "of", " ", "the", " ", "group", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", ":", "param", " ", "member", ":", " ", "anyt", "hing", " ", "accept", "ed", " ", "by", " ", ":", "func", ":`", "principal", "`", "\\", "10", ";", " ", " ", " ", " ", ":", "return", "s", ":", " ", ":", "class", ":`", "Princip", "al", "`", " ", "for", " ", "`", "member", "`", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "member_", "=_", "principal_", "(_", "member_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "wrapped_", "(_", "win32", "net_", "._", "Net", "Group", "Del", "User_", ",_", "self_", "._", "system_", ",_", "self_", "._", "name_", ",_", "r", "\"%", "s", "\\\\", "%", "s", "\"_", "%_", "(_", "member_", "._", "domain_", ",_", "member_", "._", "name_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "member_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Global", "Group_", "(_", "Group_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "\\u\\u", "iter\\u\\u_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "Yi", "eld", " ", "the", " ", "list", " ", "of", " ", "member", "s", " ", "of", " ", "this", " ", "group", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", ":", "return", "s", ":", " ", "yield", " ", "a", " ", ":", "class", ":`", "Princip", "al", "`", " ", "or", " ", "subclass", " ", "correspond", "ing", " ", "to", " ", "each", " ", "member", "\\", "10", ";", " ", " ", " ", " ", " ", " ", "of", " ", "this", " ", "group", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "resume_", "=_", "0_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "while_", "True_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "members_", ",_", "total_", ",_", "resume_", "=_", "wrapped_", "(_", "win32", "net_", "._", "Net", "Group", "Get", "Users_", ",_", "self_", "._", "system_", ",_", "self_", "._", "name_", ",_", "1_", ",_", "resume_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "member_", "in_", "members_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "yield_", "principal_", "(_", "member_", "[_", "'", "name", "'_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "resume_", "==_", "0_", ":_", "break_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "class_", "Local", "Group_", "(_", "Group_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "[SEP]_", "class_", "Local", "Group_", "(_", "Group_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "@_", "classmethod_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "create_", "(_", "cls_", ",_", "groupname_", ",_", "system_", "=_", "None_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "Creat", "e", " ", "a", " ", "new", " ", "group", ".", " ", "Return", " ", "a", " ", ":", "class", ":`", "Group", "`", " ", "for", " ", "the", " ", "new", " ", "group", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", ":", "param", " ", "group", "name", ":", " ", "name", " ", "of", " ", "the", " ", "new", " ", "group", ".", " ", "Mus", "t", " ", "not", " ", "alr", "ead", "y", " ", "exist", " ", "on", " ", "`", "system", "`", "\\", "10", ";", " ", " ", " ", " ", ":", "param", " ", "system", ":", " ", "option", "al", " ", "security", " ", "authori", "ty", "\\", "10", ";", " ", " ", " ", " ", ":", "return", "s", ":", " ", "a", " ", ":", "class", ":`", "Group", "`", " ", "for", " ", "`", "group", "name", "`", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "wrapped_", "(_", "win32", "net_", "._", "Net", "Local", "Group", "Add_", ",_", "system_", ",_", "0_", ",_", "dict_", "(_", "name_", "=_", "groupname_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "cls_", "._", "from", "\\u", "string_", "(_", "groupname_", ",_", "system_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Local", "Group_", "(_", "Group_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "delete_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "Delete", " ", "this", " ", "group", " ", "from", " ", "`", "system", "`.", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", ":", "param", " ", "system", ":", " ", "option", "al", " ", "security", " ", "authori", "ty", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "wrapped_", "(_", "win32", "net_", "._", "Net", "Local", "Group", "Del", "_", ",_", "self_", "._", "system_", ",_", "self_", "._", "name_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Local", "Group_", "(_", "Group_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "add_", "(_", "self_", ",_", "member_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "Add", " ", "a", " ", ":", "class", ":`", "Princip", "al", "`", " ", "to", " ", "this", " ", "local", " ", "group", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", ":", "param", " ", "member", ":", " ", "anyt", "hing", " ", "accept", "ed", " ", "by", " ", ":", "func", ":`", "principal", "`", "\\", "10", ";", " ", " ", " ", " ", ":", "return", "s", ":", " ", ":", "class", ":`", "Princip", "al", "`", " ", "for", " ", "`", "member", "`", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "member_", "=_", "principal_", "(_", "member_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "wrapped_", "(_", "win32", "net_", "._", "Net", "Local", "Group", "Add", "Members_", ",_", "self_", "._", "system_", ",_", "self_", "._", "name_", ",_", "0_", ",_", "[_", "dict_", "(_", "sid_", "=_", "member_", "._", "sid_", ")_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "member_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Local", "Group_", "(_", "Group_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "remove_", "(_", "self_", ",_", "member_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "Remove", " ", "a", " ", ":", "class", ":`", "Princip", "al", "`", " ", "from", " ", "this", " ", "local", " ", "group", ".", " ", "The", "\\", "10", ";", " ", " ", " ", " ", "principal", " ", "must", " ", "alr", "ead", "y", " ", "be", " ", "a", " ", "member", " ", "of", " ", "the", " ", "group", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", ":", "param", " ", "member", ":", " ", "anyt", "hing", " ", "accept", "ed", " ", "by", " ", ":", "func", ":`", "principal", "`", "\\", "10", ";", " ", " ", " ", " ", ":", "return", "s", ":", " ", ":", "class", ":`", "Princip", "al", "`", " ", "for", " ", "`", "member", "`", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "member_", "=_", "principal_", "(_", "member_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "wrapped_", "(_", "win32", "net_", "._", "Net", "Local", "Group", "Del", "Members_", ",_", "self_", "._", "system_", ",_", "self_", "._", "name_", ",_", "[_", "\"%", "s", "\\\\\\\\", "%", "s", "\"_", "%_", "(_", "member_", "._", "domain_", ",_", "member_", "._", "name_", ")_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "member_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Local", "Group_", "(_", "Group_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "\\u\\u", "iter\\u\\u_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "Yi", "eld", " ", "the", " ", "list", " ", "of", " ", "member", "s", " ", "of", " ", "this", " ", "group", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", ":", "return", "s", ":", " ", "yield", " ", "a", " ", ":", "class", ":`", "Princip", "al", "`", " ", "or", " ", "subclass", " ", "correspond", "ing", " ", "to", " ", "each", " ", "member", "\\", "10", ";", " ", " ", " ", " ", " ", " ", "of", " ", "this", " ", "group", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "resume_", "=_", "0_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "while_", "True_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "members_", ",_", "total_", ",_", "resume_", "=_", "wrapped_", "(_", "win32", "net_", "._", "Net", "Local", "Group", "Get", "Members_", ",_", "self_", "._", "system_", ",_", "self_", "._", "name_", ",_", "resume_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "member_", "in_", "members_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "yield_", "principal_", "(_", "member_", "[_", "'", "sid", "'_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "resume_", "==_", "0_", ":_", "break_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "local", "\\u", "groups_", "(_", "system_", "=_", "None_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "Conve", "nie", "nce", " ", "function", " ", "to", " ", "yield", " ", "each", " ", "of", " ", "the", " ", "local", " ", "users", "\\", "10", ";", " ", " ", " ", " ", "on", " ", "a", " ", "system", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", ":", "param", " ", "system", ":", " ", "option", "al", " ", "security", " ", "authori", "ty", "\\", "10", ";", " ", " ", " ", " ", ":", "return", "s", ":", " ", "yield", " ", ":", "class", ":`", "Local", "Group", "`", " ", "object", "s", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "group_", "in_", "\\u", "win32", "net", "\\u", "enum_", "(_", "win32", "net_", "._", "Net", "Local", "Group", "Enum_", ",_", "system_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "yield_", "Local", "Group_", "._", "from", "\\u", "string_", "(_", "group_", "[_", "'", "name", "'_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "global", "\\u", "groups_", "(_", "domain_", "=_", "None_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "Conve", "nie", "nce", " ", "function", " ", "to", " ", "yield", " ", "each", " ", "of", " ", "the", " ", "local", " ", "users", "\\", "10", ";", " ", " ", " ", " ", "on", " ", "a", " ", "system", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", ":", "param", " ", "domain", ":", " ", "option", "al", " ", "security", " ", "domain", "\\", "10", ";", " ", " ", " ", " ", ":", "return", "s", ":", " ", "yield", " ", ":", "class", ":`", "Global", "Group", "`", " ", "object", "s", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "group_", "in_", "\\u", "win32", "net", "\\u", "enum_", "(_", "win32", "net_", "._", "Net", "Group", "Enum_", ",_", "domain", "\\u", "controller_", "(_", "domain_", ")_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "yield_", "Global", "Group_", "._", "from", "\\u", "string_", "(_", "group_", "[_", "'", "name", "'_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "class_", "\\u", "Local", "Users_", "(_", "object_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "[SEP]_", "class_", "\\u", "Local", "Users_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "def_", "\\u\\u", "init\\u\\u_", "(_", "self_", ",_", "system_", "=_", "None_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "system_", "=_", "system_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "\\u", "Local", "Users_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "\\u\\u", "iter\\u\\u_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "resume_", "=_", "0_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "while_", "True_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "users_", ",_", "total_", ",_", "resume_", "=_", "wrapped_", "(_", "win32", "net_", "._", "Net", "User", "Enum_", ",_", "self_", "._", "system_", ",_", "0_", ",_", "FILTER_", "._", "NORMA", "L", "\\u", "ACCOUNT", "_", ",_", "resume_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "user_", "in_", "users_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "yield_", "User_", "._", "from", "\\u", "string_", "(_", "user_", "[_", "'", "name", "'_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "resume_", "==_", "0_", ":_", "break_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "\\u", "Local", "Users_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "add_", "(_", "self_", ",_", "username_", ",_", "password_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "User_", "._", "create_", "(_", "username_", ",_", "password_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "\\u", "Local", "Users_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL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2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 ]
Unused import
hpssjellis/easy-tensorflow-on-cloud9/bcomposes-examples/hidden-backup.py
[ { "content": "import tensorflow.python.platform\n\nimport numpy as np\nimport tensorflow as tf\n\n# Global variables.\nNUM_LABELS = 2 # The number of labels.\nBATCH_SIZE = 100 # The number of training examples to use per training step.\n\ntf.app.flags.DEFINE_string('train', None,\n 'File containing the training data (labels & features).')\ntf.app.flags.DEFINE_string('test', None,\n 'File containing the test data (labels & features).')\ntf.app.flags.DEFINE_integer('num_epochs', 1,\n 'Number of passes over the training data.')\ntf.app.flags.DEFINE_integer('num_hidden', 1,\n 'Number of nodes in the hidden layer.')\ntf.app.flags.DEFINE_boolean('verbose', False, 'Produce verbose output.')\nFLAGS = tf.app.flags.FLAGS\n\n# Extract numpy representations of the labels and features given rows consisting of:\n# label, feat_0, feat_1, ..., feat_n\n\n# Init weights method. (Lifted from Delip Rao: http://deliprao.com/archives/100)\n \n \nif __name__ == '__main__':\n tf.app.run()\n", "metadata": "root", "header": "['module', '___EOS___']", "index": 0 }, { "content": "def extract_data(filename):\n\n # Arrays to hold the labels and feature vectors.\n labels = []\n fvecs = []\n\n # Iterate over the rows, splitting the label from the features. Convert labels\n # to integers and features to floats.\n for line in file(filename):\n row = line.split(\",\")\n labels.append(int(row[0]))\n fvecs.append([float(x) for x in row[1:]])\n\n # Convert the array of float arrays into a numpy float matrix.\n fvecs_np = np.matrix(fvecs).astype(np.float32)\n\n # Convert the array of int labels into a numpy array.\n labels_np = np.array(labels).astype(dtype=np.uint8)\n\n # Convert the int numpy array into a one-hot matrix.\n labels_onehot = (np.arange(NUM_LABELS) == labels_np[:, None]).astype(np.float32)\n\n # Return a pair of the feature matrix and the one-hot label matrix.\n return fvecs_np,labels_onehot", "metadata": "root.extract_data", "header": "['module', '___EOS___']", "index": 22 }, { "content": "def init_weights(shape, init_method='xavier', xavier_params = (None, None)):\n if init_method == 'zeros':\n return tf.Variable(tf.zeros(shape, dtype=tf.float32))\n elif init_method == 'uniform':\n return tf.Variable(tf.random_normal(shape, stddev=0.01, dtype=tf.float32))\n else: #xavier\n (fan_in, fan_out) = xavier_params\n low = -4*np.sqrt(6.0/(fan_in + fan_out)) # {sigmoid:4, tanh:1} \n high = 4*np.sqrt(6.0/(fan_in + fan_out))\n return tf.Variable(tf.random_uniform(shape, minval=low, maxval=high, dtype=tf.float32))", "metadata": "root.init_weights", "header": "['module', '___EOS___']", "index": 48 }, { "content": "def main(argv=None):\n # Be verbose?\n verbose = FLAGS.verbose\n \n # Get the data.\n train_data_filename = FLAGS.train\n test_data_filename = FLAGS.test\n\n # Extract it into numpy arrays.\n train_data,train_labels = extract_data(train_data_filename)\n test_data, test_labels = extract_data(test_data_filename)\n\n # Get the shape of the training data.\n train_size,num_features = train_data.shape\n\n # Get the number of epochs for training.\n num_epochs = FLAGS.num_epochs\n\n # Get the size of layer one.\n num_hidden = FLAGS.num_hidden\n \n # This is where training samples and labels are fed to the graph.\n # These placeholder nodes will be fed a batch of training data at each\n # training step using the {feed_dict} argument to the Run() call below.\n x = tf.placeholder(\"float\", shape=[None, num_features])\n y_ = tf.placeholder(\"float\", shape=[None, NUM_LABELS])\n \n # For the test data, hold the entire dataset in one constant node.\n test_data_node = tf.constant(test_data)\n\n # Define and initialize the network.\n\n # Initialize the hidden weights and biases.\n w_hidden = init_weights(\n [num_features, num_hidden],\n 'xavier',\n xavier_params=(num_features, num_hidden))\n\n b_hidden = init_weights([1,num_hidden],'zeros')\n\n # The hidden layer.\n hidden = tf.nn.tanh(tf.matmul(x,w_hidden) + b_hidden)\n\n # Initialize the output weights and biases.\n w_out = init_weights(\n [num_hidden, NUM_LABELS],\n 'xavier',\n xavier_params=(num_hidden, NUM_LABELS))\n \n b_out = init_weights([1,NUM_LABELS],'zeros')\n\n # The output layer.\n y = tf.nn.softmax(tf.matmul(hidden, w_out) + b_out)\n \n # Optimization.\n cross_entropy = -tf.reduce_sum(y_*tf.log(y))\n train_step = tf.train.GradientDescentOptimizer(0.01).minimize(cross_entropy)\n \n # Evaluation.\n correct_prediction = tf.equal(tf.argmax(y,1), tf.argmax(y_,1))\n accuracy = tf.reduce_mean(tf.cast(correct_prediction, \"float\"))\n\n # Create a local session to run this computation.\n with tf.Session() as s:\n # Run all the initializers to prepare the trainable parameters.\n \ttf.initialize_all_variables().run()\n \tif verbose:\n \t print 'Initialized!'\n \t print\n \t print 'Training.'\n \t \n \t# Iterate and train.\n \tfor step in xrange(num_epochs * train_size // BATCH_SIZE):\n \t if verbose:\n \t print step,\n \t \n \t offset = (step * BATCH_SIZE) % train_size\n \t batch_data = train_data[offset:(offset + BATCH_SIZE), :]\n \t batch_labels = train_labels[offset:(offset + BATCH_SIZE)]\n \t train_step.run(feed_dict={x: batch_data, y_: batch_labels})\n \t if verbose and offset >= train_size-BATCH_SIZE:\n \t print\n \tprint \"Accuracy:\", accuracy.eval(feed_dict={x: test_data, y_: test_labels})", "metadata": "root.main", "header": "['module', '___EOS___']", "index": 59 } ]
[ { "span": "import tensorflow.python.platform", "start_line": 0, "start_column": 0, "end_line": 0, "end_column": 33 } ]
[]
1
false
[ "[CLS]_", "Un", "used_", "import_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "import_", "tensorflow_", "._", "python_", "._", "platform_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "import_", "numpy_", "as_", "np_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "tensorflow_", "as_", "tf_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Global", " ", "variab", "les", "._", "\\u\\u\\uNL\\u\\u\\u_", "NUM", "\\u", "LABELS_", "=_", "2_", "#", " ", "The", " ", "number", " ", "of", " ", "labels", "._", "\\u\\u\\uNEWLINE\\u\\u\\u_", "BATCH", "\\u", "SIZE_", "=_", "100_", "#", " ", "The", " ", "number", " ", "of", " ", "train", "ing", " ", "example", "s", " ", "to", " ", "use", " ", "per", " ", "train", "ing", " ", "step", "._", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "tf_", "._", "app_", "._", "flags_", "._", "DEFINE", "\\u", "string_", "(_", "'", "train", "'_", ",_", "None_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "File", " ", "contain", "ing", " ", "the", " ", "train", "ing", " ", "data", " ", "(", "labels", " ", "&", " ", "features", ").'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "tf_", "._", "app_", "._", "flags_", "._", "DEFINE", "\\u", "string_", "(_", "'", "test", "'_", ",_", "None_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "File", " ", "contain", "ing", " ", "the", " ", "test", " ", "data", " ", "(", "labels", " ", "&", " ", "features", ").'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "tf_", "._", "app_", "._", "flags_", "._", "DEFINE", "\\u", "integer_", "(_", "'", "num", "\\u", "epoch", "s", "'_", ",_", "1_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "Number", " ", "of", " ", "pass", "es", " ", "over", " ", "the", " ", "train", "ing", " ", "data", ".'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "tf_", "._", "app_", "._", "flags_", "._", "DEFINE", "\\u", "integer_", "(_", "'", "num", "\\u", "hidden", "'_", ",_", "1_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "Number", " ", "of", " ", "nodes", " ", "in", " ", "the", " ", "hidden", " ", "layer", ".'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "tf_", "._", "app_", "._", "flags_", "._", "DEFINE", "\\u", "boolean_", "(_", "'", "verbo", "se", "'_", ",_", "False_", ",_", "'", "Produce", " ", "verbo", "se", " ", "output", ".'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "FLAGS_", "=_", "tf_", "._", "app_", "._", "flags_", "._", "FLAGS_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Extract", " ", "nump", "y", " ", "representations", " ", "of", " ", "the", " ", "labels", " ", "and", " ", "features", " ", "give", "n", " ", "rows", " ", "consi", "stin", "g", " ", "of", ":_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", " ", " ", "label", ",", " ", "feat", "\\u", "0", ",", " ", "feat", "\\u", "1", ",", " ", "...", ",", " ", "feat", "\\u", "n_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Ini", "t", " ", "weight", "s", " ", "method", ".", " ", "(", "Lif", "ted", " ", "from", " ", "Del", "ip", " ", "Ra", "o", ":", " ", "http", "://", "deli", "pra", "o", ".", "com", "/", "archives", "/", "100", ")_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "\\u\\u", "name\\u\\u_", "==_", "'\\u", "\\u", "main", "\\u\\u'_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "tf_", "._", "app_", "._", "run_", "(_", ")_", "\\u\\u\\uDEDENT\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "extract", "\\u", "data_", "(_", "filename_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Arrays", " ", "to", " ", "hold", " ", "the", " ", "labels", " ", "and", " ", "feature", " ", "vector", "s", "._", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "labels_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "fv", "ecs_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Iterat", "e", " ", "over", " ", "the", " ", "rows", ",", " ", "splitting", " ", "the", " ", "label", " ", "from", " ", "the", " ", "features", ".", " ", "Convert", " ", "labels_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "to", " ", "integ", "ers", " ", "and", " ", "features", " ", "to", " ", "float", "s", "._", "\\u\\u\\uNL\\u\\u\\u_", "for_", "line_", "in_", "file_", "(_", "filename_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "row_", "=_", "line_", "._", "split_", "(_", "\",\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "labels_", "._", "append_", "(_", "int_", "(_", "row_", "[_", "0_", "]_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "fv", "ecs_", "._", "append_", "(_", "[_", "float_", "(_", "x_", ")_", "for_", "x_", "in_", "row_", "[_", "1_", ":_", "]_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Convert", " ", "the", " ", "array", " ", "of", " ", "float", " ", "arrays", " ", "int", "o", " ", "a", " ", "nump", "y", " ", "float", " ", "matrix", "._", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "fv", "ecs", "\\u", "np_", "=_", "np_", "._", "matrix_", "(_", "fv", "ecs_", ")_", "._", "astype_", "(_", "np_", "._", "float32_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Convert", " ", "the", " ", "array", " ", "of", " ", "int", " ", "labels", " ", "int", "o", " ", "a", " ", "nump", "y", " ", "array", "._", "\\u\\u\\uNL\\u\\u\\u_", "labels", "\\u", "np_", "=_", "np_", "._", "array_", "(_", "labels_", ")_", "._", "astype_", "(_", "dtype_", "=_", "np_", "._", "uint8_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Convert", " ", "the", " ", "int", " ", "nump", "y", " ", "array", " ", "int", "o", " ", "a", " ", "one", "-", "hot", " ", "matrix", "._", "\\u\\u\\uNL\\u\\u\\u_", "labels", "\\u", "one", "hot_", "=_", "(_", "np_", "._", "arange_", "(_", "NUM", "\\u", "LABELS_", ")_", "==_", "labels", "\\u", "np_", "[_", ":_", ",_", "None_", "]_", ")_", "._", "astype_", "(_", "np_", "._", "float32_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Return", " ", "a", " ", "pair", " ", "of", " ", "the", " ", "feature", " ", "matrix", " ", "and", " ", "the", " ", "one", "-", "hot", " ", "label", " ", "matrix", "._", "\\u\\u\\uNL\\u\\u\\u_", "return_", "fv", "ecs", "\\u", "np_", ",_", "labels", "\\u", "one", "hot_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "init", "\\u", "weights_", "(_", "shape_", ",_", "init", "\\u", "method_", "=_", "'", "xa", "vie", "r", "'_", ",_", "xa", "vie", "r", "\\u", "params_", "=_", "(_", "None_", ",_", "None_", ")_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "init", "\\u", "method_", "==_", "'", "zero", "s", "'_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "tf_", "._", "Variable_", "(_", "tf_", "._", "zeros_", "(_", "shape_", ",_", "dtype_", "=_", "tf_", "._", "float32_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "init", "\\u", "method_", "==_", "'", "uniform", "'_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "tf_", "._", "Variable_", "(_", "tf_", "._", "random", "\\u", "normal_", "(_", "shape_", ",_", "stddev_", "=_", "0.01_", ",_", "dtype_", "=_", "tf_", "._", "float32_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "#", "xa", "vie", "r_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "(_", "fan", "\\u", "in_", ",_", "fan", "\\u", "out_", ")_", "=_", "xa", "vie", "r", "\\u", "params_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "low_", "=_", "-_", "4_", "*_", "np_", "._", "sqrt_", "(_", "6.0_", "/_", "(_", "fan", "\\u", "in_", "+_", "fan", "\\u", "out_", ")_", ")_", "#", " ", "{", "sigm", "oid", ":", "4", ",", " ", "tan", "h", ":", "1", "}", " _", "\\u\\u\\uNEWLINE\\u\\u\\u_", "high_", "=_", "4_", "*_", "np_", "._", "sqrt_", "(_", "6.0_", "/_", "(_", "fan", "\\u", "in_", "+_", "fan", "\\u", "out_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "tf_", "._", "Variable_", "(_", "tf_", "._", "random", "\\u", "uniform_", "(_", "shape_", ",_", "minval_", "=_", "low_", ",_", "maxval_", "=_", "high_", ",_", "dtype_", "=_", "tf_", "._", "float32_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "main_", "(_", "argv_", "=_", "None_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Be", " ", "verbo", "se", "?", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "verbose_", "=_", "FLAGS_", "._", "verbose_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Get", " ", "the", " ", "data", "._", "\\u\\u\\uNL\\u\\u\\u_", "train", "\\u", "data\\u", "filename_", "=_", "FLAGS_", "._", "train_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "test\\u", "data\\u", "filename_", "=_", "FLAGS_", "._", "test_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Extract", " ", "it", " ", "int", "o", " ", "nump", "y", " ", "arrays", "._", "\\u\\u\\uNL\\u\\u\\u_", "train", "\\u", "data_", ",_", "train", "\\u", "labels_", "=_", "extract", "\\u", "data_", "(_", "train", "\\u", "data\\u", "filename_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "test\\u", "data_", ",_", "test\\u", "labels_", "=_", "extract", "\\u", "data_", "(_", "test\\u", "data\\u", "filename_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Get", " ", "the", " ", "shape", " ", "of", " ", "the", " ", "train", "ing", " ", "data", "._", "\\u\\u\\uNL\\u\\u\\u_", "train", "\\u", "size_", ",_", "num", "\\u", "features_", "=_", "train", "\\u", "data_", "._", "shape_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Get", " ", "the", " ", "number", " ", "of", " ", "epoch", "s", " ", "for", " ", "train", "ing", "._", "\\u\\u\\uNL\\u\\u\\u_", "num", "\\u", "epochs_", "=_", "FLAGS_", "._", "num", "\\u", "epochs_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Get", " ", "the", " ", "size", " ", "of", " ", "layer", " ", "one", "._", "\\u\\u\\uNL\\u\\u\\u_", "num", "\\u", "hidden_", "=_", "FLAGS_", "._", "num", "\\u", "hidden_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Thi", "s", " ", "is", " ", "where", " ", "train", "ing", " ", "samples", " ", "and", " ", "labels", " ", "are", " ", "fed", " ", "to", " ", "the", " ", "graph", "._", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "The", "se", " ", "placehold", "er", " ", "nodes", " ", "will", " ", "be", " ", "fed", " ", "a", " ", "batch", " ", "of", " ", "train", "ing", " ", "data", " ", "at", " ", "each_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "train", "ing", " ", "step", " ", "usi", "ng", " ", "the", " ", "{", "feed", "\\u", "dict", "}", " ", "argu", "ment", " ", "to", " ", "the", " ", "Run", "()", " ", "call", " ", "belo", "w", "._", "\\u\\u\\uNL\\u\\u\\u_", "x_", "=_", "tf_", "._", "placeholder_", "(_", "\"", "float", "\"_", ",_", "shape_", "=_", "[_", "None_", ",_", "num", "\\u", "features_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "y\\u_", "=_", "tf_", "._", "placeholder_", "(_", "\"", "float", "\"_", ",_", "shape_", "=_", "[_", "None_", ",_", "NUM", "\\u", "LABELS_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "For", " ", "the", " ", "test", " ", "data", ",", " ", "hold", " ", "the", " ", "entire", " ", "dataset", " ", "in", " ", "one", " ", "constant", " ", "node", "._", "\\u\\u\\uNL\\u\\u\\u_", "test\\u", "data\\u", "node_", "=_", "tf_", "._", "constant_", "(_", "test\\u", "data_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Define", " ", "and", " ", "initialize", " ", "the", " ", "network", "._", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Initializ", "e", " ", "the", " ", "hidden", " ", "weight", "s", " ", "and", " ", "bias", "es", "._", "\\u\\u\\uNL\\u\\u\\u_", "w", "\\u", "hidden_", "=_", "init", "\\u", "weights_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "[_", "num", "\\u", "features_", ",_", "num", "\\u", "hidden_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "xa", "vie", "r", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "xa", "vie", "r", "\\u", "params_", "=_", "(_", "num", "\\u", "features_", ",_", "num", "\\u", "hidden_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "b", "\\u", "hidden_", "=_", "init", "\\u", "weights_", "(_", "[_", "1_", ",_", "num", "\\u", "hidden_", "]_", ",_", "'", "zero", "s", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "The", " ", "hidden", " ", "layer", "._", "\\u\\u\\uNL\\u\\u\\u_", "hidden_", "=_", "tf_", "._", "nn_", "._", "tanh_", "(_", "tf_", "._", "matmul_", "(_", "x_", ",_", "w", "\\u", "hidden_", ")_", "+_", "b", "\\u", "hidden_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Initializ", "e", " ", "the", " ", "output", " ", "weight", "s", " ", "and", " ", "bias", "es", "._", "\\u\\u\\uNL\\u\\u\\u_", "w", "\\u", "out_", "=_", "init", "\\u", "weights_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "[_", "num", "\\u", "hidden_", ",_", "NUM", "\\u", "LABELS_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "xa", "vie", "r", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "xa", "vie", "r", "\\u", "params_", "=_", "(_", "num", "\\u", "hidden_", ",_", "NUM", "\\u", "LABELS_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "b", "\\u", "out_", "=_", "init", "\\u", "weights_", "(_", "[_", "1_", ",_", "NUM", "\\u", "LABELS_", "]_", ",_", "'", "zero", "s", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "The", " ", "output", " ", "layer", "._", "\\u\\u\\uNL\\u\\u\\u_", "y_", "=_", "tf_", "._", "nn_", "._", "softmax_", "(_", "tf_", "._", "matmul_", "(_", "hidden_", ",_", "w", "\\u", "out_", ")_", "+_", "b", "\\u", "out_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Optim", "izatio", "n", "._", "\\u\\u\\uNL\\u\\u\\u_", "cross", "\\u", "entropy_", "=_", "-_", "tf_", "._", "reduce", "\\u", "sum_", "(_", "y\\u_", "*_", "tf_", "._", "log_", "(_", "y_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "train", "\\u", "step_", "=_", "tf_", "._", "train_", "._", "Grad", "ient", "Descen", "t", "Optimizer_", "(_", "0.01_", ")_", "._", "minimize_", "(_", "cross", "\\u", "entropy_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Evaluati", "on", "._", "\\u\\u\\uNL\\u\\u\\u_", "correct", "\\u", "prediction_", "=_", "tf_", "._", "equal_", "(_", "tf_", "._", "argmax_", "(_", "y_", ",_", "1_", ")_", ",_", "tf_", "._", "argmax_", "(_", "y\\u_", ",_", "1_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "accuracy_", "=_", "tf_", "._", "reduce", "\\u", "mean_", "(_", "tf_", "._", "cast_", "(_", "correct", "\\u", "prediction_", ",_", "\"", "float", "\"_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Creat", "e", " ", "a", " ", "local", " ", "session", " ", "to", " ", "run", " ", "this", " ", "computation", "._", "\\u\\u\\uNL\\u\\u\\u_", "with_", "tf_", "._", "Session_", "(_", ")_", "as_", "s_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Run", " ", "all", " ", "the", " ", "initializer", "s", " ", "to", " ", "prepar", "e", " ", "the", " ", "train", "able", " ", "parameter", "s", "._", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " \t_", "tf_", "._", "initialize", "\\u", "all", "\\u", "variables_", "(_", ")_", "._", "run_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "verbose_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " \t", " _", "print_", "'", "Initialized", "!'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "print_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "print_", "'", "Train", "ing", ".'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Iterat", "e", " ", "and", " ", "train", "._", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "for_", "step_", "in_", "xrange_", "(_", "num", "\\u", "epochs_", "*_", "train", "\\u", "size_", "//_", "BATCH", "\\u", "SIZE_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " \t", " _", "if_", "verbose_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " \t", " _", "print_", "step_", ",_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "offset_", "=_", "(_", "step_", "*_", "BATCH", "\\u", "SIZE_", ")_", "%_", "train", "\\u", "size_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "batch", "\\u", "data_", "=_", "train", "\\u", "data_", "[_", "offset_", ":_", "(_", "offset_", "+_", "BATCH", "\\u", "SIZE_", ")_", ",_", ":_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "batch", "\\u", "labels_", "=_", "train", "\\u", "labels_", "[_", "offset_", ":_", "(_", "offset_", "+_", "BATCH", "\\u", "SIZE_", ")_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "train", "\\u", "step_", "._", "run_", "(_", "feed", "\\u", "dict_", "=_", "{_", "x_", ":_", "batch", "\\u", "data_", ",_", "y\\u_", ":_", "batch", "\\u", "labels_", "}_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "verbose_", "and_", "offset_", ">=_", "train", "\\u", "size_", "-_", "BATCH", "\\u", "SIZE_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " \t", " _", "print_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uD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ode, depth, axisDisposition, facts, i=None, tblAxisRels=None, processOpenDefinitionNode=True):\n subtreeRelationships = view.axisSubtreeRelSet.fromModelObject(definitionNode)\n \n def checkLabelWidth(structuralNode, checkBoundFact=False):\n if axisDisposition == \"y\":\n # messages can't be evaluated, just use the text portion of format string\n label = structuralNode.header(lang=view.lang, \n returnGenLabel=not checkBoundFact, \n returnMsgFormatString=not checkBoundFact)\n if label:\n # need to et more exact word length in screen units\n widestWordLen = max(len(w) * RENDER_UNITS_PER_CHAR for w in label.split())\n # abstract only pertains to subtree of closed nodesbut not cartesian products or open nodes\n while structuralNode.depth >= len(view.rowHdrColWidth):\n view.rowHdrColWidth.append(0)\n if definitionNode.isAbstract or not subtreeRelationships: # isinstance(definitionNode, ModelOpenDefinitionNode): \n if widestWordLen > view.rowHdrColWidth[structuralNode.depth]:\n view.rowHdrColWidth[structuralNode.depth] = widestWordLen\n else:\n if widestWordLen > view.rowNonAbstractHdrSpanMin[structuralNode.depth]:\n view.rowNonAbstractHdrSpanMin[structuralNode.depth] = widestWordLen\n \n if axisDisposition == \"z\" and structuralNode.aspects is None:\n structuralNode.aspects = view.zOrdinateChoices.get(definitionNode, None)\n if structuralNode and isinstance(definitionNode, (ModelBreakdown, ModelEuAxisCoord, ModelDefinitionNode)):\n try:\n \n #cartesianProductNestedArgs = (view, depth, axisDisposition, facts, tblAxisRels, i)\n ordCardinality, ordDepth = definitionNode.cardinalityAndDepth(structuralNode)\n if (not definitionNode.isAbstract and\n isinstance(definitionNode, ModelClosedDefinitionNode) and \n ordCardinality == 0):\n view.modelXbrl.error(\"xbrlte:closedDefinitionNodeZeroCardinality\",\n _(\"Closed definition node %(xlinkLabel)s does not contribute at least one structural node\"),\n modelObject=(view.modelTable,definitionNode), xlinkLabel=definitionNode.xlinkLabel, axis=definitionNode.localName)\n nestedDepth = depth + ordDepth\n # HF test\n cartesianProductNestedArgs = [view, nestedDepth, axisDisposition, facts, tblAxisRels, i]\n if axisDisposition == \"z\":\n if depth == 1: # choices (combo boxes) don't add to z row count\n view.zAxisRows += 1 \n elif axisDisposition == \"x\":\n if ordDepth:\n if nestedDepth - 1 > view.colHdrRows:\n view.colHdrRows = nestedDepth - 1\n '''\n if not view.colHdrDocRow:\n if definitionNode.header(role=\"http://www.xbrl.org/2008/role/documentation\",\n lang=view.lang): \n view.colHdrDocRow = True\n if not view.colHdrCodeRow:\n if definitionNode.header(role=\"http://www.eurofiling.info/role/2010/coordinate-code\"): \n view.colHdrCodeRow = True\n '''\n hdrNonStdRoles = view.colHdrNonStdRoles\n elif axisDisposition == \"y\":\n if ordDepth:\n #if not definitionNode.isAbstract:\n # view.dataRows += ordCardinality\n if nestedDepth - 1 > view.rowHdrCols: \n view.rowHdrCols = nestedDepth - 1\n for j in range(1 + ordDepth):\n view.rowHdrColWidth.append(RENDER_UNITS_PER_CHAR) # min width for 'tail' of nonAbstract coordinate\n view.rowNonAbstractHdrSpanMin.append(0)\n checkLabelWidth(structuralNode, checkBoundFact=False)\n ''' \n if not view.rowHdrDocCol:\n if definitionNode.header(role=\"http://www.xbrl.org/2008/role/documentation\",\n lang=view.lang): \n view.rowHdrDocCol = True\n if not view.rowHdrCodeCol:\n if definitionNode.header(role=\"http://www.eurofiling.info/role/2010/coordinate-code\"): \n view.rowHdrCodeCol = True\n '''\n hdrNonStdRoles = view.rowHdrNonStdRoles\n if axisDisposition in (\"x\", \"y\"):\n hdrNonStdPosition = -1 # where a match last occured\n for rel in view.modelXbrl.relationshipSet(XbrlConst.elementLabel).fromModelObject(definitionNode):\n if rel.toModelObject is not None and rel.toModelObject.role != XbrlConst.genStandardLabel:\n labelLang = rel.toModelObject.xmlLang\n labelRole = rel.toModelObject.role\n if (labelLang == view.lang or labelLang.startswith(view.lang) or view.lang.startswith(labelLang)\n or (\"code\" in labelRole)):\n labelRole = rel.toModelObject.role\n if labelRole in hdrNonStdRoles:\n hdrNonStdPosition = hdrNonStdRoles.index(labelRole)\n else:\n hdrNonStdRoles.insert(hdrNonStdPosition + 1, labelRole)\n isCartesianProductExpanded = False\n if not isinstance(definitionNode, ModelFilterDefinitionNode):\n isCartesianProductExpanded = True\n # note: reduced set of facts should always be passed to subsequent open nodes\n for axisSubtreeRel in subtreeRelationships:\n childDefinitionNode = axisSubtreeRel.toModelObject\n if childDefinitionNode.isRollUp:\n structuralNode.rollUpStructuralNode = StructuralNode(structuralNode, breakdownNode, childDefinitionNode, )\n if not structuralNode.childStructuralNodes: # first sub ordinate is the roll up\n structuralNode.subtreeRollUp = CHILD_ROLLUP_FIRST\n else: \n structuralNode.subtreeRollUp = CHILD_ROLLUP_LAST\n if not view.topRollup.get(axisDisposition):\n view.topRollup[axisDisposition] = structuralNode.subtreeRollUp\n else:\n if (isinstance(definitionNode, (ModelBreakdown, ModelCompositionDefinitionNode)) and\n isinstance(childDefinitionNode, ModelRelationshipDefinitionNode)): # append list products to composititionAxes subObjCntxs\n childStructuralNode = structuralNode\n else:\n childStructuralNode = StructuralNode(structuralNode, breakdownNode, childDefinitionNode) # others are nested structuralNode\n if axisDisposition != \"z\":\n structuralNode.childStructuralNodes.append(childStructuralNode)\n if axisDisposition != \"z\":\n expandDefinition(view, childStructuralNode, breakdownNode, childDefinitionNode, depth+ordDepth, axisDisposition, facts, i, tblAxisRels) #recurse\n if not childContainsOpenNodes(childStructuralNode) :\n # To be computed only if the structural node does not contain an open node\n cartesianProductExpander(childStructuralNode, *cartesianProductNestedArgs)\n else:\n childStructuralNode.indent = depth - 1\n if structuralNode.choiceStructuralNodes is not None:\n structuralNode.choiceStructuralNodes.append(childStructuralNode)\n expandDefinition(view, childStructuralNode, breakdownNode, childDefinitionNode, depth + 1, axisDisposition, facts) #recurse\n # required when switching from abstract to roll up to determine abstractness\n #if not structuralNode.subtreeRollUp and structuralNode.childStructuralNodes and definitionNode.tag.endswith(\"Node\"):\n # structuralNode.subtreeRollUp = CHILDREN_BUT_NO_ROLLUP\n \n #if not hasattr(structuralNode, \"indent\"): # probably also for multiple open axes\n if processOpenDefinitionNode:\n if isinstance(definitionNode, ModelRelationshipDefinitionNode):\n structuralNode.isLabeled = False\n selfStructuralNodes = {} if definitionNode.axis.endswith('-or-self') else None\n for rel in definitionNode.relationships(structuralNode):\n if not isinstance(rel, list):\n relChildStructuralNode = addRelationship(breakdownNode, definitionNode, rel, structuralNode, cartesianProductNestedArgs, selfStructuralNodes)\n else:\n addRelationships(breakdownNode, definitionNode, rel, relChildStructuralNode, cartesianProductNestedArgs)\n if axisDisposition == \"z\":\n # if definitionNode is first structural node child remove it\n if structuralNode.choiceStructuralNodes and structuralNode.choiceStructuralNodes[0].definitionNode == definitionNode:\n del structuralNode.choiceStructuralNodes[0]\n # flatten hierarchy of nested structural nodes inot choice nodes (for single listbox)\n def flattenChildNodesToChoices(childStructuralNodes, indent):\n while childStructuralNodes:\n choiceStructuralNode = childStructuralNodes.pop(0)\n choiceStructuralNode.indent = indent\n structuralNode.choiceStructuralNodes.append(choiceStructuralNode)\n flattenChildNodesToChoices(choiceStructuralNode.childStructuralNodes, indent + 1)\n if structuralNode.childStructuralNodes:\n flattenChildNodesToChoices(structuralNode.childStructuralNodes, 0)\n # set up by definitionNode.relationships\n if isinstance(definitionNode, ModelConceptRelationshipDefinitionNode):\n if (definitionNode._sourceQname != XbrlConst.qnXfiRoot and\n definitionNode._sourceQname not in view.modelXbrl.qnameConcepts):\n view.modelXbrl.error(\"xbrlte:invalidConceptRelationshipSource\",\n _(\"Concept relationship rule node %(xlinkLabel)s source %(source)s does not refer to an existing concept.\"),\n modelObject=definitionNode, xlinkLabel=definitionNode.xlinkLabel, source=definitionNode._sourceQname)\n elif isinstance(definitionNode, ModelDimensionRelationshipDefinitionNode):\n dim = view.modelXbrl.qnameConcepts.get(definitionNode._dimensionQname)\n if dim is None or not dim.isExplicitDimension:\n view.modelXbrl.error(\"xbrlte:invalidExplicitDimensionQName\",\n _(\"Dimension relationship rule node %(xlinkLabel)s dimension %(dimension)s does not refer to an existing explicit dimension.\"),\n modelObject=definitionNode, xlinkLabel=definitionNode.xlinkLabel, dimension=definitionNode._dimensionQname)\n domMbr = view.modelXbrl.qnameConcepts.get(definitionNode._sourceQname)\n if domMbr is None or not domMbr.isDomainMember:\n view.modelXbrl.error(\"xbrlte:invalidDimensionRelationshipSource\",\n _(\"Dimension relationship rule node %(xlinkLabel)s source %(source)s does not refer to an existing domain member.\"),\n modelObject=definitionNode, xlinkLabel=definitionNode.xlinkLabel, source=definitionNode._sourceQname)\n if (definitionNode._axis in (\"child\", \"child-or-self\", \"parent\", \"parent-or-self\", \"sibling\", \"sibling-or-self\") and\n (not isinstance(definitionNode._generations, _NUM_TYPES) or definitionNode._generations > 1)):\n view.modelXbrl.error(\"xbrlte:relationshipNodeTooManyGenerations \",\n _(\"Relationship rule node %(xlinkLabel)s formulaAxis %(axis)s implies a single generation tree walk but generations %(generations)s is greater than one.\"),\n modelObject=definitionNode, xlinkLabel=definitionNode.xlinkLabel, axis=definitionNode._axis, generations=definitionNode._generations)\n \n elif isinstance(definitionNode, ModelSelectionDefinitionNode):\n structuralNode.setHasOpenNode()\n structuralNode.isLabeled = False\n isCartesianProductExpanded = True\n varQn = definitionNode.variableQname\n if varQn:\n selections = sorted(structuralNode.evaluate(definitionNode, definitionNode.evaluate) or [], \n key=lambda obj:sortkey(obj))\n if isinstance(selections, (list,set,tuple)) and len(selections) > 1:\n for selection in selections: # nested choices from selection list\n childStructuralNode = StructuralNode(structuralNode, breakdownNode, definitionNode, contextItemFact=selection)\n childStructuralNode.variables[varQn] = selection\n childStructuralNode.indent = 0\n if axisDisposition == \"z\":\n structuralNode.choiceStructuralNodes.append(childStructuralNode)\n childStructuralNode.zSelection = True\n else:\n structuralNode.childStructuralNodes.append(childStructuralNode)\n expandDefinition(view, childStructuralNode, breakdownNode, definitionNode, depth, axisDisposition, facts, processOpenDefinitionNode=False) #recurse\n cartesianProductExpander(childStructuralNode, *cartesianProductNestedArgs)\n else:\n structuralNode.variables[varQn] = selections\n elif isinstance(definitionNode, ModelFilterDefinitionNode):\n structuralNode.setHasOpenNode()\n structuralNode.isLabeled = False\n isCartesianProductExpanded = True\n structuralNode.abstract = True # spanning ordinate acts as a subtitle\n filteredFactsPartitions = structuralNode.evaluate(definitionNode, \n definitionNode.filteredFactsPartitions, \n evalArgs=(facts,))\n if structuralNode._rendrCntx.formulaOptions.traceVariableFilterWinnowing:\n view.modelXbrl.info(\"table:trace\",\n _(\"Filter node %(xlinkLabel)s facts partitions: %(factsPartitions)s\"), \n modelObject=definitionNode, xlinkLabel=definitionNode.xlinkLabel,\n factsPartitions=str(filteredFactsPartitions))\n \n # ohly for fact entry (true if no parent open nodes or all are on entry prototype row)\n if axisDisposition != \"z\":\n childList = structuralNode.childStructuralNodes\n if structuralNode.isEntryPrototype(default=True):\n for i in range(getattr(view, \"openBreakdownLines\", \n # for file output, 1 entry row if no facts\n 0 if filteredFactsPartitions else 1)):\n view.aspectEntryObjectId += 1\n filteredFactsPartitions.append([FactPrototype(view, {\"aspectEntryObjectId\": OPEN_ASPECT_ENTRY_SURROGATE + str(view.aspectEntryObjectId)})])\n if structuralNode.isEntryPrototype(default=False):\n break # only one node per cartesian product under outermost nested open entry row\n else:\n childList = structuralNode.choiceStructuralNodes\n for factsPartition in filteredFactsPartitions:\n childStructuralNode = StructuralNode(structuralNode, breakdownNode, definitionNode, contextItemFact=factsPartition[0])\n childStructuralNode.indent = 0\n childStructuralNode.depth -= 1 # for label width; parent is merged/invisible\n childList.append(childStructuralNode)\n checkLabelWidth(childStructuralNode, checkBoundFact=True)\n #expandDefinition(view, childStructuralNode, breakdownNode, definitionNode, depth, axisDisposition, factsPartition, processOpenDefinitionNode=False) #recurse\n cartesianProductNestedArgs[3] = factsPartition\n # note: reduced set of facts should always be passed to subsequent open nodes\n if subtreeRelationships:\n for axisSubtreeRel in subtreeRelationships:\n child2DefinitionNode = axisSubtreeRel.toModelObject\n child2StructuralNode = StructuralNode(childStructuralNode, breakdownNode, child2DefinitionNode) # others are nested structuralNode\n childStructuralNode.childStructuralNodes.append(child2StructuralNode)\n expandDefinition(view, child2StructuralNode, breakdownNode, child2DefinitionNode, depth+ordDepth, axisDisposition, factsPartition) #recurse\n cartesianProductExpander(child2StructuralNode, *cartesianProductNestedArgs)\n else:\n cartesianProductExpander(childStructuralNode, *cartesianProductNestedArgs)\n # sort by header (which is likely to be typed dim value, for example)\n childList.sort(key=lambda childStructuralNode: \n childStructuralNode.header(lang=view.lang, \n returnGenLabel=False, \n returnMsgFormatString=False) \n or '') # exception on trying to sort if header returns None\n \n # TBD if there is no abstract 'sub header' for these subOrdCntxs, move them in place of parent structuralNode \n elif isinstance(definitionNode, ModelTupleDefinitionNode):\n structuralNode.abstract = True # spanning ordinate acts as a subtitle\n matchingTupleFacts = structuralNode.evaluate(definitionNode, \n definitionNode.filteredFacts, \n evalArgs=(facts,))\n for tupleFact in matchingTupleFacts:\n childStructuralNode = StructuralNode(structuralNode, breakdownNode, definitionNode, contextItemFact=tupleFact)\n childStructuralNode.indent = 0\n structuralNode.childStructuralNodes.append(childStructuralNode)\n expandDefinition(view, childStructuralNode, breakdownNode, definitionNode, depth, axisDisposition, [tupleFact]) #recurse\n # sort by header (which is likely to be typed dim value, for example)\n if (structuralNode.childStructuralNodes and\n any(sOC.header(lang=view.lang) for sOC in structuralNode.childStructuralNodes)):\n structuralNode.childStructuralNodes.sort(key=lambda childStructuralNode: childStructuralNode.header(lang=view.lang) or '')\n elif isinstance(definitionNode, ModelRuleDefinitionNode):\n for constraintSet in definitionNode.constraintSets.values():\n for aspect in constraintSet.aspectsCovered():\n if not constraintSet.aspectValueDependsOnVars(aspect):\n if aspect == Aspect.CONCEPT:\n conceptQname = definitionNode.aspectValue(view.rendrCntx, Aspect.CONCEPT)\n concept = view.modelXbrl.qnameConcepts.get(conceptQname)\n if concept is None or not concept.isItem or concept.isDimensionItem or concept.isHypercubeItem:\n view.modelXbrl.error(\"xbrlte:invalidQNameAspectValue\",\n _(\"Rule node %(xlinkLabel)s specifies concept %(concept)s does not refer to an existing primary item concept.\"),\n modelObject=definitionNode, xlinkLabel=definitionNode.xlinkLabel, concept=conceptQname)\n elif isinstance(aspect, QName):\n dim = view.modelXbrl.qnameConcepts.get(aspect)\n memQname = definitionNode.aspectValue(view.rendrCntx, aspect)\n mem = view.modelXbrl.qnameConcepts.get(memQname)\n if dim is None or not dim.isDimensionItem:\n view.modelXbrl.error(\"xbrlte:invalidQNameAspectValue\",\n _(\"Rule node %(xlinkLabel)s specifies dimension %(concept)s does not refer to an existing dimension concept.\"),\n modelObject=definitionNode, xlinkLabel=definitionNode.xlinkLabel, concept=aspect)\n if isinstance(memQname, QName) and (mem is None or not mem.isDomainMember):\n view.modelXbrl.error(\"xbrlte:invalidQNameAspectValue\",\n _(\"Rule node %(xlinkLabel)s specifies domain member %(concept)s does not refer to an existing domain member concept.\"),\n modelObject=definitionNode, xlinkLabel=definitionNode.xlinkLabel, concept=memQname)\n \n if axisDisposition == \"z\":\n if structuralNode.choiceStructuralNodes:\n choiceNodeIndex = view.zOrdinateChoices.get(definitionNode, 0)\n if isinstance(choiceNodeIndex, dict): # aspect entry for open node\n structuralNode.aspects = choiceNodeIndex\n structuralNode.choiceNodeIndex = -1\n elif choiceNodeIndex < len(structuralNode.choiceStructuralNodes):\n structuralNode.choiceNodeIndex = choiceNodeIndex\n else:\n structuralNode.choiceNodeIndex = 0\n view.zmostOrdCntx = structuralNode\n \n if not isCartesianProductExpanded or (axisDisposition == \"z\" and structuralNode.choiceStructuralNodes is not None):\n cartesianProductExpander(structuralNode, *cartesianProductNestedArgs)\n \n if not structuralNode.childStructuralNodes: # childless root ordinate, make a child to iterate in producing table\n subOrdContext = StructuralNode(structuralNode, breakdownNode, definitionNode)\n except ResolutionException as ex:\n if sys.version[0] >= '3':\n #import traceback\n #traceback.print_tb(ex.__traceback__)\n raise ex.with_traceback(ex.__traceback__) # provide original traceback information\n else:\n raise ex\n except Exception as ex:\n e = ResolutionException(\"arelle:resolutionException\",\n _(\"Exception in resolution of definition node %(node)s: %(error)s\"),\n modelObject=definitionNode, node=definitionNode.qname, error=str(ex)\n )\n if sys.version[0] >= '3':\n raise e.with_traceback(ex.__traceback__) # provide original traceback information\n else:\n raise e", "metadata": "root.expandDefinition", "header": "['module', '___EOS___']", "index": 219 } ]
[ { "span": "subOrdContext ", "start_line": 519, "start_column": 20, "end_line": 519, "end_column": 33 } ]
[]
1
true
[ "[CLS]_", "Un", "used_", "local_", "variable_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "expand", "Definition_", "(_", "view_", ",_", "structural", "Node_", ",_", "breakdown", "Node_", ",_", "definit", "ion", "Node_", ",_", "depth_", ",_", "axis", "Dispo", "sition", "_", ",_", "facts_", ",_", "i_", "=_", "None_", ",_", "tbl", "Axi", "s", "Rel", "s_", "=_", "None_", ",_", "process", "Open", "Definit", "ion", "Node_", "=_", "True_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "subtree", "Relationship", "s_", "=_", "view_", "._", "axis", "Subt", "ree", "Rel", "Set_", "._", "from", "Model", "Object_", "(_", "definit", "ion", "Node_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "check", "Label", "Width_", "(_", "structural", "Node_", ",_", "check", "Bound", "Fact", "_", "=_", "False_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "axis", "Dispo", "sition", "_", "==_", "\"", "y", "\"_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "message", "s", " ", "can", "'", "t", " ", "be", " ", "evaluate", "d", ",", " ", "just", " ", "use", " ", "the", " ", "text", " ", "porti", "on", " ", "of", " ", "format", " ", "string_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "label_", "=_", "structural", "Node_", "._", "header_", "(_", "lang_", "=_", "view_", "._", "lang_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "return", "Gen", "Label_", "=_", "not_", "check", "Bound", "Fact", "_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "return", "Msg", "Format", "String_", "=_", "not_", "check", "Bound", "Fact", "_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "label_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "need", " ", "to", " ", "et", " ", "more", " ", "exact", " ", "word", " ", "length", " ", "in", " ", "screen", " ", "units_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "wide", "st", "Word", "Len_", "=_", "max_", "(_", "len_", "(_", "w_", ")_", "*_", "RENDER", "\\u", "UNIT", "S", "\\u", "PER", "\\u", "CHAR_", "for_", "w_", "in_", "label_", "._", "split_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "abstract", " ", "only", " ", "pert", "ain", "s", " ", "to", " ", "subtree", " ", "of", " ", "close", "d", " ", "nodes", "but", " ", "not", " ", "cartesian", " ", "products", " ", "or", " ", "open", " ", "nodes_", "\\u\\u\\uNL\\u\\u\\u_", "while_", "structural", "Node_", "._", "depth_", ">=_", "len_", "(_", "view_", "._", "row", "Hdr", "Col", "Width_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "view_", "._", "row", "Hdr", "Col", "Width_", "._", "append_", "(_", "0_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "definit", "ion", "Node_", "._", "is", "Abstract", "_", "or_", "not_", "subtree", "Relationship", "s_", ":_", "#", " ", "isin", "stance", "(", "definit", "ion", "Node", ",", " ", "Model", "Open", "Definit", "ion", "Node", "):", " ", " _", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "if_", "wide", "st", "Word", "Len_", ">_", "view_", "._", "row", "Hdr", "Col", "Width_", "[_", "structural", "Node_", "._", "depth_", "]_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "view_", "._", "row", "Hdr", "Col", "Width_", "[_", "structural", "Node_", "._", "depth_", "]_", "=_", "wide", "st", "Word", "Len_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "if_", "wide", "st", "Word", "Len_", ">_", "view_", "._", "row", "Non", "Abstract", "Hdr", "Span", "Min_", "[_", "structural", "Node_", "._", "depth_", "]_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "view_", "._", "row", "Non", "Abstract", "Hdr", "Span", "Min_", "[_", "structural", "Node_", "._", "depth_", "]_", "=_", "wide", "st", "Word", "Len_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "axis", "Dispo", "sition", "_", "==_", "\"", "z", "\"_", "and_", "structural", "Node_", "._", "aspect", "s_", "is_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "structural", "Node_", "._", "aspect", "s_", "=_", "view_", "._", "z", "Ord", "inat", "e", "Choices_", "._", "get_", "(_", "definit", "ion", "Node_", ",_", "None_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "structural", "Node_", "and_", "isinstance_", "(_", "definit", "ion", "Node_", ",_", "(_", "Model", "Break", "down_", ",_", "Model", "Eu", "Axi", "s", "Coord_", ",_", "Model", "Definit", "ion", "Node_", ")_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", "cartesian", "Product", "Nest", "ed", "Arg", "s", " ", "=", " ", "(", "view", ",", " ", "depth", ",", " ", "axis", "Dispo", "sition", ",", " ", "fact", "s", ",", " ", "tbl", "Axi", "s", "Rel", "s", ",", " ", "i", ")_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "ord", "Card", "inal", "ity_", ",_", "ord", "Depth_", "=_", "definit", "ion", "Node_", "._", "cardinalit", "y", "And", "Depth_", "(_", "structural", "Node_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "(_", "not_", "definit", "ion", "Node_", "._", "is", "Abstract", "_", "and_", "\\u\\u\\uNL\\u\\u\\u_", "isinstance_", "(_", "definit", "ion", "Node_", ",_", "Model", "Clos", "ed", "Definit", "ion", "Node_", ")_", "and_", "\\u\\u\\uNL\\u\\u\\u_", "ord", "Card", "inal", "ity_", "==_", "0_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "view_", "._", "model", "Xbrl", "_", "._", "error_", "(_", "\"", "xbr", "lte", ":", "close", "d", "Definit", "ion", "Node", "Zero", "Card", "inal", "it", "y", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\\u_", "(_", "\"", "Clos", "ed", " ", "definit", "ion", " ", "node", " ", "%", "(", "xli", "nk", "Label", ")", "s", " ", "doe", "s", " ", "not", " ", "contribute", " ", "at", " ", "leas", "t", " ", "one", " ", "structural", " ", "node", "\"_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "model", "Object_", "=_", "(_", "view_", "._", "model", "Table_", ",_", "definit", "ion", "Node_", ")_", ",_", "xli", "nk", "Label_", "=_", "definit", "ion", "Node_", "._", "xli", "nk", "Label_", ",_", "axis_", "=_", "definit", "ion", "Node_", "._", "local", "Name_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "nest", "ed", "Depth_", "=_", "depth_", "+_", "ord", "Depth_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "HF", " ", "test_", "\\u\\u\\uNL\\u\\u\\u_", "cartesian", "Product", "Nest", "ed", "Args_", "=_", "[_", "view_", ",_", "nest", "ed", "Depth_", ",_", "axis", "Dispo", "sition", "_", ",_", "facts_", ",_", "tbl", "Axi", "s", "Rel", "s_", ",_", "i_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "axis", "Dispo", "sition", "_", "==_", "\"", "z", "\"_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "depth_", "==_", "1_", ":_", "#", " ", "choice", "s", " ", "(", "combo", " ", "box", "es", ")", " ", "don", "'", "t", " ", "add", " ", "to", " ", "z", " ", "row", " ", "count_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "view_", "._", "z", "Axi", "s", "Rows_", "+=_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "axis", "Dispo", "sition", "_", "==_", "\"", "x", "\"_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "ord", "Depth_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "if_", "nest", "ed", "Depth_", "-_", "1_", ">_", "view_", "._", "col", "Hdr", "Rows_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "view_", "._", "col", "Hdr", "Rows_", "=_", "nest", "ed", "Depth_", "-_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "'''", "\\", "10", ";", " ", " ", "if", " ", "not", " ", "view", ".", "col", "Hdr", "Doc", "Row", ":", "\\", "10", ";", " ", " ", "if", " ", "definit", "ion", "Node", ".", "header", "(", "role", "=\"", "http", "://", "www", ".", "xbr", "l", ".", "org", "/", "2008", "/", "role", "/", "documentation", "\",", "\\", "10", ";", " ", " ", " ", " ", " ", " ", " ", "lang", "=", "view", ".", "lang", "):", " ", "\\", "10", ";", " ", " ", " ", " ", " ", " ", "view", ".", "col", "Hdr", "Doc", "Row", " ", "=", " ", "Tru", "e", "\\", "10", ";", " ", " ", "if", " ", "not", " ", "view", ".", "col", "Hdr", "Code", "Row", ":", "\\", "10", ";", " ", " ", "if", " ", "definit", "ion", "Node", ".", "header", "(", "role", "=\"", "http", "://", "www", ".", "euro", "filing", ".", "info", "/", "role", "/", "2010", "/", "coordinate", "-", "code", "\"):", " ", "\\", "10", ";", " ", " ", " ", " ", " ", " ", "view", ".", "col", "Hdr", "Code", "Row", " ", "=", " ", "Tru", "e", "\\", "10", ";", " ", " ", "'''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "hdr", "Non", "Std", "Roles_", "=_", "view_", "._", "col", "Hdr", "Non", "Std", "Roles_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "axis", "Dispo", "sition", "_", "==_", "\"", "y", "\"_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "ord", "Depth_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", "if", " ", "not", " ", "definit", "ion", "Node", ".", "is", "Abstract", ":_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", " ", " ", " ", "view", ".", "data", "Row", "s", " ", "+=", " ", "ord", "Card", "inal", "ity_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "if_", "nest", "ed", "Depth_", "-_", "1_", ">_", "view_", "._", "row", "Hdr", "Cols_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "view_", "._", "row", "Hdr", "Cols_", "=_", "nest", "ed", "Depth_", "-_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "j_", "in_", "range_", "(_", "1_", "+_", "ord", "Depth_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "view_", "._", "row", "Hdr", "Col", "Width_", "._", "append_", "(_", "RENDER", "\\u", "UNIT", "S", "\\u", "PER", "\\u", "CHAR_", ")_", "#", " ", "min", " ", "widt", "h", " ", "for", " ", "'", "tail", "'", " ", "of", " ", "non", "Abstract", " ", "coordinate_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "view_", "._", "row", "Non", "Abstract", "Hdr", "Span", "Min_", "._", "append_", "(_", "0_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "check", "Label", "Width_", "(_", "structural", "Node_", ",_", "check", "Bound", "Fact", "_", "=_", "False_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "'''", " ", "\\", "10", ";", " ", " ", "if", " ", "not", " ", "view", ".", "row", "Hdr", "Doc", "Col", ":", "\\", "10", ";", " ", " ", "if", " ", "definit", "ion", "Node", ".", "header", "(", "role", "=\"", "http", "://", "www", ".", "xbr", "l", ".", "org", "/", "2008", "/", "role", "/", "documentation", "\",", "\\", "10", ";", " ", " ", " ", " ", " ", "lang", "=", "view", ".", "lang", "):", " ", "\\", "10", ";", " ", " ", " ", " ", " ", " ", "view", ".", "row", "Hdr", "Doc", "Col", " ", "=", " ", "Tru", "e", "\\", "10", ";", " ", " ", "if", " ", "not", " ", "view", ".", "row", "Hdr", "Code", "Col", ":", "\\", "10", ";", " ", " ", "if", " ", "definit", "ion", "Node", ".", "header", "(", "role", "=\"", "http", "://", "www", ".", "euro", "filing", ".", "info", "/", "role", "/", "2010", "/", "coordinate", "-", "code", "\"):", " ", "\\", "10", ";", " ", " ", " ", " ", " ", " ", "view", ".", "row", "Hdr", "Code", "Col", " ", "=", " ", "Tru", "e", "\\", "10", ";", " ", " ", "'''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "hdr", "Non", "Std", "Roles_", "=_", "view_", "._", "row", "Hdr", "Non", "Std", "Roles_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "axis", "Dispo", "sition", "_", "in_", "(_", "\"", "x", "\"_", ",_", "\"", "y", "\"_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "hdr", "Non", "Std", "Position_", "=_", "-_", "1_", "#", " ", "where", " ", "a", " ", "match", " ", "last", " ", "occure", "d_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "rel_", "in_", "view_", "._", "model", "Xbrl", "_", "._", "relation", "ship", "Set_", "(_", "Xbrl", "Const_", "._", "element", "Label_", ")_", "._", "from", "Model", "Object_", "(_", "definit", "ion", "Node_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "if_", "rel_", "._", "to", "Model", "Object_", "is_", "not_", "None_", "and_", "rel_", "._", "to", "Model", "Object_", "._", "role_", "!=_", "Xbrl", "Const_", "._", "gen", "Standard", "Label_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "label", "Lang_", "=_", "rel_", "._", "to", "Model", "Object_", "._", "xml", "Lang_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "label", "Role_", "=_", "rel_", "._", "to", "Model", "Object_", "._", "role_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "(_", "label", "Lang_", "==_", "view_", "._", "lang_", "or_", "label", "Lang_", "._", "startswith_", "(_", "view_", "._", "lang_", ")_", "or_", "view_", "._", "lang_", "._", "startswith_", "(_", "label", "Lang_", ")_", "\\u\\u\\uNL\\u\\u\\u_", "or_", "(_", "\"", "code", "\"_", "in_", "label", "Role_", ")_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "label", "Role_", "=_", "rel_", "._", "to", "Model", "Object_", "._", "role_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "label", "Role_", "in_", "hdr", "Non", "Std", "Roles_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "hdr", "Non", "Std", "Position_", "=_", "hdr", "Non", "Std", "Roles_", "._", "index_", "(_", "label", "Role_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "hdr", "Non", "Std", "Roles_", "._", "insert_", "(_", "hdr", "Non", "Std", "Position_", "+_", "1_", ",_", "label", "Role_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "is", "Cart", "esia", "n", "Product", "Expand", "ed_", "=_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "not_", "isinstance_", "(_", "definit", "ion", "Node_", ",_", "Model", "Filter", "Definit", "ion", "Node_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "is", "Cart", "esia", "n", "Product", "Expand", "ed_", "=_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "note", ":", " ", "reduce", "d", " ", "set", " ", "of", " ", "fact", "s", " ", "shou", "ld", " ", "alw", "ay", "s", " ", "be", " ", "pass", "ed", " ", "to", " ", "subsequen", "t", " ", "open", " ", "nodes_", "\\u\\u\\uNL\\u\\u\\u_", "for_", "axis", "Subt", "ree", "Rel", "_", "in_", "subtree", "Relationship", "s_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "child", "Definit", "ion", "Node_", "=_", "axis", "Subt", "ree", "Rel", "_", "._", "to", "Model", "Object_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "child", "Definit", "ion", "Node_", "._", "is", "Roll", "Up_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "structural", "Node_", "._", "roll", "Up", "Structur", "al", "Node_", "=_", "Structur", "al", "Node_", "(_", "structural", "Node_", ",_", "breakdown", "Node_", ",_", "child", "Definit", "ion", "Node_", ",_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "not_", "structural", "Node_", "._", "child", "Structur", "al", "Nodes_", ":_", "#", " ", "first", " ", "sub", " ", "ordina", "te", " ", "is", " ", "the", " ", "roll", " ", "up_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "structural", "Node_", "._", "subtree", "Roll", "Up_", "=_", "CHILD", "\\u", "ROLL", "UP", "\\u", "FIRST_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "structural", "Node_", "._", "subtree", "Roll", "Up_", "=_", "CHILD", "\\u", "ROLL", "UP", "\\u", "LAST_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "not_", "view_", "._", "top", "Roll", "up_", "._", "get_", "(_", "axis", "Dispo", "sition", "_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "view_", "._", "top", "Roll", "up_", "[_", "axis", "Dispo", "sition", "_", "]_", "=_", "structural", "Node_", "._", "subtree", "Roll", "Up_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "if_", "(_", "isinstance_", "(_", "definit", "ion", "Node_", ",_", "(_", "Model", "Break", "down_", ",_", "Model", "Composit", "ion", "Definit", "ion", "Node_", ")_", ")_", "and_", "\\u\\u\\uNL\\u\\u\\u_", "isinstance_", "(_", "child", "Definit", "ion", "Node_", ",_", "Model", "Relationship", "Definit", "ion", "Node_", ")_", ")_", ":_", "#", " ", "append", " ", "list", " ", "products", " ", "to", " ", "composi", "titi", "on", "Axe", "s", " ", "sub", "Obj", "Cnt", "xs_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "child", "Structur", "al", "Node_", "=_", "structural", "Node_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "child", "Structur", "al", "Node_", "=_", "Structur", "al", "Node_", "(_", "structural", "Node_", ",_", "breakdown", "Node_", ",_", "child", "Definit", "ion", "Node_", ")_", "#", " ", "other", "s", " ", "are", " ", "nest", "ed", " ", "structural", "Node_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "axis", "Dispo", "sition", "_", "!=_", "\"", "z", "\"_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "structural", "Node_", "._", "child", "Structur", "al", "Nodes_", "._", "append_", "(_", "child", "Structur", "al", "Node_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "axis", "Dispo", "sition", "_", "!=_", "\"", "z", "\"_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "expand", "Definition_", "(_", "view_", ",_", "child", "Structur", "al", "Node_", ",_", "breakdown", "Node_", ",_", "child", "Definit", "ion", "Node_", ",_", "depth_", "+_", "ord", "Depth_", ",_", "axis", "Dispo", "sition", "_", ",_", "facts_", ",_", "i_", ",_", "tbl", "Axi", "s", "Rel", "s_", ")_", "#", "recurse_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "not_", "child", "Contain", "s", "Open", "Nodes_", "(_", "child", "Structur", "al", "Node_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "To", " ", "be", " ", "compute", "d", " ", "only", " ", "if", " ", "the", " ", "structural", " ", "node", " ", "doe", "s", " ", "not", " ", "contain", " ", "an", " ", "open", " ", "node_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "cartesian", "Product", "Expand", "er_", "(_", "child", "Structur", "al", "Node_", ",_", "*_", "cartesian", "Product", "Nest", "ed", "Args_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "child", "Structur", "al", "Node_", "._", "indent_", "=_", "depth_", "-_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "structural", "Node_", "._", "choice", "Structur", "al", "Nodes_", "is_", "not_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "structural", "Node_", "._", "choice", "Structur", "al", "Nodes_", "._", "append_", "(_", "child", "Structur", "al", "Node_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "expand", "Definition_", "(_", "view_", ",_", "child", "Structur", "al", "Node_", ",_", "breakdown", "Node_", ",_", "child", "Definit", "ion", "Node_", ",_", "depth_", "+_", "1_", ",_", "axis", "Dispo", "sition", "_", ",_", "facts_", ")_", "#", "recurse_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "require", "d", " ", "whe", "n", " ", "switching", " ", "from", " ", "abstract", " ", "to", " ", "roll", " ", "up", " ", "to", " ", "dete", "rmin", "e", " ", "abstract", "ness_", "\\u\\u\\uNL\\u\\u\\u_", "#", "if", " ", "not", " ", "structural", "Node", ".", "subtree", "Roll", "Up", " ", "and", " ", "structural", "Node", ".", "child", "Structur", "al", "Node", "s", " ", "and", " ", "definit", "ion", "Node", ".", "tag", ".", "ends", "with", "(\"", "Node", "\"):", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", " ", " ", " ", "structural", "Node", ".", "subtree", "Roll", "Up", " ", "=", " ", "CHILD", "REN", "\\u", "BUT", "\\u", "NO", "\\u", "ROLL", "UP_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", "if", " ", "not", " ", "has", "attr", "(", "structural", "Node", ",", " ", "\"", "indent", "\"):", " ", "#", " ", "probab", "ly", " ", "als", "o", " ", "for", " ", "multiple", " ", "open", " ", "axes_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "process", "Open", "Definit", "ion", "Node_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "isinstance_", "(_", "definit", "ion", "Node_", ",_", "Model", "Relationship", "Definit", "ion", "Node_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "structural", "Node_", "._", "is", "Label", "ed_", "=_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self", "Structur", "al", "Nodes_", "=_", "{_", "}_", "if_", "definit", "ion", "Node_", "._", "axis_", "._", "endswith_", "(_", "'-", "or", "-", "self", "'_", ")_", "else_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "rel_", "in_", "definit", "ion", "Node_", "._", "relationships_", "(_", "structural", "Node_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "if_", "not_", "isinstance_", "(_", "rel_", ",_", "list_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "rel", "Chil", "d", "Structur", "al", "Node_", "=_", "add", "Relationship", "_", "(_", "breakdown", "Node_", ",_", "definit", "ion", "Node_", ",_", "rel_", ",_", "structural", "Node_", ",_", "cartesian", "Product", "Nest", "ed", "Args_", ",_", "self", "Structur", "al", "Nodes_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "add", "Relationship", "s_", "(_", "breakdown", "Node_", ",_", "definit", "ion", "Node_", ",_", "rel_", ",_", "rel", "Chil", "d", "Structur", "al", "Node_", ",_", "cartesian", "Product", "Nest", "ed", "Args_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "axis", "Dispo", "sition", "_", "==_", "\"", "z", "\"_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "if", " ", "definit", "ion", "Node", " ", "is", " ", "first", " ", "structural", " ", "node", " ", "child", " ", "remove", " ", "it_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "if_", "structural", "Node_", "._", "choice", "Structur", "al", "Nodes_", "and_", "structural", "Node_", "._", "choice", "Structur", "al", "Nodes_", "[_", "0_", "]_", "._", "definit", "ion", "Node_", "==_", "definit", "ion", "Node_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "del_", "structural", "Node_", "._", "choice", "Structur", "al", "Nodes_", "[_", "0_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "flat", "ten", " ", "hier", "arch", "y", " ", "of", " ", "nest", "ed", " ", "structural", " ", "nodes", " ", "ino", "t", " ", "choice", " ", "nodes", " ", "(", "for", " ", "single", " ", "list", "box", ")_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "flat", "ten", "Chil", "d", "Node", "s", "To", "Choices_", "(_", "child", "Structur", "al", "Nodes_", ",_", "indent_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "while_", "child", "Structur", "al", "Nodes_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "choice", "Structur", "al", "Node_", "=_", "child", "Structur", "al", "Nodes_", "._", "pop_", "(_", "0_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "choice", "Structur", "al", "Node_", "._", "indent_", "=_", "indent_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "structural", "Node_", "._", "choice", "Structur", "al", "Nodes_", "._", "append_", "(_", "choice", "Structur", "al", "Node_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "flat", "ten", "Chil", "d", "Node", "s", "To", "Choices_", "(_", "choice", "Structur", "al", "Node_", "._", "child", "Structur", "al", "Nodes_", ",_", "indent_", "+_", "1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "structural", "Node_", "._", "child", "Structur", "al", "Nodes_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "flat", "ten", "Chil", "d", "Node", "s", "To", "Choices_", "(_", "structural", "Node_", "._", "child", "Structur", "al", "Nodes_", ",_", "0_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "set", " ", "up", " ", "by", " ", "definit", "ion", "Node", ".", "relationships_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "isinstance_", "(_", "definit", "ion", "Node_", ",_", "Model", "Concept", "Relationship", "Definit", "ion", "Node_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "if_", "(_", "definit", "ion", "Node_", "._", "\\u", "source", "Qn", "ame_", "!=_", "Xbrl", "Const_", "._", "qn", "Xf", "i", "Root_", "and_", "\\u\\u\\uNL\\u\\u\\u_", "definit", "ion", "Node_", "._", "\\u", "source", "Qn", "ame_", "not_", "in_", "view_", "._", "model", "Xbrl", "_", "._", "qna", "me", "Concept", "s_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "view_", "._", "model", "Xbrl", "_", "._", "error_", "(_", "\"", "xbr", "lte", ":", "invalid", "Concept", "Relationship", "Sou", "rce", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\\u_", "(_", "\"", "Concept", " ", "relation", "ship", " ", "rule", " ", "node", " ", "%", "(", "xli", "nk", "Label", ")", "s", " ", "source", " ", "%", "(", "source", ")", "s", " ", "doe", "s", " ", "not", " ", "refer", " ", "to", " ", "an", " ", "exist", "ing", " ", "concept", ".\"_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "model", "Object_", "=_", "definit", "ion", "Node_", ",_", "xli", "nk", "Label_", "=_", "definit", "ion", "Node_", "._", "xli", "nk", "Label_", ",_", "source_", "=_", "definit", "ion", "Node_", "._", "\\u", "source", "Qn", "ame_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "isinstance_", "(_", "definit", "ion", "Node_", ",_", "Model", "Dimen", "sion", "Relationship", "Definit", "ion", "Node_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "dim_", "=_", "view_", "._", "model", "Xbrl", "_", "._", "qna", "me", "Concept", "s_", "._", "get_", "(_", "definit", "ion", "Node_", "._", "\\u", "dimension", "Qn", "ame_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "dim_", "is_", "None_", "or_", "not_", "dim_", "._", "is", "Exp", "licit", "Dimension_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "view_", "._", "model", "Xbrl", "_", "._", "error_", "(_", "\"", "xbr", "lte", ":", "invalid", "Exp", "licit", "Dimen", "sion", "QN", "ame", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\\u_", "(_", "\"", "Dimen", "sion", " ", "relation", "ship", " ", "rule", " ", "node", " ", "%", "(", "xli", "nk", "Label", ")", "s", " ", "dimension", " ", "%", "(", "dimension", ")", "s", " ", "doe", "s", " ", "not", " ", "refer", " ", "to", " ", "an", " ", "exist", "ing", " ", "explicit", " ", "dimension", ".\"_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "model", "Object_", "=_", "definit", "ion", "Node_", ",_", "xli", "nk", "Label_", "=_", "definit", "ion", "Node_", "._", "xli", "nk", "Label_", ",_", "dimension_", "=_", "definit", "ion", "Node_", "._", "\\u", "dimension", "Qn", "ame_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "dom", "Mb", "r_", "=_", "view_", "._", "model", "Xbrl", "_", "._", "qna", "me", "Concept", "s_", "._", "get_", "(_", "definit", "ion", "Node_", "._", "\\u", "source", "Qn", "ame_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "dom", "Mb", "r_", "is_", "None_", "or_", "not_", "dom", "Mb", "r_", "._", "is", "Doma", "in", "Member_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "view_", "._", "model", "Xbrl", "_", "._", "error_", "(_", "\"", "xbr", "lte", ":", "invalid", "Dimen", "sion", "Relationship", "Sou", "rce", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\\u_", "(_", "\"", "Dimen", "sion", " ", "relation", "ship", " ", "rule", " ", "node", " ", "%", "(", "xli", "nk", "Label", ")", "s", " ", "source", " ", "%", "(", "source", ")", "s", " ", "doe", "s", " ", "not", " ", "refer", " ", "to", " ", "an", " ", "exist", "ing", " ", "domain", " ", "member", ".\"_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "model", "Object_", "=_", "definit", "ion", "Node_", ",_", "xli", "nk", "Label_", "=_", "definit", "ion", "Node_", "._", "xli", "nk", "Label_", ",_", "source_", "=_", "definit", "ion", "Node_", "._", "\\u", "source", "Qn", "ame_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "(_", "definit", "ion", "Node_", "._", "\\u", "axis_", "in_", "(_", "\"", "child", "\"_", ",_", "\"", "child", "-", "or", "-", "self", "\"_", ",_", "\"", "parent", "\"_", ",_", "\"", "parent", "-", "or", "-", "self", "\"_", ",_", "\"", "sib", "ling", "\"_", ",_", "\"", "sib", "ling", "-", "or", "-", "self", "\"_", ")_", "and_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "not_", "isinstance_", "(_", "definit", "ion", "Node_", "._", "\\u", "generations", "_", ",_", "\\u", "NUM", "\\u", "TYPES_", ")_", "or_", "definit", "ion", "Node_", "._", "\\u", "generations", "_", ">_", "1_", ")_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "view_", "._", "model", "Xbrl", "_", "._", "error_", "(_", "\"", "xbr", "lte", ":", "relation", "ship", "Node", "Too", "Many", "Generat", "ion", "s", " ", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\\u_", "(_", "\"", "Relationship", " ", "rule", " ", "node", " ", "%", "(", "xli", "nk", "Label", ")", "s", " ", "formula", "Axi", "s", " ", "%", "(", "axis", ")", "s", " ", "implies", " ", "a", " ", "single", " ", "generat", "ion", " ", "tree", " ", "walk", " ", "but", " ", "generations", " ", "%", "(", "generations", ")", "s", " ", "is", " ", "great", "er", " ", "than", " ", "one", ".\"_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "model", "Object_", "=_", "definit", "ion", "Node_", ",_", "xli", "nk", "Label_", "=_", "definit", "ion", "Node_", "._", "xli", "nk", "Label_", ",_", "axis_", "=_", "definit", "ion", "Node_", "._", "\\u", "axis_", ",_", "generations", "_", "=_", "definit", "ion", "Node_", "._", "\\u", "generations", "_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "isinstance_", "(_", "definit", "ion", "Node_", ",_", "Model", "Selecti", "on", "Definit", "ion", "Node_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "structural", "Node_", "._", "set", "Has", "Open", "Node_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "structural", "Node_", "._", "is", "Label", "ed_", "=_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "is", "Cart", "esia", "n", "Product", "Expand", "ed_", "=_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "var", "Qn", "_", "=_", "definit", "ion", "Node_", "._", "variab", "le", "Qn", "ame_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "var", "Qn", "_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "selections_", "=_", "sorted_", "(_", "structural", "Node_", "._", "evaluate_", "(_", "definit", "ion", "Node_", ",_", "definit", "ion", "Node_", "._", "evaluate_", ")_", "or_", "[_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "key_", "=_", "lambda_", "obj_", ":_", "sort", "key_", "(_", "obj_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "isinstance_", "(_", "selections_", ",_", "(_", "list_", ",_", "set_", ",_", "tuple_", ")_", ")_", "and_", "len_", "(_", "selections_", ")_", ">_", "1_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "for_", "selection_", "in_", "selections_", ":_", "#", " ", "nest", "ed", " ", "choice", "s", " ", "from", " ", "selection", " ", "list_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "child", "Structur", "al", "Node_", "=_", "Structur", "al", "Node_", "(_", "structural", "Node_", ",_", "breakdown", "Node_", ",_", "definit", "ion", "Node_", ",_", "context", "Item", "Fact", "_", "=_", "selection_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "child", "Structur", "al", "Node_", "._", "variables_", "[_", "var", "Qn", "_", "]_", "=_", "selection_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "child", "Structur", "al", "Node_", "._", "indent_", "=_", "0_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "axis", "Dispo", "sition", "_", "==_", "\"", "z", "\"_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "structural", "Node_", "._", "choice", "Structur", "al", "Nodes_", "._", "append_", "(_", "child", "Structur", "al", "Node_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "child", "Structur", "al", "Node_", "._", "z", "Selection_", "=_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "structural", "Node_", "._", "child", "Structur", "al", "Nodes_", "._", "append_", "(_", "child", "Structur", "al", "Node_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "expand", "Definition_", "(_", "view_", ",_", "child", "Structur", "al", "Node_", ",_", "breakdown", "Node_", ",_", "definit", "ion", "Node_", ",_", "depth_", ",_", "axis", "Dispo", "sition", "_", ",_", "facts_", ",_", "process", "Open", "Definit", "ion", "Node_", "=_", "False_", ")_", "#", "recurse_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "cartesian", "Product", "Expand", "er_", "(_", "child", "Structur", "al", "Node_", ",_", "*_", "cartesian", "Product", "Nest", "ed", "Args_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "structural", "Node_", "._", "variables_", "[_", "var", "Qn", "_", "]_", "=_", "selections_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "isinstance_", "(_", "definit", "ion", "Node_", ",_", "Model", "Filter", "Definit", "ion", "Node_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "structural", "Node_", "._", "set", "Has", "Open", "Node_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "structural", "Node_", "._", "is", "Label", "ed_", "=_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "is", "Cart", "esia", "n", "Product", "Expand", "ed_", "=_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "structural", "Node_", "._", "abstract_", "=_", "True_", "#", " ", "spanning", " ", "ordina", "te", " ", "acts", " ", "as", " ", "a", " ", "subtitle_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "filter", "ed", "Fact", "s", "Partition", "s_", "=_", "structural", "Node_", "._", "evaluate_", "(_", "definit", "ion", "Node_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "definit", "ion", "Node_", "._", "filter", "ed", "Fact", "s", "Partition", "s_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "eval", "Args_", "=_", "(_", "facts_", ",_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "structural", "Node_", "._", "\\u", "rend", "r", "Cnt", "x_", "._", "formula", "Options_", "._", "trace", "Varia", "ble", "Filter", "Win", "now", "ing_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "view_", "._", "model", "Xbrl", "_", "._", "info_", "(_", "\"", "table", ":", "trace", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\\u_", "(_", "\"", "Filter", " ", "node", " ", "%", "(", "xli", "nk", "Label", ")", "s", " ", "fact", "s", " ", "partit", "ion", "s", ":", " ", "%", "(", "fact", "s", "Partition", "s", ")", "s", "\"_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "model", "Object_", "=_", "definit", "ion", "Node_", ",_", "xli", "nk", "Label_", "=_", "definit", "ion", "Node_", "._", "xli", "nk", "Label_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "fact", "s", "Partition", "s_", "=_", "str_", "(_", "filter", "ed", "Fact", "s", "Partition", "s_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "oh", "ly", " ", "for", " ", "fact", " ", "entry", " ", "(", "true", " ", "if", " ", "no", " ", "parent", " ", "open", " ", "nodes", " ", "or", " ", "all", " ", "are", " ", "on", " ", "entry", " ", "protot", "ype", " ", "row", ")_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "axis", "Dispo", "sition", "_", "!=_", "\"", "z", "\"_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "child", "List_", "=_", "structural", "Node_", "._", "child", "Structur", "al", "Nodes_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "structural", "Node_", "._", "is", "Entr", "y", "Prototype", "_", "(_", "default_", "=_", "True_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "for_", "i_", "in_", "range_", "(_", "getattr_", "(_", "view_", ",_", "\"", "open", "Break", "down", "Line", "s", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "for", " ", "file", " ", "output", ",", " ", "1", " ", "entry", " ", "row", " ", "if", " ", "no", " ", "facts_", "\\u\\u\\uNL\\u\\u\\u_", "0_", "if_", "filter", "ed", "Fact", "s", "Partition", "s_", "else_", "1_", ")_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "view_", "._", "aspect", "Entr", "y", "Object", "Id_", "+=_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "filter", "ed", "Fact", "s", "Partition", "s_", "._", "append_", "(_", "[_", "Fact", "Prototype", "_", "(_", "view_", ",_", "{_", "\"", "aspect", "Entr", "y", "Object", "Id", "\"_", ":_", "OPEN", "\\u", "ASP", "ECT", "\\u", "ENTR", "Y", "\\u", "SUR", "RO", "GAT", "E_", "+_", "str_", "(_", "view_", "._", "aspect", "Entr", "y", "Object", "Id_", ")_", "}_", ")_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "structural", "Node_", "._", "is", "Entr", "y", "Prototype", "_", "(_", "default_", "=_", "False_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "break_", "#", " ", "only", " ", "one", " ", "node", " ", "per", " ", "cartesian", " ", "product", " ", "under", " ", "outer", "most", " ", "nest", "ed", " ", "open", " ", "entry", " ", "row_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "child", "List_", "=_", "structural", "Node_", "._", "choice", "Structur", "al", "Nodes_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "for_", "fact", "s", "Partition_", "in_", "filter", "ed", "Fact", "s", "Partition", "s_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "child", "Structur", "al", "Node_", "=_", "Structur", "al", "Node_", "(_", "structural", "Node_", ",_", "breakdown", "Node_", ",_", "definit", "ion", "Node_", ",_", "context", "Item", "Fact", "_", "=_", "fact", "s", "Partition_", "[_", "0_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "child", "Structur", "al", "Node_", "._", "indent_", "=_", "0_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "child", "Structur", "al", "Node_", "._", "depth_", "-=_", "1_", "#", " ", "for", " ", "label", " ", "widt", "h", ";", " ", "parent", " ", "is", " ", "merge", "d", "/", "invisible", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "child", "List_", "._", "append_", "(_", "child", "Structur", "al", "Node_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "check", "Label", "Width_", "(_", "child", "Structur", "al", "Node_", ",_", "check", "Bound", "Fact", "_", "=_", "True_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", "expand", "Definit", "ion", "(", "view", ",", " ", "child", "Structur", "al", "Node", ",", " ", "breakdown", "Node", ",", " ", "definit", "ion", "Node", ",", " ", "depth", ",", " ", "axis", "Dispo", "sition", ",", " ", "fact", "s", "Partition", ",", " ", "process", "Open", "Definit", "ion", "Node", "=", "Fal", "se", ")", " ", "#", "recurse_", "\\u\\u\\uNL\\u\\u\\u_", "cartesian", "Product", "Nest", "ed", "Args_", "[_", "3_", "]_", "=_", "fact", "s", "Partition_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "note", ":", " ", "reduce", "d", " ", "set", " ", "of", " ", "fact", "s", " ", "shou", "ld", " ", "alw", "ay", "s", " ", "be", " ", "pass", "ed", " ", "to", " ", "subsequen", "t", " ", "open", " ", "nodes_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "subtree", "Relationship", "s_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "for_", "axis", "Subt", "ree", "Rel", "_", "in_", "subtree", "Relationship", "s_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "child", "2", "Definit", "ion", "Node_", "=_", "axis", "Subt", "ree", "Rel", "_", "._", "to", "Model", "Object_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "child", "2", "Structur", "al", "Node_", "=_", "Structur", "al", "Node_", "(_", "child", "Structur", "al", "Node_", ",_", "breakdown", "Node_", ",_", "child", "2", "Definit", "ion", "Node_", ")_", "#", " ", "other", "s", " ", "are", " ", "nest", "ed", " ", "structural", "Node_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "child", "Structur", "al", "Node_", "._", "child", "Structur", "al", "Nodes_", "._", "append_", "(_", "child", "2", "Structur", "al", "Node_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "expand", "Definition_", "(_", "view_", ",_", "child", "2", "Structur", "al", "Node_", ",_", "breakdown", "Node_", ",_", "child", "2", "Definit", "ion", "Node_", ",_", "depth_", "+_", "ord", "Depth_", ",_", "axis", "Dispo", "sition", "_", ",_", "fact", "s", "Partition_", ")_", "#", "recurse_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "cartesian", "Product", "Expand", "er_", "(_", "child", "2", "Structur", "al", "Node_", ",_", "*_", "cartesian", "Product", "Nest", "ed", "Args_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "cartesian", "Product", "Expand", "er_", "(_", "child", "Structur", "al", "Node_", ",_", "*_", "cartesian", "Product", "Nest", "ed", "Args_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "sort", " ", "by", " ", "header", " ", "(", "whi", "ch", " ", "is", " ", "like", "ly", " ", "to", " ", "be", " ", "typed", " ", "dim", " ", "value", ",", " ", "for", " ", "example", ")_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "child", "List_", "._", "sort_", "(_", "key_", "=_", "lambda_", "child", "Structur", "al", "Node_", ":_", "\\u\\u\\uNL\\u\\u\\u_", "child", "Structur", "al", "Node_", "._", "header_", "(_", "lang_", "=_", "view_", "._", "lang_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "return", "Gen", "Label_", "=_", "False_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "return", "Msg", "Format", "String_", "=_", "False_", ")_", "\\u\\u\\uNL\\u\\u\\u_", "or_", "''_", ")_", "#", " ", "exception", " ", "on", " ", "try", "ing", " ", "to", " ", "sort", " ", "if", " ", "header", " ", "return", "s", " ", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "TB", "D", " ", "if", " ", "there", " ", "is", " ", "no", " ", "abstract", " ", "'", "sub", " ", "header", "'", " ", "for", " ", "these", " ", "sub", "Ord", "Cnt", "xs", ",", " ", "move", " ", "them", " ", "in", " ", "place", " ", "of", " ", "parent", " ", "structural", "Node", " _", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "isinstance_", "(_", "definit", "ion", "Node_", ",_", "Model", "Tup", "le", "Definit", "ion", "Node_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "structural", "Node_", "._", "abstract_", "=_", "True_", "#", " ", "spanning", " ", "ordina", "te", " ", "acts", " ", "as", " ", "a", " ", "subtitle_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "matchi", "ng", "Tup", "le", "Fact", "s_", "=_", "structural", "Node_", "._", "evaluate_", "(_", "definit", "ion", "Node_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "definit", "ion", "Node_", "._", "filter", "ed", "Fact", "s_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "eval", "Args_", "=_", "(_", "facts_", ",_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "tuple", "Fact", "_", "in_", "matchi", "ng", "Tup", "le", "Fact", "s_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "child", "Structur", "al", "Node_", "=_", "Structur", "al", "Node_", "(_", "structural", "Node_", ",_", "breakdown", "Node_", ",_", "definit", "ion", "Node_", ",_", "context", "Item", "Fact", "_", "=_", "tuple", "Fact", "_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "child", "Structur", "al", "Node_", "._", "indent_", "=_", "0_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "structural", "Node_", "._", "child", "Structur", "al", "Nodes_", "._", "append_", "(_", "child", "Structur", "al", "Node_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "expand", "Definition_", "(_", "view_", ",_", "child", "Structur", "al", "Node_", ",_", "breakdown", "Node_", ",_", "definit", "ion", "Node_", ",_", "depth_", ",_", "axis", "Dispo", "sition", "_", ",_", "[_", "tuple", "Fact", "_", "]_", ")_", "#", "recurse_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "sort", " ", "by", " ", "header", " ", "(", "whi", "ch", " ", "is", " ", "like", "ly", " ", "to", " ", "be", " ", "typed", " ", "dim", " ", "value", ",", " ", "for", " ", "example", ")_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "(_", "structural", "Node_", "._", "child", "Structur", "al", "Nodes_", "and_", "\\u\\u\\uNL\\u\\u\\u_", "any_", "(_", "s", "OC", "_", "._", "header_", "(_", "lang_", "=_", "view_", "._", "lang_", ")_", "for_", "s", "OC", "_", "in_", "structural", "Node_", "._", "child", "Structur", "al", "Nodes_", ")_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "structural", "Node_", "._", "child", "Structur", "al", "Nodes_", "._", "sort_", "(_", "key_", "=_", "lambda_", "child", "Structur", "al", "Node_", ":_", "child", "Structur", "al", "Node_", "._", "header_", "(_", "lang_", "=_", "view_", "._", "lang_", ")_", "or_", "''_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "isinstance_", "(_", "definit", "ion", "Node_", ",_", "Model", "Rule", "Definit", "ion", "Node_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "for_", "constraint", "Set_", "in_", "definit", "ion", "Node_", "._", "constraint", "Sets_", "._", "values_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "for_", "aspect_", "in_", "constraint", "Set_", "._", "aspect", "s", "Cover", "ed_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "if_", "not_", "constraint", "Set_", "._", "aspect", "Value", "Depend", "s", "On", "Vars_", "(_", "aspect_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "if_", "aspect_", "==_", "Asp", "ect_", "._", "CONC", "EP", "T_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "concept", "Qn", "ame_", "=_", "definit", "ion", "Node_", "._", "aspect", "Value_", "(_", "view_", "._", "rend", "r", "Cnt", "x_", ",_", "Asp", "ect_", "._", "CONC", "EP", "T_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "concept_", "=_", "view_", "._", "model", "Xbrl", "_", "._", "qna", "me", "Concept", "s_", "._", "get_", "(_", "concept", "Qn", "ame_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "concept_", "is_", "None_", "or_", "not_", "concept_", "._", "is", "Item_", "or_", "concept_", "._", "is", "Dimen", "sion", "Item_", "or_", "concept_", "._", "is", "Hyper", "cube", "Item_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " ", " _", "view_", "._", "model", "Xbrl", "_", "._", "error_", "(_", "\"", "xbr", "lte", ":", "invalid", "QN", "ame", "Asp", "ect", "Value", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\\u_", "(_", "\"", "Rule", " ", "node", " ", "%", "(", "xli", "nk", "Label", ")", "s", " ", "speci", "fie", "s", " ", "concept", " ", "%", "(", "concept", ")", "s", " ", "doe", "s", " ", "not", " ", "refer", " ", "to", " ", "an", " ", "exist", "ing", " ", "primary", " ", "item", " ", "concept", ".\"_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "model", "Object_", "=_", "definit", "ion", "Node_", ",_", "xli", "nk", "Label_", "=_", "definit", "ion", "Node_", "._", "xli", "nk", "Label_", ",_", "concept_", "=_", "concept", "Qn", "ame_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "isinstance_", "(_", "aspect_", ",_", "QN", "ame_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "dim_", "=_", "view_", "._", "model", "Xbrl", "_", "._", "qna", "me", "Concept", "s_", "._", "get_", "(_", "aspect_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "mem", "Qn", "ame_", "=_", "definit", "ion", "Node_", "._", "aspect", "Value_", "(_", "view_", "._", "rend", "r", "Cnt", "x_", ",_", "aspect_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "mem_", "=_", "view_", "._", "model", "Xbrl", "_", "._", "qna", "me", "Concept", "s_", "._", "get_", "(_", "mem", "Qn", "ame_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "dim_", "is_", "None_", "or_", "not_", "dim_", "._", "is", "Dimen", "sion", "Item_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " ", " _", "view_", "._", "model", "Xbrl", "_", "._", "error_", "(_", "\"", "xbr", "lte", ":", "invalid", "QN", "ame", "Asp", "ect", "Value", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\\u_", "(_", "\"", "Rule", " ", "node", " ", "%", "(", "xli", "nk", "Label", ")", "s", " ", "speci", "fie", "s", " ", "dimension", " ", "%", "(", "concept", ")", "s", " ", "doe", "s", " ", "not", " ", "refer", " ", "to", " ", "an", " ", "exist", "ing", " ", "dimension", " ", "concept", ".\"_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "model", "Object_", "=_", "definit", "ion", "Node_", ",_", "xli", "nk", "Label_", "=_", "definit", "ion", "Node_", "._", "xli", "nk", "Label_", ",_", "concept_", "=_", "aspect_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "isinstance_", "(_", "mem", "Qn", "ame_", ",_", "QN", "ame_", ")_", "and_", "(_", "mem_", "is_", "None_", "or_", "not_", "mem_", "._", "is", "Doma", "in", "Member_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " ", " _", "view_", "._", "model", "Xbrl", "_", "._", "error_", "(_", "\"", "xbr", "lte", ":", "invalid", "QN", "ame", "Asp", "ect", "Value", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\\u_", "(_", "\"", "Rule", " ", "node", " ", "%", "(", "xli", "nk", "Label", ")", "s", " ", "speci", "fie", "s", " ", "domain", " ", "member", " ", "%", "(", "concept", ")", "s", " ", "doe", "s", " ", "not", " ", "refer", " ", "to", " ", "an", " ", "exist", "ing", " ", "domain", " ", "member", " ", "concept", ".\"_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "model", "Object_", "=_", "definit", "ion", "Node_", ",_", "xli", "nk", "Label_", "=_", "definit", "ion", "Node_", "._", "xli", "nk", "Label_", ",_", "concept_", "=_", "mem", "Qn", "ame_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "axis", "Dispo", "sition", "_", "==_", "\"", "z", "\"_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "if_", "structural", "Node_", "._", "choice", "Structur", "al", "Nodes_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "choice", "Node", "Index_", "=_", "view_", "._", "z", "Ord", "inat", "e", "Choices_", "._", "get_", "(_", "definit", "ion", "Node_", ",_", "0_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "isinstance_", "(_", "choice", "Node", "Index_", ",_", "dict_", ")_", ":_", "#", " ", "aspect", " ", "entry", " ", "for", " ", "open", " ", "node_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "structural", "Node_", "._", "aspect", "s_", "=_", "choice", "Node", "Index_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "structural", "Node_", "._", "choice", "Node", "Index_", "=_", "-_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "choice", "Node", "Index_", "<_", "len_", "(_", "structural", "Node_", "._", "choice", "Structur", "al", "Nodes_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "structural", "Node_", "._", "choice", "Node", "Index_", "=_", "choice", "Node", "Index_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "structural", "Node_", "._", "choice", "Node", "Index_", "=_", "0_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "view_", "._", "zm", "ost", "Ord", "Cnt", "x_", "=_", "structural", "Node_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "not_", "is", "Cart", "esia", "n", "Product", "Expand", "ed_", "or_", "(_", "axis", "Dispo", "sition", "_", "==_", "\"", "z", "\"_", "and_", "structural", "Node_", "._", "choice", "Structur", "al", "Nodes_", "is_", "not_", "None_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "cartesian", "Product", "Expand", "er_", "(_", "structural", "Node_", ",_", "*_", "cartesian", "Product", "Nest", "ed", "Args_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "not_", "structural", "Node_", "._", "child", "Structur", "al", "Nodes_", ":_", "#", " ", "child", "less", " ", "root", " ", "ordina", "te", ",", " ", "make", " ", "a", " ", "child", " ", "to", " ", "iterate", " ", "in", " ", "produc", "ing", " ", "table_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "sub", "Ord", "Context_", "=_", "Structur", "al", "Node_", "(_", "structural", "Node_", ",_", "breakdown", "Node_", ",_", "definit", "ion", "Node_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "Reso", "luti", "on", "Exception_", "as_", "ex_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "sys_", "._", "version_", "[_", "0_", "]_", ">=_", "'", "3", "'_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", "import", " ", "traceback_", "\\u\\u\\uNL\\u\\u\\u_", "#", "traceback", ".", "print", "\\u", "tb", "(", "ex", ".\\u", "\\u", "traceback", "\\u\\u)", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "raise_", "ex_", "._", "with", "\\u", "traceback_", "(_", "ex_", "._", "\\u\\u", "traceback", "\\u\\u_", ")_", "#", " ", "provide", " ", "original", " ", "traceback", " ", "information_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "raise_", "ex_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "Exception_", "as_", "ex_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "e_", "=_", "Reso", "luti", "on", "Exception_", "(_", "\"", "are", "lle", ":", "resolu", "tion", "Except", "ion", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\\u_", "(_", "\"", "Except", "ion", " ", "in", " ", "resolu", "tion", " ", "of", " ", "definit", "ion", " ", "node", " ", "%", "(", "node", ")", "s", ":", " ", "%", "(", "error", ")", "s", "\"_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "model", "Object_", "=_", "definit", "ion", "Node_", ",_", "node_", "=_", "definit", "ion", "Node_", "._", "qname_", ",_", "error_", "=_", "str_", "(_", "ex_", ")_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "sys_", "._", "version_", "[_", "0_", "]_", ">=_", "'", "3", "'_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "raise_", "e_", "._", "with", "\\u", "traceback_", "(_", "ex_", "._", "\\u\\u", "traceback", "\\u\\u_", ")_", "#", " ", "provide", " ", "original", " ", "traceback", " ", "information_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "raise_", "e_", "\\u\\u\\uNEWLINE\\u\\u\\u_" ]
[ 4, 4, 4, 4, 4, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,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 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 ]
Unused import
ossxp-com/repo/subcmds/config.py
[ { "content": "#\n# Copyright (C) 2010 [email protected]\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file except in compliance with the License.\n# You may obtain a copy of the License at\n#\n# http://www.apache.org/licenses/LICENSE-2.0\n#\n# Unless required by applicable law or agreed to in writing, software\n# distributed under the License is distributed on an \"AS IS\" BASIS,\n# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n# See the License for the specific language governing permissions and\n# limitations under the License.\n\nimport sys\nfrom command import Command\nfrom git_command import GitCommand\nfrom error import GitError\n\n", "metadata": "root", "header": "['module', '___EOS___']", "index": 0 }, { "content": "class Config(Command):\n common = True\n helpSummary = \"Get and set repo config\"\n helpUsage = \"\"\"\n%prog name [value]\n\"\"\"\n helpDescription = \"\"\"\n'%prog' get or set config of the manifest repository.\n\"\"\"\n\n", "metadata": "root.Config", "header": "['module', '___EOS___']", "index": 20 }, { "content": " def _Options(self, p):\n p.add_option('--bool',\n dest='bool', action='store_true',\n help='git config will ensure that the output is \"true\" or \"false\"')", "metadata": "root.Config._Options", "header": "['class', 'Config', '(', 'Command', ')', ':', '___EOS___']", "index": 30 }, { "content": " def Execute(self, opt, args):\n if not args:\n self.Usage()\n\n if len(args) > 1 and not args[0].startswith ('repo.'):\n print >>sys.stderr, \"error: can only set config name starts with 'repo.', but you provide '%s'.\" % args[0]\n sys.exit(1)\n\n if len(args) > 1 and args[0] == 'repo.mirror':\n print >>sys.stderr, \"fatal: reset repo.mirror is not supported on existing client.\"\n sys.exit(1)\n\n mp = self.manifest.manifestProject\n\n command = [\"config\"]\n\n if opt.bool:\n command.append('--bool')\n\n command.extend(args)\n\n if GitCommand(mp, command).Wait() != 0:\n return -1", "metadata": "root.Config.Execute", "header": "['class', 'Config', '(', 'Command', ')', ':', '___EOS___']", "index": 35 } ]
[ { "span": "from error import GitError", "start_line": 18, "start_column": 0, "end_line": 18, "end_column": 26 } ]
[]
1
false
[ "[CLS]_", "Un", "used_", "import_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "#", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Copy", "right", " ", "(", "C", ")", " ", "2010", " ", "Jia", "ng", "Xin", "@", "oss", "xp", ".", "com_", "\\u\\u\\uNL\\u\\u\\u_", "#", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "License", "d", " ", "under", " ", "the", " ", "Ap", "ache", " ", "License", ",", " ", "Version", " ", "2.0", " ", "(", "the", " ", "\"", "License", "\");", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "you", " ", "may", " ", "not", " ", "use", " ", "this", " ", "file", " ", "except", " ", "in", " ", "compli", "anc", "e", " ", "with", " ", "the", " ", "License", "._", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "You", " ", "may", " ", "obtain", " ", "a", " ", "copy", " ", "of", " ", "the", " ", "License", " ", "at_", "\\u\\u\\uNL\\u\\u\\u_", "#", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", " ", "http", "://", "www", ".", "apa", "che", ".", "org", "/", "license", "s", "/", "LICENSE", "-", "2.0_", "\\u\\u\\uNL\\u\\u\\u_", "#", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Un", "less", " ", "require", "d", " ", "by", " ", "applica", "ble", " ", "law", " ", "or", " ", "agree", "d", " ", "to", " ", "in", " ", "writ", "ing", ",", " ", "software", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "distributed", " ", "under", " ", "the", " ", "License", " ", "is", " ", "distributed", " ", "on", " ", "an", " ", "\"", "AS", " ", "IS", "\"", " ", "BAS", "IS", ",_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "WITH", "OUT", " ", "WAR", "RAN", "TIES", " ", "OR", " ", "CONDITION", "S", " ", "OF", " ", "ANY", " ", "KIND", ",", " ", "eit", "her", " ", "express", " ", "or", " ", "impli", "ed", "._", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "See", " ", "the", " ", "License", " ", "for", " ", "the", " ", "specific", " ", "language", " ", "govern", "ing", " ", "permissi", "ons", " ", "and_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "limit", "ation", "s", " ", "under", " ", "the", " ", "License", "._", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "import_", "sys_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "command_", "import_", "Command_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "git", "\\u", "command_", "import_", "Git", "Command_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "error_", "import_", "Git", "Error_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "class_", "Config_", "(_", "Command_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "common_", "=_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "help", "Summary_", "=_", "\"", "Get", " ", "and", " ", "set", " ", "repo", " ", "config", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "help", "Usage_", "=_", "\"\"\"", "\\", "10", ";", "%", "prog", " ", "name", " ", "[", "value", "]", "\\", "10", ";\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "help", "Description_", "=_", "\"\"\"", "\\", "10", ";'", "%", "prog", "'", " ", "get", " ", "or", " ", "set", " ", "config", " ", "of", " ", "the", " ", "manifest", " ", "repos", "itor", "y", ".", "\\", "10", ";\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "[SEP]_", "class_", "Config_", "(_", "Command_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "\\u", "Options_", "(_", "self_", ",_", "p_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "p_", "._", "add", "\\u", "option_", "(_", "'--", "bool", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "dest_", "=_", "'", "bool", "'_", ",_", "action_", "=_", "'", "store", "\\u", "true", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "help_", "=_", "'", "git", " ", "config", " ", "will", " ", "ensure", " ", "tha", "t", " ", "the", " ", "output", " ", "is", " ", "\"", "true", "\"", " ", "or", " ", "\"", "fal", "se", "\"'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Config_", "(_", "Command_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "Execute_", "(_", "self_", ",_", "opt_", ",_", "args_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "not_", "args_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "Usage_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "len_", "(_", "args_", ")_", ">_", "1_", "and_", "not_", "args_", "[_", "0_", "]_", "._", "startswith_", "(_", "'", "repo", ".'_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "print_", ">>_", "sys_", "._", "stderr_", ",_", "\"", "error", ":", " ", "can", " ", "only", " ", "set", " ", "config", " ", "name", " ", "starts", " ", "with", " ", "'", "repo", ".'", ",", " ", "but", " ", "you", " ", "provide", " ", "'%", "s", "'.\"_", "%_", "args_", "[_", "0_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "sys_", "._", "exit_", "(_", "1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "len_", "(_", "args_", ")_", ">_", "1_", "and_", "args_", "[_", "0_", "]_", "==_", "'", "repo", ".", "mirror", "'_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "print_", ">>_", "sys_", "._", "stderr_", ",_", "\"", "fat", "al", ":", " ", "reset", " ", "repo", ".", "mirror", " ", "is", " ", "not", " ", "support", "ed", " ", "on", " ", "exist", "ing", " ", "client", ".\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "sys_", "._", "exit_", "(_", "1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "mp_", "=_", "self_", "._", "manifest_", "._", "manifest", "Project_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "command_", "=_", "[_", "\"", "config", "\"_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "opt_", "._", "bool_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "command_", "._", "append_", "(_", "'--", "bool", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "command_", "._", "extend_", "(_", "args_", ")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 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 ]
Unused import
openxc/openxc-python/openxc/__init__.py
[ { "content": "import openxc.logconfig\n", "metadata": "root", "header": "['module', '___EOS___']", "index": 0 } ]
[ { "span": "import openxc.logconfig", "start_line": 0, "start_column": 0, "end_line": 0, "end_column": 23 } ]
[]
1
false
[ "[CLS]_", "Un", "used_", "import_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "import_", "open", "xc_", "._", "logc", "onfig_" ]
[ 4, 4, 4, 4, 4, 2, 2, 0, 1, 1, 1, 1, 1 ]
Unreachable code
apache/libcloud/libcloud/test/compute/test_openstack.py
[ { "content": " def _v1_1_slug_servers_4242_action(self, method, url, body, headers):\n if method == \"POST\":\n body = ''\n return (httplib.ACCEPTED, body, self.json_content_headers, httplib.responses[httplib.OK])\n else:\n raise NotImplementedError()\n\n return (httplib.OK, body, self.json_content_headers, httplib.responses[httplib.OK])", "metadata": "root.OpenStack_1_1_MockHttp._v1_1_slug_servers_4242_action", "header": "['class', 'OpenStack_1_1_MockHttp', '(', 'MockHttpTestCase', ')', ':', '___EOS___']", "index": 1801 }, { "content": " def _v1_1_slug_servers_72258_action(self, method, url, body, headers):\n if method == 'POST':\n body = self.fixtures.load('_servers_suspend.json')\n return (httplib.ACCEPTED, body, self.json_content_headers, httplib.responses[httplib.OK])\n else:\n raise NotImplementedError()\n\n return (httplib.OK, body, self.json_content_headers, httplib.responses[httplib.OK])", "metadata": "root.OpenStack_1_1_MockHttp._v1_1_slug_servers_72258_action", "header": "['class', 'OpenStack_1_1_MockHttp', '(', 'MockHttpTestCase', ')', ':', '___EOS___']", "index": 1825 }, { "content": " def _v1_1_slug_servers_12063_action(self, method, url, body, headers):\n if method == 'POST':\n body = self.fixtures.load('_servers_unpause.json')\n return (httplib.ACCEPTED, body, self.json_content_headers, httplib.responses[httplib.OK])\n else:\n raise NotImplementedError()\n\n return (httplib.OK, body, self.json_content_headers, httplib.responses[httplib.OK])", "metadata": "root.OpenStack_1_1_MockHttp._v1_1_slug_servers_12063_action", "header": "['class', 'OpenStack_1_1_MockHttp', '(', 'MockHttpTestCase', ')', ':', '___EOS___']", "index": 1834 } ]
[ { "span": "return (httplib.OK, body, self.json_content_headers, httplib.responses[httplib.OK])", "start_line": 1808, "start_column": 8, "end_line": 1808, "end_column": 91 }, { "span": "return (httplib.OK, body, self.json_content_headers, httplib.responses[httplib.OK])", "start_line": 1832, "start_column": 8, "end_line": 1832, "end_column": 91 }, { "span": "return (httplib.OK, body, self.json_content_headers, httplib.responses[httplib.OK])", "start_line": 1841, "start_column": 8, "end_line": 1841, "end_column": 91 } ]
[]
1
true
[ "[CLS]_", "Unrea", "chab", "le_", "code_", "[SEP]_", "class_", "Open", "Stack", "\\u", "1", "\\u", "1", "\\u", "Moc", "k", "Http_", "(_", "Moc", "k", "Http", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "\\u", "v1", "\\u", "1", "\\u", "slug", "\\u", "server", "s", "\\u", "424", "2", "\\u", "action_", "(_", "self_", ",_", "method_", ",_", "url_", ",_", "body_", ",_", "headers_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "method_", "==_", "\"", "POST", "\"_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "body_", "=_", "''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "(_", "httplib_", "._", "ACCEPTED", "_", ",_", "body_", ",_", "self_", "._", "json", "\\u", "content", "\\u", "headers_", ",_", "httplib_", "._", "responses_", "[_", "httplib_", "._", "OK_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "raise_", "Not", "Impl", "ement", "ed", "Error_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "(_", "httplib_", "._", "OK_", ",_", "body_", ",_", "self_", "._", "json", "\\u", "content", "\\u", "headers_", ",_", "httplib_", "._", "responses_", "[_", "httplib_", "._", "OK_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Open", "Stack", "\\u", "1", "\\u", "1", "\\u", "Moc", "k", "Http_", "(_", "Moc", "k", "Http", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "\\u", "v1", "\\u", "1", "\\u", "slug", "\\u", "server", "s", "\\u", "722", "5", "8", "\\u", "action_", "(_", "self_", ",_", "method_", ",_", "url_", ",_", "body_", ",_", "headers_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "method_", "==_", "'", "POST", "'_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "body_", "=_", "self_", "._", "fixtures_", "._", "load_", "(_", "'\\u", "server", "s", "\\u", "suspend", ".", "json", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "(_", "httplib_", "._", "ACCEPTED", "_", ",_", "body_", ",_", "self_", "._", "json", "\\u", "content", "\\u", "headers_", ",_", "httplib_", "._", "responses_", "[_", "httplib_", "._", "OK_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "raise_", "Not", "Impl", "ement", "ed", "Error_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "(_", "httplib_", "._", "OK_", ",_", "body_", ",_", "self_", "._", "json", "\\u", "content", "\\u", "headers_", ",_", "httplib_", "._", "responses_", "[_", "httplib_", "._", "OK_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Open", "Stack", "\\u", "1", "\\u", "1", "\\u", "Moc", "k", "Http_", "(_", "Moc", "k", "Http", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "\\u", "v1", "\\u", "1", "\\u", "slug", "\\u", "server", "s", "\\u", "120", "6", "3", "\\u", "action_", "(_", "self_", ",_", "method_", ",_", "url_", ",_", "body_", ",_", "headers_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "method_", "==_", "'", "POST", "'_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "body_", "=_", "self_", "._", "fixtures_", "._", "load_", "(_", "'\\u", "server", "s", "\\u", "unpa", "use", ".", "json", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "(_", "httplib_", "._", "ACCEPTED", "_", ",_", "body_", ",_", "self_", "._", "json", "\\u", "content", "\\u", "headers_", ",_", "httplib_", "._", "responses_", "[_", "httplib_", "._", "OK_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "raise_", "Not", "Impl", "ement", "ed", "Error_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "(_", "httplib_", "._", "OK_", ",_", "body_", ",_", "self_", "._", "json", "\\u", "content", "\\u", "headers_", ",_", "httplib_", "._", "responses_", "[_", "httplib_", "._", "OK_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_" ]
[ 4, 4, 4, 4, 4, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2 ]
Unused import
coreemu/core/daemon/core/services/dockersvc.py
[ { "content": "#\n# CORE\n# Copyright (c)2014 the Boeing Company.\n# See the LICENSE file included in this distribution.\n#\n# authors: Stuart Marsden\n# Jeff Ahrenholz <[email protected]>\n#\n''' Docker service allows running docker containers within CORE nodes.\n\nThe running of Docker within a CORE node allows for additional extensibility to\nthe CORE services. This allows network applications and protocols to be easily\npackaged and run on any node.\n\nThis service that will add a new group to the services list. This\nwill have a service called Docker which will just start the docker service\nwithin the node but not run anything. It will also scan all docker images on\nthe host machine. If any are tagged with 'core' then they will be added as a\nservice to the Docker group. The image will then be auto run if that service is\nselected.\n\nThis requires a recent version of Docker. This was tested using a PPA on Ubuntu\n with version 1.2.0. The version in the standard Ubuntu repo is to old for \nthis purpose (we need --net host).\n\nIt also requires docker-py (https://pypi.python.org/pypi/docker-py) which can be\ninstalled with 'pip install docker-py'. This is used to interface with Docker\nfrom the python service.\n\nAn example use case is to pull an image from Docker.com. A test image has been\nuploaded for this purpose:\n\nsudo docker pull stuartmarsden/multicastping\n\nThis downloads an image which is based on Ubuntu 14.04 with python and twisted.\nIt runs a simple program that sends a multicast ping and listens and records\nany it receives.\n\nIn order for this to appear as a docker service it must be tagged with core.\nFind out the id by running 'sudo docker images'. You should see all installed\nimages and the one you want looks like this:\n\nstuartmarsden/multicastping latest 4833487e66d2 20 hours\nago 487 MB\n\nThe id will be different on your machine so use it in the following command:\n\nsudo docker tag 4833487e66d2 stuartmarsden/multicastping:core\n\nThis image will be listed in the services after we restart the core-daemon: \n\nsudo service core-daemon restart\n\nYou can set up a simple network with a number of PCs connected to a switch. Set\nthe stuartmarsden/multicastping service for all the PCs. When started they will\nall begin sending Multicast pings. \n\nIn order to see what is happening you can go in to the terminal of a node and\nlook at the docker log. Easy shorthand is:\n\ndocker logs $(docker ps -q)\n\nWhich just shows the log of the running docker container (usually just one per\nnode). I have added this as an observer node to my setup: Name: docker logs\nCommand: bash -c 'docker logs $(docker ps -q) | tail -20'\n\nSo I can just hover over to see the log which looks like this:\n\nDatagram 'Client: Ping' received from ('10.0.0.20', 8005)\nDatagram 'Client: Ping' received from ('10.0.5.21', 8005)\nDatagram 'Client: Ping' received from ('10.0.3.20', 8005)\nDatagram 'Client: Ping' received from ('10.0.4.20', 8005)\nDatagram 'Client: Ping' received from ('10.0.4.20', 8005)\nDatagram 'Client: Ping' received from ('10.0.1.21', 8005)\nDatagram 'Client: Ping' received from ('10.0.4.21', 8005)\nDatagram 'Client: Ping' received from ('10.0.4.21', 8005)\nDatagram 'Client: Ping' received from ('10.0.5.20', 8005)\nDatagram 'Client: Ping' received from ('10.0.0.21', 8005)\nDatagram 'Client: Ping' received from ('10.0.3.21', 8005)\nDatagram 'Client: Ping' received from ('10.0.0.20', 8005)\nDatagram 'Client: Ping' received from ('10.0.5.21', 8005)\nDatagram 'Client: Ping' received from ('10.0.3.20', 8005)\nDatagram 'Client: Ping' received from ('10.0.4.20', 8005)\nDatagram 'Client: Ping' received from ('10.0.4.20', 8005)\nDatagram 'Client: Ping' received from ('10.0.1.21', 8005)\nDatagram 'Client: Ping' received from ('10.0.4.21', 8005)\nDatagram 'Client: Ping' received from ('10.0.4.21', 8005)\nDatagram 'Client: Ping' received from ('10.0.5.20', 8005)\n\nLimitations:\n\n1. Docker images must be downloaded on the host as usually a CORE node does not \n have access to the internet.\n2. Each node isolates running containers (keeps things simple)\n3. Recent version of docker needed so that --net host can be used. This does \n not further abstract the network within a node and allows multicast which \n is not enabled within Docker containers at the moment.\n4. The core-daemon must be restarted for new images to show up.\n5. A Docker-daemon is run within each node but the images are shared. This\n does mean that the daemon attempts to access an SQLlite database within the\n host. At startup all the nodes will try to access this and it will be locked\n for most due to contention. The service just does a hackish wait for 1 second\n and retry. This means all the docker containers can take a while to come up\n depending on how many nodes you have. \n\n'''\n\nimport os\nimport sys\ntry:\n from docker import Client\nexcept Exception:\n pass\n\nfrom core.service import CoreService, addservice\nfrom core.misc.ipaddr import IPv4Prefix, IPv6Prefix\n\n\naddservice(DockerService)\n\n# This auto-loads Docker images having a :core tag, adding them to the list\n# of services under the \"Docker\" group.\nif 'Client' in globals():\n client = Client(version='1.10')\n images = client.images()\n del client\nelse:\n images = []\nfor image in images:\n if u'<none>' in image['RepoTags'][0]:\n continue\n for repo in image['RepoTags']:\n if u':core' not in repo:\n continue\n dockerid = repo.encode('ascii','ignore').split(':')[0]\n SubClass = type('SubClass', (DockerService,),\n {'_name': dockerid, '_image': dockerid})\n addservice(SubClass)\ndel images\n", "metadata": "root", "header": "['module', '___EOS___']", "index": 0 }, { "content": "class DockerService(CoreService):\n ''' This is a service which will allow running docker containers in a CORE\n node. \n '''\n _name = \"Docker\"\n _group = \"Docker\"\n _depends = ()\n _dirs = ('/var/lib/docker/containers/', '/run/shm', '/run/resolvconf',)\n _configs = ('docker.sh', )\n _startindex = 50\n _startup = ('sh docker.sh',)\n _shutdown = ('service docker stop', )\n # Container image to start\n _image = \"\"\n", "metadata": "root.DockerService", "header": "['module', '___EOS___']", "index": 117 }, { "content": " @classmethod\n def generateconfig(cls, node, filename, services):\n ''' Returns a string having contents of a docker.sh script that\n can be modified to start a specific docker image.\n '''\n cfg = \"#!/bin/sh\\n\"\n cfg += \"# auto-generated by Docker (docker.py)\\n\"\n # Docker likes to think it has DNS set up or it complains. \n # Unless your network was attached to the Internet this is\n # non-functional but hides error messages.\n cfg += 'echo \"nameserver 8.8.8.8\" > /run/resolvconf/resolv.conf\\n'\n # Starts the docker service. In Ubuntu this is docker.io; in other\n # distros may just be docker\n cfg += 'service docker start\\n'\n cfg += \"# you could add a command to start a image here eg:\\n\"\n if not cls._image:\n cfg += \"# docker run -d --net host --name coreDock <imagename>\\n\"\n else:\n cfg += \"\"\"\\\nresult=1\nuntil [ $result -eq 0 ]; do\n docker run -d --net host --name coreDock %s\n result=$?\n # this is to alleviate contention to docker's SQLite database\n sleep 0.3\ndone\n\"\"\" % (cls._image, )\n return cfg", "metadata": "root.DockerService.generateconfig", "header": "['class', 'DockerService', '(', 'CoreService', ')', ':', '___EOS___']", "index": 132 } ]
[ { "span": "import os", "start_line": 107, "start_column": 0, "end_line": 107, "end_column": 9 }, { "span": "import sys", "start_line": 108, "start_column": 0, "end_line": 108, "end_column": 10 }, { "span": "from core.misc.ipaddr import IPv4Prefix, IPv6Prefix", "start_line": 115, "start_column": 0, "end_line": 115, "end_column": 51 } ]
[]
1
false
[ "[CLS]_", "Un", "used_", "import_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "#", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "CORE", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Copy", "right", " ", "(", "c", ")", "2014", " ", "the", " ", "Bo", "ein", "g", " ", "Compa", "ny", "._", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "See", " ", "the", " ", "LICENSE", " ", "file", " ", "include", "d", " ", "in", " ", "this", " ", "distribu", "tion", "._", "\\u\\u\\uNL\\u\\u\\u_", "#", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "author", "s", ":", " ", "Stu", "art", " ", "Mars", "den_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", " ", "Je", "ff", " ", "Ah", "ren", "hol", "z", " ", "<", "je", "ff", "rey", ".", "m", ".", "ah", "ren", "hol", "z", "@", "bo", "ein", "g", ".", "com", ">_", "\\u\\u\\uNL\\u\\u\\u_", "#", "_", "\\u\\u\\uNL\\u\\u\\u_", "'''", " ", "Docke", "r", " ", "service", " ", "allow", "s", " ", "runn", "ing", " ", "docker", " ", "container", "s", " ", "within", " ", "CORE", " ", "nodes", ".", "\\", "10", ";", "\\", "10", ";", "The", " ", "runn", "ing", " ", "of", " ", "Docke", "r", " ", "within", " ", "a", " ", "CORE", " ", "node", " ", "allow", "s", " ", "for", " ", "addition", "al", " ", "extensi", "bilit", "y", " ", "to", "\\", "10", ";", "the", " ", "CORE", " ", "service", "s", ".", " ", "Thi", "s", " ", "allow", "s", " ", "network", " ", "applica", "tion", "s", " ", "and", " ", "protoc", "ols", " ", "to", " ", "be", " ", "easi", "ly", "\\", "10", ";", "package", "d", " ", "and", " ", "run", " ", "on", " ", "any", " ", "node", ".", "\\", "10", ";", "\\", "10", ";", "Thi", "s", " ", "service", " ", "tha", "t", " ", "will", " ", "add", " ", "a", " ", "new", " ", "group", " ", "to", " ", "the", " ", "service", "s", " ", "list", ".", " ", "Thi", "s", "\\", "10", ";", "will", " ", "have", " ", "a", " ", "service", " ", "call", "ed", " ", "Docke", "r", " ", "whi", "ch", " ", "will", " ", "just", " ", "start", " ", "the", " ", "docker", " ", "service", "\\", "10", ";", "within", " ", "the", " ", "node", " ", "but", " ", "not", " ", "run", " ", "anyt", "hing", ".", " ", "It", " ", "will", " ", "als", "o", " ", "scan", " ", "all", " ", "docker", " ", "images", " ", "on", "\\", "10", ";", "the", " ", "host", " ", "machine", ".", " ", "If", " ", "any", " ", "are", " ", "tagg", "ed", " ", "with", " ", "'", "core", "'", " ", "then", " ", "the", "y", " ", "will", " ", "be", " ", "adde", "d", " ", "as", " ", "a", "\\", "10", ";", "service", " ", "to", " ", "the", " ", "Docke", "r", " ", "group", ".", " ", "The", " ", "image", " ", "will", " ", "then", " ", "be", " ", "auto", " ", "run", " ", "if", " ", "tha", "t", " ", "service", " ", "is", "\\", "10", ";", "selecte", "d", ".", "\\", "10", ";", "\\", "10", ";", "Thi", "s", " ", "require", "s", " ", "a", " ", "recent", " ", "version", " ", "of", " ", "Docke", "r", ".", " ", "Thi", "s", " ", "was", " ", "tested", " ", "usi", "ng", " ", "a", " ", "PP", "A", " ", "on", " ", "Ub", "unt", "u", "\\", "10", ";", " ", "with", " ", "version", " ", "1.2", ".0", ".", " ", "The", " ", "version", " ", "in", " ", "the", " ", "standard", " ", "Ub", "unt", "u", " ", "repo", " ", "is", " ", "to", " ", "old", " ", "for", " ", "\\", "10", ";", "this", " ", "purpose", " ", "(", "we", " ", "need", " ", "--", "net", " ", "host", ").", "\\", "10", ";", "\\", "10", ";", "It", " ", "als", "o", " ", "require", "s", " ", "docker", "-", "py", " ", "(", "https", "://", "pypi", ".", "python", ".", "org", "/", "pypi", "/", "docker", "-", "py", ")", " ", "whi", "ch", " ", "can", " ", "be", "\\", "10", ";", "install", "ed", " ", "with", " ", "'", "pip", " ", "install", " ", "docker", "-", "py", "'.", " ", "Thi", "s", " ", "is", " ", "used", " ", "to", " ", "interface", " ", "with", " ", "Docke", "r", "\\", "10", ";", "from", " ", "the", " ", "python", " ", "service", ".", "\\", "10", ";", "\\", "10", ";", "An", " ", "example", " ", "use", " ", "case", " ", "is", " ", "to", " ", "pull", " ", "an", " ", "image", " ", "from", " ", "Docke", "r", ".", "com", ".", " ", "A", " ", "test", " ", "image", " ", "has", " ", "bee", "n", "\\", "10", ";", "uploade", "d", " ", "for", " ", "this", " ", "purpose", ":", "\\", "10", ";", "\\", "10", ";", "sudo", " ", "docker", " ", "pull", " ", "stu", "art", "mars", "den", "/", "multica", "stp", "ing", "\\", "10", ";", "\\", "10", ";", "Thi", "s", " ", "download", "s", " ", "an", " ", "image", " ", "whi", "ch", " ", "is", " ", "based", " ", "on", " ", "Ub", "unt", "u", " ", "14.0", "4", " ", "with", " ", "python", " ", "and", " ", "twist", "ed", ".", "\\", "10", ";", "It", " ", "runs", " ", "a", " ", "simple", " ", "program", " ", "tha", "t", " ", "send", "s", " ", "a", " ", "multica", "st", " ", "ping", " ", "and", " ", "listen", "s", " ", "and", " ", "record", "s", "\\", "10", ";", "any", " ", "it", " ", "receive", "s", ".", "\\", "10", ";", "\\", "10", ";", "In", " ", "order", " ", "for", " ", "this", " ", "to", " ", "appear", " ", "as", " ", "a", " ", "docker", " ", "service", " ", "it", " ", "must", " ", "be", " ", "tagg", "ed", " ", "with", " ", "core", ".", "\\", "10", ";", "Fin", "d", " ", "out", " ", "the", " ", "id", " ", "by", " ", "runn", "ing", " ", "'", "sudo", " ", "docker", " ", "images", "'.", " ", "You", " ", "shou", "ld", " ", "see", " ", "all", " ", "install", "ed", "\\", "10", ";", "images", " ", "and", " ", "the", " ", "one", " ", "you", " ", "want", " ", "look", "s", " ", "like", " ", "this", ":", "\\", "10", ";", "\\", "10", ";", "stu", "art", "mars", "den", "/", "multica", "stp", "ing", " ", " ", " ", " ", "late", "st", " ", " ", " ", " ", " ", " ", "483", "348", "7e", "6", "6d", "2", " ", " ", " ", " ", "20", " ", "hour", "s", "\\", "10", ";", "ago", " ", " ", " ", " ", "487", " ", "MB", "\\", "10", ";", "\\", "10", ";", "The", " ", "id", " ", "will", " ", "be", " ", "different", " ", "on", " ", "your", " ", "machine", " ", "so", " ", "use", " ", "it", " ", "in", " ", "the", " ", "follow", "ing", " ", "command", ":", "\\", "10", ";", "\\", "10", ";", "sudo", " ", "docker", " ", "tag", " ", "483", "348", "7e", "6", "6d", "2", " ", "stu", "art", "mars", "den", "/", "multica", "stp", "ing", ":", "core", "\\", "10", ";", "\\", "10", ";", "Thi", "s", " ", "image", " ", "will", " ", "be", " ", "liste", "d", " ", "in", " ", "the", " ", "service", "s", " ", "after", " ", "we", " ", "restart", " ", "the", " ", "core", "-", "daemon", ":", " ", "\\", "10", ";", "\\", "10", ";", "sudo", " ", "service", " ", "core", "-", "daemon", " ", "restart", "\\", "10", ";", "\\", "10", ";", "You", " ", "can", " ", "set", " ", "up", " ", "a", " ", "simple", " ", "network", " ", "with", " ", "a", " ", "number", " ", "of", " ", "PC", "s", " ", "connect", "ed", " ", "to", " ", "a", " ", "switch", ".", " ", "Set", "\\", "10", ";", "the", " ", "stu", "art", "mars", "den", "/", "multica", "stp", "ing", " ", "service", " ", "for", " ", "all", " ", "the", " ", "PC", "s", ".", " ", "Whe", "n", " ", "start", "ed", " ", "the", "y", " ", "will", "\\", "10", ";", "all", " ", "begin", " ", "sendin", "g", " ", "Multi", "cast", " ", "ping", "s", ".", " ", "\\", "10", ";", "\\", "10", ";", "In", " ", "order", " ", "to", " ", "see", " ", "what", " ", "is", " ", "happ", "eni", "ng", " ", "you", " ", "can", " ", "go", " ", "in", " ", "to", " ", "the", " ", "termina", "l", " ", "of", " ", "a", " ", "node", " ", "and", "\\", "10", ";", "look", " ", "at", " ", "the", " ", "docker", " ", "log", ".", " ", "Eas", "y", " ", "short", "hand", " ", "is", ":", "\\", "10", ";", "\\", "10", ";", "docker", " ", "logs", " ", "$(", "docker", " ", "ps", " ", "-", "q", ")", "\\", "10", ";", "\\", "10", ";", "Whi", "ch", " ", "just", " ", "show", "s", " ", "the", " ", "log", " ", "of", " ", "the", " ", "runn", "ing", " ", "docker", " ", "container", " ", "(", "usual", "ly", " ", "just", " ", "one", " ", "per", "\\", "10", ";", "node", ").", " ", "I", " ", "have", " ", "adde", "d", " ", "this", " ", "as", " ", "an", " ", "observer", " ", "node", " ", "to", " ", "my", " ", "setup", ":", " ", "Name", ":", " ", "docker", " ", "logs", "\\", "10", ";", "Command", ":", " ", "bash", " ", "-", "c", " ", "'", "docker", " ", "logs", " ", "$(", "docker", " ", "ps", " ", "-", "q", ")", " ", "|", " ", "tail", " ", "-", "20", "'", "\\", "10", ";", "\\", "10", ";", "So", " ", "I", " ", "can", " ", "just", " ", "hover", " ", "over", " ", "to", " ", "see", " ", "the", " ", "log", " ", "whi", "ch", " ", "look", "s", " ", "like", " ", "this", ":", "\\", "10", ";", "\\", "10", ";", "Data", "gram", " ", "'", "Client", ":", " ", "Ping", "'", " ", "receive", "d", " ", "from", " ", "('", "10.", "0.", "0.20", "',", " ", "800", "5", ")", "\\", "10", ";", "Data", "gram", " ", "'", "Client", ":", " ", "Ping", "'", " ", "receive", "d", " ", "from", " ", "('", "10.", "0.", "5.2", "1", "',", " ", "800", "5", ")", "\\", "10", ";", "Data", "gram", " ", "'", "Client", ":", " ", "Ping", "'", " ", "receive", "d", " ", "from", " ", "('", "10.", "0.", "3.2", "0", "',", " ", "800", "5", ")", "\\", "10", ";", "Data", "gram", " ", "'", "Client", ":", " ", "Ping", "'", " ", "receive", "d", " ", "from", " ", "('", "10.", "0.", "4.2", "0", "',", " ", "800", "5", ")", "\\", "10", ";", "Data", "gram", " ", "'", "Client", ":", " ", "Ping", "'", " ", "receive", "d", " ", "from", " ", "('", "10.", "0.", "4.2", "0", "',", " ", "800", "5", ")", "\\", "10", ";", "Data", "gram", " ", "'", "Client", ":", " ", "Ping", "'", " ", "receive", "d", " ", "from", " ", "('", "10.", "0.", "1.2", "1", "',", " ", "800", "5", ")", "\\", "10", ";", "Data", "gram", " ", "'", "Client", ":", " ", "Ping", "'", " ", "receive", "d", " ", "from", " ", "('", "10.", "0.", "4.2", "1", "',", " ", "800", "5", ")", "\\", "10", ";", "Data", "gram", " ", "'", "Client", ":", " ", "Ping", "'", " ", "receive", "d", " ", "from", " ", "('", "10.", "0.", "4.2", "1", "',", " ", "800", "5", ")", "\\", "10", ";", "Data", "gram", " ", "'", "Client", ":", " ", "Ping", "'", " ", "receive", "d", " ", "from", " ", "('", "10.", "0.", "5.2", "0", "',", " ", "800", "5", ")", "\\", "10", ";", "Data", "gram", " ", "'", "Client", ":", " ", "Ping", "'", " ", "receive", "d", " ", "from", " ", "('", "10.", "0.", "0.21", "',", " ", "800", "5", ")", "\\", "10", ";", "Data", "gram", " ", "'", "Client", ":", " ", "Ping", "'", " ", "receive", "d", " ", "from", " ", "('", "10.", "0.", "3.2", "1", "',", " ", "800", "5", ")", "\\", "10", ";", "Data", "gram", " ", "'", "Client", ":", " ", "Ping", "'", " ", "receive", "d", " ", "from", " ", "('", "10.", "0.", "0.20", "',", " ", "800", "5", ")", "\\", "10", ";", "Data", "gram", " ", "'", "Client", ":", " ", "Ping", "'", " ", "receive", "d", " ", "from", " ", "('", "10.", "0.", "5.2", "1", "',", " ", "800", "5", ")", "\\", "10", ";", "Data", "gram", " ", "'", "Client", ":", " ", "Ping", "'", " ", "receive", "d", " ", "from", " ", "('", "10.", "0.", "3.2", "0", "',", " ", "800", "5", ")", "\\", "10", ";", "Data", "gram", " ", "'", "Client", ":", " ", "Ping", "'", " ", "receive", "d", " ", "from", " ", "('", "10.", "0.", "4.2", "0", "',", " ", "800", "5", ")", "\\", "10", ";", "Data", "gram", " ", "'", "Client", ":", " ", "Ping", "'", " ", "receive", "d", " ", "from", " ", "('", "10.", "0.", "4.2", "0", "',", " ", "800", "5", ")", "\\", "10", ";", "Data", "gram", " ", "'", "Client", ":", " ", "Ping", "'", " ", "receive", "d", " ", "from", " ", "('", "10.", "0.", "1.2", "1", "',", " ", "800", "5", ")", "\\", "10", ";", "Data", "gram", " ", "'", "Client", ":", " ", "Ping", "'", " ", "receive", "d", " ", "from", " ", "('", "10.", "0.", "4.2", "1", "',", " ", "800", "5", ")", "\\", "10", ";", "Data", "gram", " ", "'", "Client", ":", " ", "Ping", "'", " ", "receive", "d", " ", "from", " ", "('", "10.", "0.", "4.2", "1", "',", " ", "800", "5", ")", "\\", "10", ";", "Data", "gram", " ", "'", "Client", ":", " ", "Ping", "'", " ", "receive", "d", " ", "from", " ", "('", "10.", "0.", "5.2", "0", "',", " ", "800", "5", ")", "\\", "10", ";", "\\", "10", ";", "Limit", "ation", "s", ":", "\\", "10", ";", "\\", "10", ";", "1", ".", " ", "Docke", "r", " ", "images", " ", "must", " ", "be", " ", "download", "ed", " ", "on", " ", "the", " ", "host", " ", "as", " ", "usual", "ly", " ", "a", " ", "CORE", " ", "node", " ", "doe", "s", " ", "not", " ", "\\", "10", ";", " ", " ", " ", "have", " ", "access", " ", "to", " ", "the", " ", "interne", "t", ".", "\\", "10", ";", "2", ".", " ", "Ea", "ch", " ", "node", " ", "isolate", "s", " ", "runn", "ing", " ", "container", "s", " ", "(", "keep", "s", " ", "thing", "s", " ", "simple", ")", "\\", "10", ";", "3", ".", " ", "Rece", "nt", " ", "version", " ", "of", " ", "docker", " ", "need", "ed", " ", "so", " ", "tha", "t", " ", "--", "net", " ", "host", " ", "can", " ", "be", " ", "used", ".", " ", "Thi", "s", " ", "doe", "s", " ", "\\", "10", ";", " ", " ", " ", "not", " ", "fur", "ther", " ", "abstract", " ", "the", " ", "network", " ", "within", " ", "a", " ", "node", " ", "and", " ", "allow", "s", " ", "multica", "st", " ", "whi", "ch", " ", "\\", "10", ";", " ", " ", " ", "is", " ", "not", " ", "enable", "d", " ", "within", " ", "Docke", "r", " ", "container", "s", " ", "at", " ", "the", " ", "moment", ".", "\\", "10", ";", "4", ".", " ", "The", " ", "core", "-", "daemon", " ", "must", " ", "be", " ", "restart", "ed", " ", "for", " ", "new", " ", "images", " ", "to", " ", "show", " ", "up", ".", "\\", "10", ";", "5", ".", " ", "A", " ", "Docke", "r", "-", "daemon", " ", "is", " ", "run", " ", "within", " ", "each", " ", "node", " ", "but", " ", "the", " ", "images", " ", "are", " ", "shared", ".", " ", "Thi", "s", "\\", "10", ";", " ", " ", " ", "doe", "s", " ", "mean", " ", "tha", "t", " ", "the", " ", "daemon", " ", "atte", "mpt", "s", " ", "to", " ", "access", " ", "an", " ", "SQL", "lite", " ", "databa", "se", " ", "within", " ", "the", "\\", "10", ";", " ", " ", " ", "host", ".", " ", "At", " ", "start", "up", " ", "all", " ", "the", " ", "nodes", " ", "will", " ", "try", " ", "to", " ", "access", " ", "this", " ", "and", " ", "it", " ", "will", " ", "be", " ", "lock", "ed", "\\", "10", ";", " ", " ", " ", "for", " ", "most", " ", "due", " ", "to", " ", "content", "ion", ".", " ", "The", " ", "service", " ", "just", " ", "doe", "s", " ", "a", " ", "hack", "ish", " ", "wait", " ", "for", " ", "1", " ", "second", "\\", "10", ";", " ", " ", " ", "and", " ", "retr", "y", ".", " ", "Thi", "s", " ", "means", " ", "all", " ", "the", " ", "docker", " ", "container", "s", " ", "can", " ", "take", " ", "a", " ", "whi", "le", " ", "to", " ", "come", " ", "up", "\\", "10", ";", " ", " ", " ", "depend", "ing", " ", "on", " ", "how", " ", "many", " ", "nodes", " ", "you", " ", "have", ".", " ", " ", "\\", "10", ";", "\\", "10", ";'", "''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "import_", "os_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "sys_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "from_", "docker_", "import_", "Client_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "Exception_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "pass_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "from_", "core_", "._", "service_", "import_", "Core", "Service_", ",_", "adds", "ervice", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "core_", "._", "misc_", "._", "ipaddr_", "import_", "IP", "v", "4", "Prefix_", ",_", "IP", "v6", "Prefix_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "adds", "ervice", "_", "(_", "Docke", "r", "Service_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Thi", "s", " ", "auto", "-", "load", "s", " ", "Docke", "r", " ", "images", " ", "hav", "ing", " ", "a", " ", ":", "core", " ", "tag", ",", " ", "addin", "g", " ", "them", " ", "to", " ", "the", " ", "list_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "of", " ", "service", "s", " ", "under", " ", "the", " ", "\"", "Docke", "r", "\"", " ", "group", "._", "\\u\\u\\uNL\\u\\u\\u_", "if_", "'", "Client", "'_", "in_", "globals_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "client_", "=_", "Client_", "(_", "version_", "=_", "'", "1.1", "0", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "images_", "=_", "client_", "._", "images_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "del_", "client_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "images_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "for_", "image_", "in_", "images_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "u", "'<", "none", ">'_", "in_", "image_", "[_", "'", "Rep", "o", "Ta", "gs", "'_", "]_", "[_", "0_", "]_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "continue_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "for_", "repo_", "in_", "image_", "[_", "'", "Rep", "o", "Ta", "gs", "'_", "]_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "u", "':", "core", "'_", "not_", "in_", "repo_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "continue_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "docker", "id_", "=_", "repo_", "._", "encode_", "(_", "'", "ascii", "'_", ",_", "'", "ignore", "'_", ")_", "._", "split_", "(_", "':'_", ")_", "[_", "0_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "Sub", "Class_", "=_", "type_", "(_", "'", "Sub", "Class", "'_", ",_", "(_", "Docke", "r", "Service_", ",_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "{_", "'\\u", "name", "'_", ":_", "docker", "id_", ",_", "'\\u", "image", "'_", ":_", "docker", "id_", "}_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "adds", "ervice", "_", "(_", "Sub", "Class_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "del_", "images_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "class_", "Docke", "r", "Service_", "(_", "Core", "Service_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "'''", " ", "Thi", "s", " ", "is", " ", "a", " ", "service", " ", "whi", "ch", " ", "will", " ", "allow", " ", "runn", "ing", " ", "docker", " ", "container", "s", " ", "in", " ", "a", " ", "CORE", "\\", "10", ";", " ", " ", " ", " ", "node", ".", " ", "\\", "10", ";", " ", " ", " ", " ", "'''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u", "name_", "=_", "\"", "Docke", "r", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u", "group_", "=_", "\"", "Docke", "r", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u", "depends_", "=_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u", "dirs_", "=_", "(_", "'/", "var", "/", "lib", "/", "docker", "/", "container", "s", "/'_", ",_", "'/", "run", "/", "shm", "'_", ",_", "'/", "run", "/", "resolv", "conf", "'_", ",_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u", "configs_", "=_", "(_", "'", "docker", ".", "sh", "'_", ",_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u", "startin", "dex_", "=_", "50_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u", "startup_", "=_", "(_", "'", "sh", " ", "docker", ".", "sh", "'_", ",_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u", "shutdown_", "=_", "(_", "'", "service", " ", "docker", " ", "stop", "'_", ",_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Containe", "r", " ", "image", " ", "to", " ", "start_", "\\u\\u\\uNL\\u\\u\\u_", "\\u", "image_", "=_", "\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "[SEP]_", "class_", "Docke", "r", "Service_", "(_", "Core", "Service_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "@_", "classmethod_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "generat", "eco", "nfig_", "(_", "cls_", ",_", "node_", ",_", "filename_", ",_", "services_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "'''", " ", "Return", "s", " ", "a", " ", "string", " ", "hav", "ing", " ", "content", "s", " ", "of", " ", "a", " ", "docker", ".", "sh", " ", "script", " ", "tha", "t", "\\", "10", ";", " ", " ", " ", " ", "can", " ", "be", " ", "modifi", "ed", " ", "to", " ", "start", " ", "a", " ", "specific", " ", "docker", " ", "image", ".", "\\", "10", ";", " ", " ", " ", " ", "'''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "cfg_", "=_", "\"#", "!", "/", "bin", "/", "sh", "\\\\", "n", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "cfg_", "+=_", "\"#", " ", "auto", "-", "generat", "ed", " ", "by", " ", "Docke", "r", " ", "(", "docker", ".", "py", ")\\\\", "n", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Docke", "r", " ", "likes", " ", "to", " ", "think", " ", "it", " ", "has", " ", "DNS", " ", "set", " ", "up", " ", "or", " ", "it", " ", "compl", "ain", "s", ".", " _", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", " ", " ", "Un", "less", " ", "your", " ", "network", " ", "was", " ", "attache", "d", " ", "to", " ", "the", " ", "Intern", "et", " ", "this", " ", "is_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", " ", " ", "non", "-", "functional", " ", "but", " ", "hide", "s", " ", "error", " ", "message", "s", "._", "\\u\\u\\uNL\\u\\u\\u_", "cfg_", "+=_", "'", "echo", " ", "\"", "nameserv", "er", " ", "8.8", ".8", ".8", "\"", " ", ">", " ", "/", "run", "/", "resolv", "conf", "/", "resolv", ".", "conf", "\\\\", "n", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Start", "s", " ", "the", " ", "docker", " ", "service", ".", " ", "In", " ", "Ub", "unt", "u", " ", "this", " ", "is", " ", "docker", ".", "io", ";", " ", "in", " ", "other_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", " ", " ", "distr", "os", " ", "may", " ", "just", " ", "be", " ", "docker_", "\\u\\u\\uNL\\u\\u\\u_", "cfg_", "+=_", "'", "service", " ", "docker", " ", "start", "\\\\", "n", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "cfg_", "+=_", "\"#", " ", "you", " ", "coul", "d", " ", "add", " ", "a", " ", "command", " ", "to", " ", "start", " ", "a", " ", "image", " ", "here", " ", "eg", ":\\\\", "n", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "not_", "cls_", "._", "\\u", "image_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "cfg_", "+=_", "\"#", " ", "docker", " ", "run", " ", "-", "d", " ", "--", "net", " ", "host", " ", "--", "name", " ", "core", "Dock", " ", "<", "imagen", "ame", ">\\\\", "n", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "cfg_", "+=_", "\"\"\"", "\\\\", "\\", "10", ";", "result", "=", "1", "\\", "10", ";", "unti", "l", " ", "[", " ", "$", "result", " ", "-", "eq", " ", "0", " ", "];", " ", "do", "\\", "10", ";", " ", " ", "docker", " ", "run", " ", "-", "d", " ", "--", "net", " ", "host", " ", "--", "name", " ", "core", "Dock", " ", "%", "s", "\\", "10", ";", " ", " ", "result", "=$", "?", "\\", "10", ";", " ", " ", "#", " ", "this", " ", "is", " ", "to", " ", "alle", "via", "te", " ", "content", "ion", " ", "to", " ", "docker", "'", "s", " ", "SQL", "ite", " ", "databa", "se", "\\", "10", ";", " ", " ", "sleep", " ", "0.",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2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 ]
Unused local variable
CGATOxford/cgat/scripts/r_table2scatter.py
[ { "content": "def main(argv=None):\n\n if argv is None:\n argv = sys.argv\n\n parser = E.OptionParser(\n version=\"%prog version: $Id: r_table2scatter.py 2782 2009-09-10 11:40:29Z andreas $\")\n\n parser.add_option(\"-c\", \"--columns\", dest=\"columns\", type=\"string\",\n help=\"columns to take from table. Choices are 'all', 'all-but-first' or a ','-separated list of columns.\")\n\n parser.add_option(\"--logscale\", dest=\"logscale\", type=\"string\",\n help=\"log-transform one or both axes [default=%Default].\")\n\n parser.add_option(\"-a\", \"--hardcopy\", dest=\"hardcopy\", type=\"string\",\n help=\"write hardcopy to file [default=%default].\",\n metavar=\"FILE\")\n\n parser.add_option(\"-f\", \"--file\", dest=\"input_filename\", type=\"string\",\n help=\"filename with table data [default=%default].\",\n metavar=\"FILE\")\n\n parser.add_option(\"-2\", \"--file2\", dest=\"input_filename2\", type=\"string\",\n help=\"additional data file [default=%default].\",\n metavar=\"FILE\")\n\n parser.add_option(\"-s\", \"--stats\", dest=\"statistics\", type=\"choice\",\n choices=(\"correlation\", \"spearman\", \"pearson\", \"count\"),\n help=\"statistical quantities to compute [default=%default]\",\n action=\"append\")\n\n parser.add_option(\"-p\", \"--plot\", dest=\"plot\", type=\"choice\",\n choices=(\"scatter\", \"pairs\", \"panel\", \"bar\", \"bar-stacked\",\n \"bar-besides\", \"1_vs_x\", \"matched\", \"boxplot\", \"scatter+marginal\",\n \"scatter-regression\"),\n help=\"plots to plot [default=%default]\",\n action=\"append\")\n\n parser.add_option(\"-t\", \"--threshold\", dest=\"threshold\", type=\"float\",\n help=\"min threshold to use for counting method [default=%default].\")\n\n parser.add_option(\"-o\", \"--colours\", dest=\"colours\", type=\"int\",\n help=\"column with colour information [default=%default].\")\n\n parser.add_option(\"-l\", \"--plot-labels\", dest=\"labels\", type=\"string\",\n help=\"column labels for x and y in matched plots [default=%default].\")\n\n parser.add_option(\"-d\", \"--add-diagonal\", dest=\"add_diagonal\", action=\"store_true\",\n help=\"add diagonal to plot [default=%default].\")\n\n parser.add_option(\"-e\", \"--plot-legend\", dest=\"legend\", type=\"int\",\n help=\"column with legend [default=%default].\")\n\n parser.add_option(\"-r\", \"--options\", dest=\"r_options\", type=\"string\",\n help=\"R plotting options [default=%default].\")\n\n parser.add_option(\"--format\", dest=\"format\", type=\"choice\",\n choices=(\"full\", \"sparse\"),\n help=\"output format [default=%default].\")\n\n parser.add_option(\"--title\", dest=\"title\", type=\"string\",\n help=\"\"\"plot title [default=%default].\"\"\")\n\n parser.add_option(\"\", \"--xrange\", dest=\"xrange\", type=\"string\",\n help=\"x viewing range of plot [default=%default].\")\n\n parser.add_option(\"\", \"--yrange\", dest=\"yrange\", type=\"string\",\n help=\"y viewing range of plot[default=%default].\")\n\n parser.add_option(\"--allow-empty-file\", dest=\"fail_on_empty\", action=\"store_false\",\n help=\"do not fail on empty input [default=%default].\")\n\n parser.add_option(\"--fail-on-empty\", dest=\"fail_on_empty\", action=\"store_true\",\n help=\"fail on empty input [default=%default].\")\n\n parser.set_defaults(\n hardcopy=None,\n input_filename=\"\",\n input_filename2=None,\n columns=\"all\",\n logscale=None,\n statistics=[],\n plot=[],\n threshold=0.0,\n labels=\"x,y\",\n colours=None,\n diagonal=False,\n legend=None,\n title=None,\n xrange=None,\n yrange=None,\n r_options=\"\",\n fail_on_empty=True,\n format=\"full\")\n\n (options, args) = E.Start(parser)\n\n if len(args) == 1 and not options.input_filename:\n options.input_filename = args[0]\n\n if options.columns not in (\"all\", \"all-but-first\"):\n options.columns = map(lambda x: int(x) - 1, options.columns.split(\",\"))\n\n if options.colours:\n options.colours -= 1\n if options.legend:\n options.legend -= 1\n\n table = {}\n headers = []\n\n # read data matrix\n if options.input_filename:\n lines = open(options.input_filename, \"r\").readlines()\n else:\n # note: this will not work for interactive viewing, but\n # creating hardcopy plots works.\n lines = sys.stdin.readlines()\n\n lines = filter(lambda x: x[0] != \"#\", lines)\n\n if len(lines) == 0:\n if options.fail_on_empty:\n raise IOError(\"no input\")\n E.warn(\"empty input\")\n E.Stop()\n return\n\n matrix, headers, colours, legend = readTable(lines,\n \"matrix\",\n take_columns=options.columns,\n headers=True,\n colours=options.colours,\n row_names=options.legend)\n\n if options.input_filename2:\n # read another matrix (should be of the same format.\n matrix2, headers2, colours2, legend2 = readTable(\n lines,\n \"matrix2\",\n take_columns=options.columns,\n headers=True,\n colours=options.colours,\n row_names=options.legend)\n\n R.assign(\"headers\", headers)\n\n ndata = R(\"\"\"length( matrix[,1] )\"\"\")[0]\n\n if options.loglevel >= 1:\n options.stdlog.write(\"# read matrix: %ix%i\\n\" % (len(headers), ndata))\n\n if colours:\n R.assign(\"colours\", colours)\n\n for method in options.statistics:\n\n if method == \"correlation\":\n cor = R.cor(matrix, use=\"pairwise.complete.obs\")\n writeMatrix(sys.stdout, cor, headers=headers, format=\"%5.2f\")\n\n elif method == \"pearson\":\n options.stdout.write(\"\\t\".join((\"var1\",\n \"var2\",\n \"coeff\",\n \"passed\",\n \"pvalue\",\n \"n\",\n \"method\",\n \"alternative\")) + \"\\n\")\n for x in range(len(headers) - 1):\n for y in range(x + 1, len(headers)):\n try:\n result = R(\n \"\"\"cor.test( matrix[,%i], matrix[,%i] )\"\"\" % (x + 1, y + 1))\n except rpy.RPyException, msg:\n E.warn(\"correlation not computed for columns %i(%s) and %i(%s): %s\" % (\n x, headers[x], y, headers[y], msg))\n options.stdout.write(\"%s\\t%s\\t%s\\t%s\\t%s\\t%i\\t%s\\t%s\\n\" %\n (headers[x], headers[y],\n \"na\",\n \"na\",\n \"na\",\n 0,\n \"na\",\n \"na\"))\n\n else:\n options.stdout.write(\n \"%s\\t%s\\t%6.4f\\t%s\\t%e\\t%i\\t%s\\t%s\\n\" %\n (headers[x], headers[y],\n result.rx2('estimate').rx2(\n 'cor')[0],\n Stats.getSignificance(\n float(result.rx2('p.value')[0])),\n result.rx2('p.value')[0],\n result.rx2('parameter').rx2(\n 'df')[0],\n result.rx2('method')[0],\n result.rx2('alternative')[0]))\n\n elif method == \"spearman\":\n options.stdout.write(\"\\t\".join((\"var1\", \"var2\",\n \"coeff\",\n \"passed\",\n \"pvalue\",\n \"method\",\n \"alternative\")) + \"\\n\")\n for x in range(len(headers) - 1):\n for y in range(x + 1, len(headers)):\n result = R(\n \"\"\"cor.test( matrix[,%i], matrix[,%i], method='spearman')\"\"\" % (x + 1, y + 1))\n options.stdout.write(\n \"%s\\t%s\\t%6.4f\\t%s\\t%e\\t%i\\t%s\\t%s\\n\" %\n (headers[x], headers[y],\n result['estimate']['rho'],\n Stats.getSignificance(float(result['p.value'])),\n result['p.value'],\n result['parameter']['df'],\n result['method'],\n result['alternative']))\n\n elif method == \"count\":\n # number of shared elements > threshold\n m, r, c = MatlabTools.ReadMatrix(open(options.input_filename, \"r\"),\n take=options.columns,\n headers=True)\n mask = numpy.greater(m, options.threshold)\n counts = numpy.dot(numpy.transpose(mask), mask)\n writeMatrix(options.stdout, counts, headers=c, format=\"%i\")\n\n if options.plot:\n\n # remove columns that are completely empty\n if \"pairs\" in options.plot:\n colsums = R('''colSums( is.na(matrix ))''')\n take = [x for x in range(len(colsums)) if colsums[x] != ndata]\n if take:\n E.warn(\"removing empty columns %s before plotting\" % str(take))\n matrix = R.subset(matrix, select=[x + 1 for x in take])\n R.assign(\"\"\"matrix\"\"\", matrix)\n headers = [headers[x] for x in take]\n if legend:\n legend = [headers[x] for x in take]\n\n if options.r_options:\n extra_options = \", %s\" % options.r_options\n else:\n extra_options = \"\"\n\n if options.legend is not None and len(legend):\n extra_options += \", legend=c('%s')\" % \"','\".join(legend)\n\n if options.labels:\n xlabel, ylabel = options.labels.split(\",\")\n extra_options += \", xlab='%s', ylab='%s'\" % (xlabel, ylabel)\n else:\n xlabel, ylabel = \"\", \"\"\n\n if options.colours:\n extra_options += \", col=colours\"\n\n if options.logscale:\n extra_options += \", log='%s'\" % options.logscale\n\n if options.xrange:\n extra_options += \", xlim=c(%f,%f)\" % tuple(\n map(float, options.xrange.split(\",\")))\n\n if options.yrange:\n extra_options += \", ylim=c(%f,%f)\" % tuple(\n map(float, options.yrange.split(\",\")))\n\n if options.hardcopy:\n if options.hardcopy.endswith(\".eps\"):\n R.postscript(options.hardcopy)\n elif options.hardcopy.endswith(\".png\"):\n R.png(options.hardcopy, width=1024, height=768, type=\"cairo\")\n elif options.hardcopy.endswith(\".jpg\"):\n R.jpg(options.hardcopy, width=1024, height=768, type=\"cairo\")\n\n for method in options.plot:\n\n if ndata < 100:\n point_size = \"1\"\n pch = \"o\"\n elif ndata < 1000:\n point_size = \"1\"\n pch = \"o\"\n else:\n point_size = \"0.5\"\n pch = \".\"\n\n if method == \"scatter\":\n R(\"\"\"plot( matrix[,1], matrix[,2], cex=%s, pch=\"o\" %s)\"\"\" % (\n point_size, extra_options))\n\n if method == \"scatter-regression\":\n R(\"\"\"plot( matrix[,1], matrix[,2], cex=%s, pch=\"o\" %s)\"\"\" % (\n point_size, extra_options))\n dat = R(\n \"\"\"dat <- data.frame(x = matrix[,1], y = matrix[,2])\"\"\")\n R(\n \"\"\"new <- data.frame(x = seq( min(matrix[,1]), max(matrix[,1]), (max(matrix[,1]) - min(matrix[,1])) / 100))\"\"\")\n mod = R(\"\"\"mod <- lm( y ~ x, dat)\"\"\")\n R(\"\"\"predict(mod, new, se.fit = TRUE)\"\"\")\n R(\"\"\"pred.w.plim <- predict(mod, new, interval=\"prediction\")\"\"\")\n R(\"\"\"pred.w.clim <- predict(mod, new, interval=\"confidence\")\"\"\")\n R(\n \"\"\"matpoints(new$x,cbind(pred.w.clim, pred.w.plim[,-1]), lty=c(1,2,2,3,3), type=\"l\")\"\"\")\n R.mtext(\n \"y = %f * x + %f, r=%6.4f, n=%i\" % (mod[\"coefficients\"][\"x\"],\n mod[\"coefficients\"][\n \"(Intercept)\"],\n R(\"\"\"cor( dat )[2]\"\"\"),\n ndata),\n 3,\n cex=1.0)\n\n elif method == \"pairs\":\n if options.add_diagonal:\n R(\n \"\"\"panel.hist <- function( x,y,... ) { points(x,y,...); abline(0,1); }\"\"\")\n else:\n R(\n \"\"\"panel.hist <- function( x,y,... ) { points(x,y,...); }\"\"\")\n\n # There used to be a argument na_action=\"na.omit\", but\n # removed this as there appeared error messages saying\n # \"na.action is not a graphical parameter\" and the\n # plots showed occasionally the wrong scale.\n # cex=point_size also caused trouble (error message:\n # \"X11 used font size 8 when 2 was requested\" or\n # similar)\n if options.colours:\n R.pairs(matrix,\n pch=pch,\n col=colours,\n main=options.title,\n panel=\"panel.hist\",\n labels=headers,\n cex_labels=2.0)\n else:\n R.pairs(matrix,\n pch=pch,\n panel=\"panel.hist\",\n main=options.title,\n labels=headers,\n cex_labels=2.0)\n\n elif method == \"boxplot\":\n extra_options += \",main='%s'\" % options.title\n\n # set vertical orientation\n if max([len(x) for x in headers]) > 40 / len(headers):\n # remove xlabel:\n extra_options = re.sub(\", xlab='[^']+'\", \"\", extra_options)\n extra_options += \", names.arg=headers, las=2\"\n R(\n \"\"\"op <- par(mar=c(11,4,4,2))\"\"\") # the 10 allows the names.arg below the barplot\n\n R(\"\"\"boxplot( matrix %s)\"\"\" % extra_options)\n\n elif method == \"bar\" or method == \"bar-stacked\":\n if not options.colours:\n extra_options += \", col=rainbow(5)\"\n\n # set vertical orientation\n if max([len(x) for x in headers]) > 40 / len(headers):\n # remove xlabel:\n extra_options = re.sub(\", xlab='[^']+'\", \"\", extra_options)\n extra_options += \", names.arg=headers, las=2\"\n R(\n \"\"\"op <- par(mar=c(11,4,4,2))\"\"\") # the 10 allows the names.arg below the barplot\n\n R(\"\"\"barplot(as.matrix(matrix), %s)\"\"\" % extra_options)\n\n elif method == \"bar-besides\":\n if not options.colours:\n extra_options += \", col=rainbow(%i)\" % ndata\n\n # set vertical orientation\n if max([len(x) for x in headers]) > 40 / len(headers):\n # remove xlabel:\n extra_options = re.sub(\", xlab='[^']+'\", \"\", extra_options)\n extra_options += \", names.arg=headers, las=2\"\n R(\n \"\"\"op <- par(mar=c(11,4,4,2))\"\"\") # the 10 allows the names.arg below the barplot\n\n R(\"\"\"barplot(as.matrix(matrix), beside=TRUE %s)\"\"\" %\n extra_options)\n\n elif method == \"scatter+marginal\":\n\n if options.title:\n # set the size of the outer margins - the title needs to be added at the end\n # after plots have been created\n R.par(oma=R.c(0, 0, 4, 0))\n\n R(\"\"\"matrix\"\"\")\n R(\"\"\"\nx <- matrix[,1];\ny <- matrix[,2];\nxhist <- hist(x, breaks=20, plot=FALSE);\nyhist <- hist(y, breaks=20, plot=FALSE);\ntop <- max(c(xhist$counts, yhist$counts));\nnf <- layout(matrix(c(2,0,1,3),2,2,byrow=TRUE), c(3,1), c(1,3), respect=TRUE );\npar(mar=c(3,3,1,1)) ;\nplot(x, y, cex=%s, pch=\"o\" %s) ;\npar(mar=c(0,3,1,1)) ;\nbarplot(xhist$counts, axes=FALSE, ylim=c(0, top), space=0 ) ;\npar(mar=c(3,0,1,1)) ;\ntitle(main='%s');\nbarplot(yhist$counts, axes=FALSE, xlim=c(0, top), space=0, horiz=TRUE ) ;\ntitle(main='%s');\n\"\"\" % (point_size, extra_options, xlabel, ylabel))\n\n if options.title:\n R.mtext(options.title, 3, outer=True, line=1, cex=1.5)\n\n elif method in (\"panel\", \"1_vs_x\", \"matched\"):\n\n if method == \"panel\":\n pairs = []\n for x in range(len(headers) - 1):\n for y in range(x + 1, len(headers)):\n pairs.append((x, y))\n\n elif method == \"1_vs_x\":\n pairs = []\n for x in range(1, len(headers)):\n pairs.append((0, x))\n\n # print matching columns\n elif method == \"matched\":\n pairs = []\n for x in range(len(headers) - 1):\n for y in range(x + 1, len(headers)):\n if headers[x] == headers[y]:\n pairs.append((x, y))\n break\n\n w = int(math.ceil(math.sqrt(len(pairs))))\n h = int(math.ceil(float(len(pairs)) / w))\n\n PosInf = 1e300000\n NegInf = -1e300000\n\n xlabel, ylabel = options.labels.split(\",\")\n\n R(\"\"\"layout(matrix(seq(1,%i), %i, %i, byrow = TRUE))\"\"\" %\n (w * h, w, h))\n for a, b in pairs:\n new_matrix = filter(lambda x:\n x[0] not in (float(\"nan\"), PosInf, NegInf) and\n x[1] not in (\n float(\"nan\"), PosInf, NegInf),\n zip(matrix[a].values()[0], matrix[b].values()[0]))\n try:\n R(\"\"\"plot(matrix[,%i], matrix[,%i], main='%s versus %s', cex=0.5, pch=\".\", xlab='%s', ylab='%s' )\"\"\" % (\n a + 1, b + 1, headers[b], headers[a], xlabel, ylabel))\n except rpy.RException, msg:\n print \"could not plot %s versus %s: %s\" % (headers[b], headers[a], msg)\n\n if options.hardcopy:\n R['dev.off']()\n\n E.info(\"matrix added as >matrix< in R.\")\n\n if not options.hardcopy:\n if options.input_filename:\n interpreter = code.InteractiveConsole(globals())\n interpreter.interact()\n else:\n E.info(\n \"can not start new interactive session as input has come from stdin.\")\n\n E.Stop()", "metadata": "root.main", "header": "['module', '___EOS___']", "index": 165 } ]
[ { "span": "argv ", "start_line": 168, "start_column": 8, "end_line": 168, "end_column": 12 }, { "span": "table ", "start_line": 273, "start_column": 4, "end_line": 273, "end_column": 9 }, { "span": "matrix2,", "start_line": 302, "start_column": 8, "end_line": 302, "end_column": 15 }, { "span": "headers2,", "start_line": 302, "start_column": 17, "end_line": 302, "end_column": 25 }, { "span": "colours2,", "start_line": 302, "start_column": 27, "end_line": 302, "end_column": 35 }, { "span": "legend2 ", "start_line": 302, "start_column": 37, "end_line": 302, "end_column": 44 } ]
[]
1
true
[ "[CLS]_", "Un", "used_", "local_", "variable_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "main_", "(_", "argv_", "=_", "None_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "argv_", "is_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "argv_", "=_", "sys_", "._", "argv_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "parser_", "=_", "E_", "._", "Optio", "n", "Parser_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "version_", "=_", "\"%", "prog", " ", "version", ":", " ", "$", "Id", ":", " ", "r", "\\u", "table", "2s", "catt", "er", ".", "py", " ", "278", "2", " ", "200", "9", "-0", "9", "-1", "0", " ", "11", ":", "40", ":", "2", "9", "Z", " ", "andr", "eas", " ", "$\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "parser_", "._", "add", "\\u", "option_", "(_", "\"-", "c", "\"_", ",_", "\"--", "column", "s", "\"_", ",_", "dest_", "=_", "\"", "column", "s", "\"_", ",_", "type_", "=_", "\"", "string", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "help_", "=_", "\"", "column", "s", " ", "to", " ", "take", " ", "from", " ", "table", ".", " ", "Choi", "ces", " ", "are", " ", "'", "all", "',", " ", "'", "all", "-", "but", "-", "first", "'", " ", "or", " ", "a", " ", "','", "-", "separate", "d", " ", "list", " ", "of", " ", "column", "s", ".\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "parser_", "._", "add", "\\u", "option_", "(_", "\"--", "logs", "cale", "\"_", ",_", "dest_", "=_", "\"", "logs", "cale", "\"_", ",_", "type_", "=_", "\"", "string", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "help_", "=_", "\"", "log", "-", "transform", " ", "one", " ", "or", " ", "bot", "h", " ", "axes", " ", "[", "default", "=", "%", "Default", "].", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "parser_", "._", "add", "\\u", "option_", "(_", "\"-", "a", "\"_", ",_", "\"--", "hard", "copy", "\"_", ",_", "dest_", "=_", "\"", "hard", "copy", "\"_", ",_", "type_", "=_", "\"", "string", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "help_", "=_", "\"", "write", " ", "hard", "copy", " ", "to", " ", "file", " ", "[", "default", "=", "%", "default", "].", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "metavar_", "=_", "\"", "FILE", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "parser_", "._", "add", "\\u", "option_", "(_", "\"-", "f", "\"_", ",_", "\"--", "file", "\"_", ",_", "dest_", "=_", "\"", "input", "\\u", "filename", "\"_", ",_", "type_", "=_", "\"", "string", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "help_", "=_", "\"", "filename", " ", "with", " ", "table", " ", "data", " ", "[", "default", "=", "%", "default", "].", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "metavar_", "=_", "\"", "FILE", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "parser_", "._", "add", "\\u", "option_", "(_", "\"-", "2", "\"_", ",_", "\"--", "file", "2", "\"_", ",_", "dest_", "=_", "\"", "input", "\\u", "filename", "2", "\"_", ",_", "type_", "=_", "\"", "string", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "help_", "=_", "\"", "addition", "al", " ", "data", " ", "file", " ", "[", "default", "=", "%", "default", "].", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "metavar_", "=_", "\"", "FILE", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "parser_", "._", "add", "\\u", "option_", "(_", "\"-", "s", "\"_", ",_", "\"--", "stats", "\"_", ",_", "dest_", "=_", "\"", "statistic", "s", "\"_", ",_", "type_", "=_", "\"", "choice", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "choices_", "=_", "(_", "\"", "correlation", "\"_", ",_", "\"", "spear", "man", "\"_", ",_", "\"", "pearson", "\"_", ",_", "\"", "count", "\"_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "help_", "=_", "\"", "statistic", "al", " ", "quantities", " ", "to", " ", "compute", " ", "[", "default", "=", "%", "default", "]\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "action_", "=_", "\"", "append", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "parser_", "._", "add", "\\u", "option_", "(_", "\"-", "p", "\"_", ",_", "\"--", "plot", "\"_", ",_", "dest_", "=_", "\"", "plot", "\"_", ",_", "type_", "=_", "\"", "choice", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "choices_", "=_", "(_", "\"", "scatter", "\"_", ",_", "\"", "pair", "s", "\"_", ",_", "\"", "panel", "\"_", ",_", "\"", "bar", "\"_", ",_", "\"", "bar", "-", "stacked", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "bar", "-", "bes", "ides", "\"_", ",_", "\"", "1", "\\u", "vs", "\\u", "x", "\"_", ",_", "\"", "matche", "d", "\"_", ",_", "\"", "box", "plot", "\"_", ",_", "\"", "scatter", "+", "marginal", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "scatter", "-", "regress", "ion", "\"_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "help_", "=_", "\"", "plots", " ", "to", " ", "plot", " ", "[", "default", "=", "%", "default", "]\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "action_", "=_", "\"", "append", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "parser_", "._", "add", "\\u", "option_", "(_", "\"-", "t", "\"_", ",_", "\"--", "threshol", "d", "\"_", ",_", "dest_", "=_", "\"", "threshol", "d", "\"_", ",_", "type_", "=_", "\"", "float", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "help_", "=_", "\"", "min", " ", "threshol", "d", " ", "to", " ", "use", " ", "for", " ", "counti", "ng", " ", "method", " ", "[", "default", "=", "%", "default", "].", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "parser_", "._", "add", "\\u", "option_", "(_", "\"-", "o", "\"_", ",_", "\"--", "colour", "s", "\"_", ",_", "dest_", "=_", "\"", "colour", "s", "\"_", ",_", "type_", "=_", "\"", "int", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "help_", "=_", "\"", "column", " ", "with", " ", "colour", " ", "informati", "on", " ", "[", "default", "=", "%", "default", "].", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "parser_", "._", "add", "\\u", "option_", "(_", "\"-", "l", "\"_", ",_", "\"--", "plot", "-", "labels", "\"_", ",_", "dest_", "=_", "\"", "labels", "\"_", ",_", "type_", "=_", "\"", "string", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "help_", "=_", "\"", "column", " ", "labels", " ", "for", " ", "x", " ", "and", " ", "y", " ", "in", " ", "matche", "d", " ", "plots", " ", "[", "default", "=", "%", "default", "].", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "parser_", "._", "add", "\\u", "option_", "(_", "\"-", "d", "\"_", ",_", "\"--", "add", "-", "diagonal", "\"_", ",_", "dest_", "=_", "\"", "add", "\\u", "diagonal", "\"_", ",_", "action_", "=_", "\"", "store", "\\u", "true", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "help_", "=_", "\"", "add", " ", "diagonal", " ", "to", " ", "plot", " ", "[", "default", "=", "%", "default", "].", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "parser_", "._", "add", "\\u", "option_", "(_", "\"-", "e", "\"_", ",_", "\"--", "plot", "-", "legend", "\"_", ",_", "dest_", "=_", "\"", "legend", "\"_", ",_", "type_", "=_", "\"", "int", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "help_", "=_", "\"", "column", " ", "with", " ", "legend", " ", "[", "default", "=", "%", "default", "].", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "parser_", "._", "add", "\\u", "option_", "(_", "\"-", "r", "\"_", ",_", "\"--", "options", "\"_", ",_", "dest_", "=_", "\"", "r", "\\u", "options", "\"_", ",_", "type_", "=_", "\"", "string", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "help_", "=_", "\"", "R", " ", "plott", "ing", " ", "options", " ", "[", "default", "=", "%", "default", "].", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "parser_", "._", "add", "\\u", "option_", "(_", "\"--", "format", "\"_", ",_", "dest_", "=_", "\"", "format", "\"_", ",_", "type_", "=_", "\"", "choice", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "choices_", "=_", "(_", "\"", "full", "\"_", ",_", "\"", "spars", "e", "\"_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "help_", "=_", "\"", "output", " ", "format", " ", "[", "default", "=", "%", "default", "].", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "parser_", "._", "add", "\\u", "option_", "(_", "\"--", "title", "\"_", ",_", "dest_", "=_", "\"", "title", "\"_", ",_", "type_", "=_", "\"", "string", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "help_", "=_", "\"\"\"", "plot", " ", "title", " ", "[", "default", "=", "%", "default", "].", "\"\"\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "parser_", "._", "add", "\\u", "option_", "(_", "\"\"_", ",_", "\"--", "xran", "ge", "\"_", ",_", "dest_", "=_", "\"", "xran", "ge", "\"_", ",_", "type_", "=_", "\"", "string", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "help_", "=_", "\"", "x", " ", "viewin", "g", " ", "range", " ", "of", " ", "plot", " ", "[", "default", "=", "%", "default", "].", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "parser_", "._", "add", "\\u", "option_", "(_", "\"\"_", ",_", "\"--", "yra", "nge", "\"_", ",_", "dest_", "=_", "\"", "yra", "nge", "\"_", ",_", "type_", "=_", "\"", "string", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "help_", "=_", "\"", "y", " ", "viewin", "g", " ", "range", " ", "of", " ", "plot", "[", "default", "=", "%", "default", "].", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "parser_", "._", "add", "\\u", "option_", "(_", "\"--", "allow", "-", "empty", "-", "file", "\"_", ",_", "dest_", "=_", "\"", "fail", "\\u", "on", "\\u", "empty", "\"_", ",_", "action_", "=_", "\"", "store", "\\u", "fal", "se", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "help_", "=_", "\"", "do", " ", "not", " ", "fail", " ", "on", " ", "empty", " ", "input", " ", "[", "default", "=", "%", "default", "].", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "parser_", "._", "add", "\\u", "option_", "(_", "\"--", "fail", "-", "on", "-", "empty", "\"_", ",_", "dest_", "=_", "\"", "fail", "\\u", "on", "\\u", "empty", "\"_", ",_", "action_", "=_", "\"", "store", "\\u", "true", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "help_", "=_", "\"", "fail", " ", "on", " ", "empty", " ", "input", " ", "[", "default", "=", "%", "default", "].", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "parser_", "._", "set\\u", "defaults_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "hard", "copy_", "=_", "None_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "input", "\\u", "filename_", "=_", "\"\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "input", "\\u", "filename", "2_", "=_", "None_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "columns_", "=_", "\"", "all", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "logs", "cale_", "=_", "None_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "statistics_", "=_", "[_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "plot_", "=_", "[_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "threshold_", "=_", "0.0_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "labels_", "=_", "\"", "x", ",", "y", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "colours_", "=_", "None_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "diagonal_", "=_", "False_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "legend_", "=_", "None_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "title_", "=_", "None_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "xrange_", "=_", "None_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "yra", "nge_", "=_", "None_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "r", "\\u", "options_", "=_", "\"\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "fail", "\\u", "on", "\\u", "empty_", "=_", "True_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "format_", "=_", "\"", "full", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "options_", ",_", "args_", ")_", "=_", "E_", "._", "Start_", "(_", "parser_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "len_", "(_", "args_", ")_", "==_", "1_", "and_", "not_", "options_", "._", "input", "\\u", "filename_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "options_", "._", "input", "\\u", "filename_", "=_", "args_", "[_", "0_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "options_", "._", "columns_", "not_", "in_", "(_", "\"", "all", "\"_", ",_", "\"", "all", "-", "but", "-", "first", "\"_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "options_", "._", "columns_", "=_", "map_", "(_", "lambda_", "x_", ":_", "int_", "(_", "x_", ")_", "-_", "1_", ",_", "options_", "._", "columns_", "._", "split_", "(_", "\",\"_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "options_", "._", "colours_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "options_", "._", "colours_", "-=_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "options_", "._", "legend_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "options_", "._", "legend_", "-=_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "table_", "=_", "{_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "headers_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "read", " ", "data", " ", "matrix_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "options_", "._", "input", "\\u", "filename_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "lines_", "=_", "open_", "(_", "options_", "._", "input", "\\u", "filename_", ",_", "\"", "r", "\"_", ")_", "._", "readlines_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "note", ":", " ", "this", " ", "will", " ", "not", " ", "work", " ", "for", " ", "interactive", " ", "viewin", "g", ",", " ", "but", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "creati", "ng", " ", "hard", "copy", " ", "plots", " ", "works", "._", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "lines_", "=_", "sys_", "._", "stdin_", "._", "readlines_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "lines_", "=_", "filter_", "(_", "lambda_", "x_", ":_", "x_", "[_", "0_", "]_", "!=_", "\"#\"_", ",_", "lines_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "len_", "(_", "lines_", ")_", "==_", "0_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "options_", "._", "fail", "\\u", "on", "\\u", "empty_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "raise_", "IO", "Error_", "(_", "\"", "no", " ", "input", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "E_", "._", "warn_", "(_", "\"", "empty", " ", "input", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "E_", "._", "Stop_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "matrix_", ",_", "headers_", ",_", "colours_", ",_", "legend_", "=_", "read", "Table_", "(_", "lines_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "matrix", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "take", "\\u", "columns_", "=_", "options_", "._", "columns_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "headers_", "=_", "True_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "colours_", "=_", "options_", "._", "colours_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "row", "\\u", "names_", "=_", "options_", "._", "legend_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "options_", "._", "input", "\\u", "filename", "2_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "read", " ", "anot", "her", " ", "matrix", " ", "(", "shou", "ld", " ", "be", " ", "of", " ", "the", " ", "same", " ", "format", "._", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "matrix", "2_", ",_", "header", "s2_", ",_", "colour", "s2_", ",_", "legend", "2_", "=_", "read", "Table_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "lines_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "matrix", "2", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "take", "\\u", "columns_", "=_", "options_", "._", "columns_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "headers_", "=_", "True_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "colours_", "=_", "options_", "._", "colours_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "row", "\\u", "names_", "=_", "options_", "._", "legend_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "R_", "._", "assign_", "(_", "\"", "header", "s", "\"_", ",_", "headers_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "ndata", "_", "=_", "R_", "(_", "\"\"\"", "length", "(", " ", "matrix", "[", ",", "1", "]", " ", ")\"\"\"_", ")_", "[_", "0_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "options_", "._", "loglevel_", ">=_", "1_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "options_", "._", "std", "log_", "._", "write_", "(_", "\"#", " ", "read", " ", "matrix", ":", " ", "%", "ix", "%", "i", "\\\\", "n", "\"_", "%_", "(_", "len_", "(_", "headers_", ")_", ",_", "ndata", "_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "colours_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "R_", "._", "assign_", "(_", "\"", "colour", "s", "\"_", ",_", "colours_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "for_", "method_", "in_", "options_", "._", "statistics_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "method_", "==_", "\"", "correlation", "\"_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "cor_", "=_", "R_", "._", "cor_", "(_", "matrix_", ",_", "use_", "=_", "\"", "pairwise", ".", "complete", ".", "obs", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "write", "Matrix_", "(_", "sys_", "._", "stdout_", ",_", "cor_", ",_", "headers_", "=_", "headers_", ",_", "format_", "=_", "\"%", "5.2", "f", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "method_", "==_", "\"", "pearson", "\"_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "options_", "._", "stdout_", "._", "write_", "(_", "\"\\\\", "t", "\"_", "._", "join_", "(_", "(_", "\"", "var", "1", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "var", "2", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "coef", "f", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "pass", "ed", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "pvalue", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "n", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "method", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "alternative", "\"_", ")_", ")_", "+_", "\"\\\\", "n", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "x_", "in_", "range_", "(_", "len_", "(_", "headers_", ")_", "-_", "1_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "for_", "y_", "in_", "range_", "(_", "x_", "+_", "1_", ",_", "len_", "(_", "headers_", ")_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "result_", "=_", "R_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "\"\"\"", "cor", ".", "test", "(", " ", "matrix", "[", ",%", "i", "],", " ", "matrix", "[", ",%", "i", "]", " ", ")\"\"\"_", "%_", "(_", "x_", "+_", "1_", ",_", "y_", "+_", "1_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "rpy", "_", "._", "RP", "y", "Exception_", ",_", "msg_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "E_", "._", "warn_", "(_", "\"", "correlation", " ", "not", " ", "compute", "d", " ", "for", " ", "column", "s", " ", "%", "i", "(%", "s", ")", " ", "and", " ", "%", "i", "(%", "s", "):", " ", "%", "s", "\"_", "%_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "x_", ",_", "headers_", "[_", "x_", "]_", ",_", "y_", ",_", "headers_", "[_", "y_", "]_", ",_", "msg_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "options_", "._", "stdout_", "._", "write_", "(_", "\"%", "s", "\\\\", "t", "%", "s", "\\\\", "t", "%", "s", "\\\\", "t", "%", "s", "\\\\", "t", "%", "s", "\\\\", "t", "%", "i", "\\\\", "t", "%", "s", "\\\\", "t", "%", "s", "\\\\", "n", "\"_", "%_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "headers_", "[_", "x_", "]_", ",_", "headers_", "[_", "y_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "na", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "na", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "na", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "0_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "na", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "na", "\"_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "options_", "._", "stdout_", "._", "write_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "\"%", "s", "\\\\", "t", "%", "s", "\\\\", "t", "%", "6.4", "f", "\\\\", "t", "%", "s", "\\\\", "t", "%", "e", "\\\\", "t", "%", "i", "\\\\", "t", "%", "s", "\\\\", "t", "%", "s", "\\\\", "n", "\"_", "%_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "headers_", "[_", "x_", "]_", ",_", "headers_", "[_", "y_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "result_", "._", "rx", "2_", "(_", "'", "estimate", "'_", ")_", "._", "rx", "2_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "'", "cor", "'_", ")_", "[_", "0_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "Stats_", "._", "get", "Sign", "ifica", "nce_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "float_", "(_", "result_", "._", "rx", "2_", "(_", "'", "p", ".", "value", "'_", ")_", "[_", "0_", "]_", ")_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "result_", "._", "rx", "2_", "(_", "'", "p", ".", "value", "'_", ")_", "[_", "0_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "result_", "._", "rx", "2_", "(_", "'", "parameter", "'_", ")_", "._", "rx", "2_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "'", "df", "'_", ")_", "[_", "0_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "result_", "._", "rx", "2_", "(_", "'", "method", "'_", ")_", "[_", "0_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "result_", "._", "rx", "2_", "(_", "'", "alternative", "'_", ")_", "[_", "0_", "]_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "method_", "==_", "\"", "spear", "man", "\"_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "options_", "._", "stdout_", "._", "write_", "(_", "\"\\\\", "t", "\"_", "._", "join_", "(_", "(_", "\"", "var", "1", "\"_", ",_", "\"", "var", "2", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "coef", "f", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "pass", "ed", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "pvalue", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "method", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "alternative", "\"_", ")_", ")_", "+_", "\"\\\\", "n", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "x_", "in_", "range_", "(_", "len_", "(_", "headers_", ")_", "-_", "1_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "for_", "y_", "in_", "range_", "(_", "x_", "+_", "1_", ",_", "len_", "(_", "headers_", ")_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "result_", "=_", "R_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "\"\"\"", "cor", ".", "test", "(", " ", "matrix", "[", ",%", "i", "],", " ", "matrix", "[", ",%", "i", "],", " ", "method", "='", "spear", "man", "')", "\"\"\"_", "%_", "(_", "x_", "+_", "1_", ",_", "y_", "+_", "1_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "options_", "._", "stdout_", "._", "write_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "\"%", "s", "\\\\", "t", "%", "s", "\\\\", "t", "%", "6.4", "f", "\\\\", "t", "%", "s", "\\\\", "t", "%", "e", "\\\\", "t", "%", "i", "\\\\", "t", "%", "s", "\\\\", "t", "%", "s", "\\\\", "n", "\"_", "%_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "headers_", "[_", "x_", "]_", ",_", "headers_", "[_", "y_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "result_", "[_", "'", "estimate", "'_", "]_", "[_", "'", "rho", "'_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "Stats_", "._", "get", "Sign", "ifica", "nce_", "(_", "float_", "(_", "result_", "[_", "'", "p", ".", "value", "'_", "]_", ")_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "result_", "[_", "'", "p", ".", "value", "'_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "result_", "[_", "'", "parameter", "'_", "]_", "[_", "'", "df", "'_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "result_", "[_", "'", "method", "'_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "result_", "[_", "'", "alternative", "'_", "]_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "method_", "==_", "\"", "count", "\"_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "number", " ", "of", " ", "shared", " ", "element", "s", " ", ">", " ", "threshold_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "m_", ",_", "r_", ",_", "c_", "=_", "Mat", "lab", "Tools_", "._", "Read", "Matrix_", "(_", "open_", "(_", "options_", "._", "input", "\\u", "filename_", ",_", "\"", "r", "\"_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "take_", "=_", "options_", "._", "columns_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "headers_", "=_", "True_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "mask_", "=_", "numpy_", "._", "greater_", "(_", "m_", ",_", "options_", "._", "threshold_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "counts_", "=_", "numpy_", "._", "dot_", "(_", "numpy_", "._", "transpose_", "(_", "mask_", ")_", ",_", "mask_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "write", "Matrix_", "(_", "options_", "._", "stdout_", ",_", "counts_", ",_", "headers_", "=_", "c_", ",_", "format_", "=_", "\"%", "i", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "options_", "._", "plot_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "remove", " ", "column", "s", " ", "tha", "t", " ", "are", " ", "complete", "ly", " ", "empty_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "\"", "pair", "s", "\"_", "in_", "options_", "._", "plot_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "cols", "ums_", "=_", "R_", "(_", "'''", "col", "Sum", "s", "(", " ", "is", ".", "na", "(", "matrix", " ", "))", "'''_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "take_", "=_", "[_", "x_", "for_", "x_", "in_", "range_", "(_", "len_", "(_", "cols", "ums_", ")_", ")_", "if_", "cols", "ums_", "[_", "x_", "]_", "!=_", "ndata", "_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "take_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "E_", "._", "warn_", "(_", "\"", "remo", "ving", " ", "empty", " ", "column", "s", " ", "%", "s", " ", "bef", "ore", " ", "plott", "ing", "\"_", "%_", "str_", "(_", "take_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "matrix_", "=_", "R_", "._", "subset_", "(_", "matrix_", ",_", "select_", "=_", "[_", "x_", "+_", "1_", "for_", "x_", "in_", "take_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "R_", "._", "assign_", "(_", "\"\"\"", "matrix", "\"\"\"_", ",_", "matrix_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "headers_", "=_", "[_", "headers_", "[_", "x_", "]_", "for_", "x_", "in_", "take_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "legend_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "legend_", "=_", "[_", "headers_", "[_", "x_", "]_", "for_", "x_", "in_", "take_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "options_", "._", "r", "\\u", "options_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "extra", "\\u", "options_", "=_", "\",", " ", "%", "s", "\"_", "%_", "options_", "._", "r", "\\u", "options_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "extra", "\\u", "options_", "=_", "\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "options_", "._", "legend_", "is_", "not_", "None_", "and_", "len_", "(_", "legend_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "extra", "\\u", "options_", "+=_", "\",", " ", "legend", "=", "c", "('", "%", "s", "')\"_", "%_", "\"',", "'\"_", "._", "join_", "(_", "legend_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "options_", "._", "labels_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "xlabel_", ",_", "ylabel_", "=_", "options_", "._", "labels_", "._", "split_", "(_", "\",\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "extra", "\\u", "options_", "+=_", "\",", " ", "xla", "b", "='", "%", "s", "',", " ", "yla", "b", "='", "%", "s", "'\"_", "%_", "(_", "xlabel_", ",_", "ylabel_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "xlabel_", ",_", "ylabel_", "=_", "\"\"_", ",_", "\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "options_", "._", "colours_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "extra", "\\u", "options_", "+=_", "\",", " ", "col", "=", "colour", "s", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "options_", "._", "logs", "cale_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "extra", "\\u", "options_", "+=_", "\",", " ", "log", "='", "%", "s", "'\"_", "%_", "options_", "._", "logs", "cale_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "options_", "._", "xrange_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "extra", "\\u", "options_", "+=_", "\",", " ", "xlim", "=", "c", "(%", "f", ",%", "f", ")\"_", "%_", "tuple_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "map_", "(_", "float_", ",_", "options_", "._", "xrange_", "._", "split_", "(_", "\",\"_", ")_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "options_", "._", "yra", "nge_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "extra", "\\u", "options_", "+=_", "\",", " ", "ylim", "=", "c", "(%", "f", ",%", "f", ")\"_", "%_", "tuple_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "map_", "(_", "float_", ",_", "options_", "._", "yra", "nge_", "._", "split_", "(_", "\",\"_", ")_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "options_", "._", "hard", "copy_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "options_", "._", "hard", "copy_", "._", "endswith_", "(_", "\".", "eps", "\"_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "R_", "._", "posts", "cript_", "(_", "options_", "._", "hard", "copy_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "options_", "._", "hard", "copy_", "._", "endswith_", "(_", "\".", "png", "\"_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "R_", "._", "png_", "(_", "options_", "._", "hard", "copy_", ",_", "width_", "=_", "1024_", ",_", "height_", "=_", "768_", ",_", "type_", "=_", "\"", "cairo", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "options_", "._", "hard", "copy_", "._", "endswith_", "(_", "\".", "jp", "g", "\"_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "R_", "._", "jp", "g_", "(_", "options_", "._", "hard", "copy_", ",_", "width_", "=_", "1024_", ",_", "height_", "=_", "768_", ",_", "type_", "=_", "\"", "cairo", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "for_", "method_", "in_", "options_", "._", "plot_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "ndata", "_", "<_", "100_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "point", "\\u", "size_", "=_", "\"", "1", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "pch", "_", "=_", "\"", "o", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "ndata", "_", "<_", "1000_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "point", "\\u", "size_", "=_", "\"", "1", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "pch", "_", "=_", "\"", "o", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "point", "\\u", "size_", "=_", "\"", "0.", "5", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "pch", "_", "=_", "\".\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "method_", "==_", "\"", "scatter", "\"_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "R_", "(_", "\"\"\"", "plot", "(", " ", "matrix", "[", ",", "1", "],", " ", "matrix", "[", ",", "2", "],", " ", "ce", "x", "=", "%", "s", ",", " ", "pch", "=\"", "o", "\"", " ", "%", "s", ")\"\"\"_", "%_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "point", "\\u", "size_", ",_", "extra", "\\u", "options_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "method_", "==_", "\"", "scatter", "-", "regress", "ion", "\"_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "R_", "(_", "\"\"\"", "plot", "(", " ", "matrix", "[", ",", "1", "],", " ", "matrix", "[", ",", "2", "],", " ", "ce", "x", "=", "%", "s", ",", " ", "pch", "=\"", "o", "\"", " ", "%", "s", ")\"\"\"_", "%_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "point", "\\u", "size_", ",_", "extra", "\\u", "options_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "dat_", "=_", "R_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "\"\"\"", "dat", " ", "<-", " ", "data", ".", "frame", "(", "x", " ", "=", " ", "matrix", "[", ",", "1", "],", " ", "y", " ", "=", " ", "matrix", "[", ",", "2", "])", "\"\"\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "R_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "\"\"\"", "new", " ", "<-", " ", "data", ".", "frame", "(", "x", " ", "=", " ", "seq", "(", " ", "min", "(", "matrix", "[", ",", "1", "])", ",", " ", "max", "(", "matrix", "[", ",", "1", "])", ",", " ", "(", "max", "(", "matrix", "[", ",", "1", "])", " ", "-", " ", "min", "(", "matrix", "[", ",", "1", "]))", " ", "/", " ", "100", "))", "\"\"\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "mod_", "=_", "R_", "(_", "\"\"\"", "mod", " ", "<-", " ", "lm", "(", " ", "y", " ", "~", " ", "x", ",", " ", "dat", ")\"\"\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "R_", "(_", "\"\"\"", "predi", "ct", "(", "mod", ",", " ", "new", ",", " ", "se", ".", "fit", " ", "=", " ", "TRU", "E", ")\"\"\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "R_", "(_", "\"\"\"", "pred", ".", "w", ".", "pli", "m", " ", "<-", " ", "predi", "ct", "(", "mod", ",", " ", "new", ",", " ", "interval", "=\"", "predicti", "on", "\")", "\"\"\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "R_", "(_", "\"\"\"", "pred", ".", "w", ".", "clim", " ", "<-", " ", "predi", "ct", "(", "mod", ",", " ", "new", ",", " ", "interval", "=\"", "confidence", "\")", "\"\"\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "R_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "\"\"\"", "mat", "points", "(", "new", "$", "x", ",", "cb", "ind", "(", "pred", ".", "w", ".", "clim", ",", " ", "pred", ".", "w", ".", "pli", "m", "[", ",-", "1", "])", ",", " ", "lty", "=", "c", "(", "1", ",", "2", ",", "2", ",", "3", ",", "3", "),", " ", "type", "=\"", "l", "\")", "\"\"\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "R_", "._", "mte", "xt_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "y", " ", "=", " ", "%", "f", " ", "*", " ", "x", " ", "+", " ", "%", "f", ",", " ", "r", "=", "%", "6.4", "f", ",", " ", "n", "=", "%", "i", "\"_", "%_", "(_", "mod_", "[_", "\"", "coefficient", "s", "\"_", "]_", "[_", "\"", "x", "\"_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "mod_", "[_", "\"", "coefficient", "s", "\"_", "]_", "[_", "\\u\\u\\uNL\\u\\u\\u_", "\"(", "Interc", "ept", ")\"_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "R_", "(_", "\"\"\"", "cor", "(", " ", "dat", " ", ")[", "2", "]\"", "\"\"_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "ndata", "_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "3_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "ce", "x_", "=_", "1.0_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "method_", "==_", "\"", "pair", "s", "\"_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "options_", "._", "add", "\\u", "diagonal_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "R_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "\"\"\"", "panel", ".", "hist", " ", "<-", " ", "function", "(", " ", "x", ",", "y", ",...", " ", " ", ")", " ", "{", " ", "points", "(", "x", ",", "y", ",...", ");", " ", "abl", "ine", "(", "0", ",", "1", ");", " ", "}\"\"\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "R_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "\"\"\"", "panel", ".", "hist", " ", "<-", " ", "function", "(", " ", "x", ",", "y", ",...", " ", " ", ")", " ", "{", " ", "points", "(", "x", ",", "y", ",...", ");", " ", "}\"\"\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "There", " ", "used", " ", "to", " ", "be", " ", "a", " ", "argu", "ment", " ", "na", "\\u", "action", "=\"", "na", ".", "omit", "\",", " ", "but", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "remove", "d", " ", "this", " ", "as", " ", "there", " ", "appear", "ed", " ", "error", " ", "message", "s", " ", "say", "ing_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "\"", "na", ".", "action", " ", "is", " ", "not", " ", "a", " ", "graphical", " ", "parameter", "\"", " ", "and", " ", "the_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "plots", " ", "show", "ed", " ", "occ", "asi", "onal", "ly", " ", "the", " ", "wrong", " ", "scale", "._", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "ce", "x", "=", "point", "\\u", "size", " ", "als", "o", " ", "caus", "ed", " ", "trouble", " ", "(", "error", " ", "message", ":_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "\"", "X1", "1", " ", "used", " ", "font", " ", "size", " ", "8", " ", "whe", "n", " ", "2", " ", "was", " ", "request", "ed", "\"", " ", "or_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "similar", ")_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "options_", "._", "colours_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "R_", "._", "pairs_", "(_", "matrix_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "pch", "_", "=_", "pch", "_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "col_", "=_", "colours_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "main_", "=_", "options_", "._", "title_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "panel_", "=_", "\"", "panel", ".", "hist", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "labels_", "=_", "headers_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "ce", "x", "\\u", "labels_", "=_", "2.0_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "R_", "._", "pairs_", "(_", "matrix_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "pch", "_", "=_", "pch", "_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "panel_", "=_", "\"", "panel", ".", "hist", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "main_", "=_", "options_", "._", "title_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "labels_", "=_", "headers_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "ce", "x", "\\u", "labels_", "=_", "2.0_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "method_", "==_", "\"", "box", "plot", "\"_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "extra", "\\u", "options_", "+=_", "\",", "main", "='", "%", "s", "'\"_", "%_", "options_", "._", "title_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "set", " ", "vertical", " ", "orientation_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "max_", "(_", "[_", "len_", "(_", "x_", ")_", "for_", "x_", "in_", "headers_", "]_", ")_", ">_", "40_", "/_", "len_", "(_", "headers_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "remove", " ", "xlabel", ":_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "extra", "\\u", "options_", "=_", "re_", "._", "sub_", "(_", "\",", " ", "xla", "b", "='", "[", "^", "']", "+'\"", "_", ",_", "\"\"_", ",_", "extra", "\\u", "options_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "extra", "\\u", "options_", "+=_", "\",", " ", "names", ".", "arg", "=", "header", "s", ",", " ", "las", "=", "2", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "R_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "\"\"\"", "op", " ", "<-", " ", "par", "(", "mar", "=", "c", "(", "11", ",", "4", ",", "4", ",", "2", "))", "\"\"\"_", ")_", "#", " ", "the", " ", "10", " ", "allow", "s", " ", "the", " ", "names", ".", "arg", " ", "belo", "w", " ", "the", " ", "bar", "plot_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "R_", "(_", "\"\"\"", "box", "plot", "(", " ", "matrix", " ", "%", "s", ")\"\"\"_", "%_", "extra", "\\u", "options_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "method_", "==_", "\"", "bar", "\"_", "or_", "method_", "==_", "\"", "bar", "-", "stacked", "\"_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "not_", "options_", "._", "colours_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "extra", "\\u", "options_", "+=_", "\",", " ", "col", "=", "rain", "bow", "(", "5", ")\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "set", " ", "vertical", " ", "orientation_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "max_", "(_", "[_", "len_", "(_", "x_", ")_", "for_", "x_", "in_", "headers_", "]_", ")_", ">_", "40_", "/_", "len_", "(_", "headers_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "remove", " ", "xlabel", ":_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "extra", "\\u", "options_", "=_", "re_", "._", "sub_", "(_", "\",", " ", "xla", "b", "='", "[", "^", "']", "+'\"", "_", ",_", "\"\"_", ",_", "extra", "\\u", "options_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "extra", "\\u", "options_", "+=_", "\",", " ", "names", ".", "arg", "=", "header", "s", ",", " ", "las", "=", "2", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "R_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "\"\"\"", "op", " ", "<-", " ", "par", "(", "mar", "=", "c", "(", "11", ",", "4", ",", "4", ",", "2", "))", "\"\"\"_", ")_", "#", " ", "the", " ", "10", " ", "allow", "s", " ", "the", " ", "names", ".", "arg", " ", "belo", "w", " ", "the", " ", "bar", "plot_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "R_", "(_", "\"\"\"", "bar", "plot", "(", "as", ".", "matrix", "(", "matrix", "),", " ", "%", "s", ")\"\"\"_", "%_", "extra", "\\u", "options_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "method_", "==_", "\"", "bar", "-", "bes", "ides", "\"_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "not_", "options_", "._", "colours_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "extra", "\\u", "options_", "+=_", "\",", " ", "col", "=", "rain", "bow", "(%", "i", ")\"_", "%_", "ndata", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "set", " ", "vertical", " ", "orientation_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "max_", "(_", "[_", "len_", "(_", "x_", ")_", "for_", "x_", "in_", "headers_", "]_", ")_", ">_", "40_", "/_", "len_", "(_", "headers_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "remove", " ", "xlabel", ":_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "extra", "\\u", "options_", "=_", "re_", "._", "sub_", "(_", "\",", " ", "xla", "b", "='", "[", "^", "']", "+'\"", "_", ",_", "\"\"_", ",_", "extra", "\\u", "options_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "extra", "\\u", "options_", "+=_", "\",", " ", "names", ".", "arg", "=", "header", "s", ",", " ", "las", "=", "2", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "R_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "\"\"\"", "op", " ", "<-", " ", "par", "(", "mar", "=", "c", "(", "11", ",", "4", ",", "4", ",", "2", "))", "\"\"\"_", ")_", "#", " ", "the", " ", "10", " ", "allow", "s", " ", "the", " ", "names", ".", "arg", " ", "belo", "w", " ", "the", " ", "bar", "plot_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "R_", "(_", "\"\"\"", "bar", "plot", "(", "as", ".", "matrix", "(", "matrix", "),", " ", "bes", "ide", "=", "TRU", "E", " ", "%", "s", ")\"\"\"_", "%_", "\\u\\u\\uNL\\u\\u\\u_", "extra", "\\u", "options_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "method_", "==_", "\"", "scatter", "+", "marginal", "\"_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "options_", "._", "title_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "set", " ", "the", " ", "size", " ", "of", " ", "the", " ", "outer", " ", "margins", " ", "-", " ", "the", " ", "title", " ", "need", "s", " ", "to", " ", "be", " ", "adde", "d", " ", "at", " ", "the", " ", "end_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "after", " ", "plots", " ", "have", " ", "bee", "n", " ", "created_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "R_", "._", "par_", "(_", "oma", "_", "=_", "R_", "._", "c_", "(_", "0_", ",_", "0_", ",_", "4_", ",_", "0_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "R_", "(_", "\"\"\"", "matrix", "\"\"\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "R_", "(_", "\"\"\"", "\\", "10", ";", "x", " ", "<-", " ", "matrix", "[", ",", "1", "];", "\\", "10", ";", "y", " ", "<-", " ", "matrix", "[", ",", "2", "];", "\\", "10", ";", "xh", "ist", " ", "<-", " ", "hist", "(", "x", ",", " ", "breaks", "=", "20", ",", " ", "plot", "=", "FAL", "SE", ");", "\\", "10", ";", "yh", "ist", " ", "<-", " ", "hist", "(", "y", ",", " ", "breaks", "=", "20", ",", " ", "plot", "=", "FAL", "SE", ");", "\\", "10", ";", "top", " ", "<-", " ", "max", "(", "c", "(", "xh", "ist", "$", "count", "s", ",", " ", "yh", "ist", "$", "count", "s", "))", ";", "\\", "10", ";", "nf", " ", "<-", " ", "layout", "(", "matrix", "(", "c", "(", "2", ",", "0", ",", "1", ",", "3", "),", "2", ",", "2", ",", "by", "row", "=", "TRU", "E", "),", " ", "c", "(", "3", ",", "1", "),", " ", "c", "(", "1", ",", "3", "),", " ", "respec", "t", "=", "TRU", "E", " ", ");", "\\", "10", ";", "par", "(", "mar", "=", "c", "(", "3", ",", "3", ",", "1", ",", "1", "))", " ", ";", "\\", "10", ";", "plot", "(", "x", ",", " ", "y", ",", " ", "ce", "x", "=", "%", "s", ",", " ", "pch", "=\"", "o", "\"", " ", "%", "s", ")", " ", ";", "\\", "10", ";", "par", "(", "mar", "=", "c", "(", "0", ",", "3", ",", "1", ",", "1", "))", " ", ";", "\\", "10", ";", "bar", "plot", "(", "xh", "ist", "$", "count", "s", ",", " ", "axes", "=", "FAL", "SE", ",", " ", "ylim", "=", "c", "(", "0", ",", " ", "top", "),", " ", "space", "=", "0", " ", ")", " ", ";", "\\", "10", ";", "par", "(", "mar", "=", "c", "(", "3", ",", "0", ",", "1", ",", "1", "))", " ", ";", "\\", "10", ";", "title", "(", "main", "='", "%", "s", "');", "\\", "10", ";", "bar", "plot", "(", "yh", "ist", "$", "count", "s", ",", " ", "axes", "=", "FAL", "SE", ",", " ", "xlim", "=", "c", "(", "0", ",", " ", "top", "),", " ", "space", "=", "0", ",", " ", "horiz", "=", "TRU", "E", " ", ")", " ", ";", "\\", "10", ";", "title", "(", "main", "='", "%", "s", "');", "\\", "10", ";\"\"\"_", "%_", "(_", "point", "\\u", "size_", ",_", "extra", "\\u", "options_", ",_", "xlabel_", ",_", "ylabel_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "options_", "._", "title_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "R_", "._", "mte", "xt_", "(_", "options_", "._", "title_", ",_", "3_", ",_", "outer_", "=_", "True_", ",_", "line_", "=_", "1_", ",_", "ce", "x_", "=_", "1.5_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "method_", "in_", "(_", "\"", "panel", "\"_", ",_", "\"", "1", "\\u", "vs", "\\u", "x", "\"_", ",_", "\"", "matche", "d", "\"_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "method_", "==_", "\"", "panel", "\"_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "pairs_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "x_", "in_", "range_", "(_", "len_", "(_", "headers_", ")_", "-_", "1_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "for_", "y_", "in_", "range_", "(_", "x_", "+_", "1_", ",_", "len_", "(_", "headers_", ")_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "pairs_", "._", "append_", "(_", "(_", "x_", ",_", "y_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "method_", "==_", "\"", "1", "\\u", "vs", "\\u", "x", "\"_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "pairs_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "x_", "in_", "range_", "(_", "1_", ",_", "len_", "(_", "headers_", ")_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "pairs_", "._", "append_", "(_", "(_", "0_", ",_", "x_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "print", " ", "matchi", "ng", " ", "columns_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "method_", "==_", "\"", "matche", "d", "\"_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "pairs_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "x_", "in_", "range_", "(_", "len_", "(_", "headers_", ")_", "-_", "1_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "for_", "y_", "in_", "range_", "(_", "x_", "+_", "1_", ",_", "len_", "(_", "headers_", ")_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "if_", "headers_", "[_", "x_", "]_", "==_", "headers_", "[_", "y_", "]_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "pairs_", "._", "append_", "(_", "(_", "x_", ",_", "y_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "break_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "w_", "=_", "int_", "(_", "math_", "._", "ceil_", "(_", "math_", "._", "sqrt_", "(_", "len_", "(_", "pairs_", ")_", ")_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "h_", "=_", "int_", "(_", "math_", "._", "ceil_", "(_", "float_", "(_", "len_", "(_", "pairs_", ")_", ")_", "/_", "w_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "Pos", "Inf", "_", "=_", "1e", "300000", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "Ne", "g", "Inf", "_", "=_", "-_", "1e", "300000", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "xlabel_", ",_", "ylabel_", "=_", "options_", "._", "labels_", "._", "split_", "(_", "\",\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "R_", "(_", "\"\"\"", "layout", "(", "matrix", "(", "seq", "(", "1", ",%", "i", "),", " ", "%", "i", ",", " ", "%", "i", ",", " ", "by", "row", " ", "=", " ", "TRU", "E", "))", "\"\"\"_", "%_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "w_", "*_", "h_", ",_", "w_", ",_", "h_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "a_", ",_", "b_", "in_", "pairs_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "new", "\\u", "matrix_", "=_", "filter_", "(_", "lambda_", "x_", ":_", "\\u\\u\\uNL\\u\\u\\u_", "x_", "[_", "0_", "]_", "not_", "in_", "(_", "float_", "(_", "\"", "nan", "\"_", ")_", ",_", "Pos", "Inf", "_", ",_", "Ne", "g", "Inf", "_", ")_", "and_", "\\u\\u\\uNL\\u\\u\\u_", "x_", "[_", "1_", "]_", "not_", "in_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "float_", "(_", "\"", "nan", "\"_", ")_", ",_", "Pos", "Inf", "_", ",_", "Ne", "g", "Inf", "_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "zip_", "(_", "matrix_", "[_", "a_", "]_", "._", "values_", "(_", ")_", "[_", "0_", "]_", ",_", "matrix_", "[_", "b_", "]_", "._", "values_", "(_", ")_", "[_", "0_", "]_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "R_", "(_", "\"\"\"", "plot", "(", "matrix", "[", ",%", "i", "],", " ", "matrix", "[", ",%", "i", "],", " ", "main", "='", "%", "s", " ", "vers", "us", " ", "%", "s", "',", " ", "ce", "x", "=", "0.", "5", ",", " ", "pch", "=\".", "\",", " ", "xla", "b", "='", "%", "s", "',", " ", "yla", "b", "='", "%", "s", "'", " ", ")\"\"\"_", "%_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "a_", "+_", "1_", ",_", "b_", "+_", "1_", ",_", "headers_", "[_", "b_", "]_", ",_", "headers_", "[_", "a_", "]_", ",_", "xlabel_", ",_", "ylabel_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "rpy", "_", "._", "RE", "xcept", "ion_", ",_", "msg_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "print_", "\"", "coul", "d", " ", "not", " ", "plot", " ", "%", "s", " ", "vers", "us", " ", "%", "s", ":", " ", "%", "s", "\"_", "%_", "(_", "headers_", "[_", "b_", "]_", ",_", "headers_", "[_", "a_", "]_", ",_", "msg_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "options_", "._", "hard", "copy_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "R_", "[_", "'", "dev", ".", "off", "'_", "]_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "E_", "._", "info_", "(_", "\"", "matrix", " ", "adde", "d", " ", "as", " ", ">", "matrix", "<", " ", "in", " ", "R", ".\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "not_", "options_", "._", "hard", "copy_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "options_", "._", "input", "\\u", "filename_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "interpreter_", "=_", "code_", "._", "Interact", "ive", "Console_", "(_", "globals_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "interpreter_", "._", "interact", "_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "E_", "._", "info_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "can", " ", "not", " ", "start", " ", "new", " ", "interactive", " ", "session", " ", "as", " ", "input", " ", "has", " ", "come", " ", "from", " ", "std", "in", ".\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "E_", "._", "Stop_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_" ]
[ 4, 4, 4, 4, 4, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2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"\n\"\"\"\nExceptions related to datasets\n\"\"\"\n\nfrom pylearn2.utils.exc import EnvironmentVariableError, NoDataPathError\nfrom pylearn2.utils.common_strings import environment_variable_essay\n\n\n", "metadata": "root", "header": "['module', '___EOS___']", "index": 0 }, { "content": "class NotInstalledError(Exception):\n\n \"\"\"\n Exception raised when a dataset appears not to be installed.\n This is different from an individual file missing within a dataset,\n the file not loading correctly, etc.\n This exception is used to make unit tests skip testing of datasets\n that haven't been installed.\n We do want the unit test to run and crash if the dataset is installed\n incorrectly.\n \"\"\"", "metadata": "root.NotInstalledError", "header": "['module', '___EOS___']", "index": 14 } ]
[ { "span": "from pylearn2.utils.exc import EnvironmentVariableError, NoDataPathError", "start_line": 10, "start_column": 0, "end_line": 10, "end_column": 72 }, { "span": "from pylearn2.utils.common_strings import environment_variable_essay", "start_line": 11, "start_column": 0, "end_line": 11, "end_column": 68 } ]
[]
1
false
[ "[CLS]_", "Un", "used_", "import_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\"\"\"", "\\", "10", ";", "..", " ", "todo", "::", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "WRITE", "ME", "\\", "10", ";\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u", "author\\u\\u_", "=_", "\"", "Ia", "n", " ", "Good", "fel", "low", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\"\"\"", "\\", "10", ";", "Except", "ion", "s", " ", "relate", "d", " ", "to", " ", "dataset", "s", "\\", "10", ";\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "from_", "pyl", "earn", "2_", "._", "utils_", "._", "exc_", "import_", "Environ", "ment", "Varia", "ble", "Error_", ",_", "No", "Data", "Path", "Error_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "pyl", "earn", "2_", "._", "utils_", "._", "common", "\\u", "strings_", "import_", "environ", "ment", "\\u", "variab", "le", "\\u", "essa", "y_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "class_", "Not", "Install", "ed", "Error_", "(_", "Exception_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Except", "ion", " ", "raise", "d", " ", "whe", "n", " ", "a", " ", "dataset", " ", "appear", "s", " ", "not", " ", "to", " ", "be", " ", "install", "ed", ".", "\\", "10", ";", " ", " ", " ", " ", "Thi", "s", " ", "is", " ", "different", " ", "from", " ", "an", " ", "individual", " ", "file", " ", "missi", "ng", " ", "within", " ", "a", " ", "dataset", ",", "\\", "10", ";", " ", " ", " ", " ", "the", " ", "file", " ", "not", " ", "load", "ing", " ", "correct", "ly", ",", " ", "etc", ".", "\\", "10", ";", " ", " ", " ", " ", "Thi", "s", " ", "exception", " ", "is", " ", "used", " ", "to", " ", "make", " ", "unit", " ", "tests", " ", "skip", " ", "testi", "ng", " ", "of", " ", "dataset", "s", "\\", "10", ";", " ", " ", " ", " ", "tha", "t", " ", "have", "n", "'", "t", " ", "bee", "n", " ", "install", "ed", ".", "\\", "10", ";", " ", " ", " ", " ", "We", " ", "do", " ", "want", " ", "the", " ", "unit", " ", "test", " ", "to", " ", "run", " ", "and", " ", "crash", " ", "if", " ", "the", " ", "dataset", " ", "is", " ", "install", "ed", "\\", "10", ";", " ", " ", " ", " ", "incorrect", "ly", ".", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_" ]
[ 4, 4, 4, 4, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 ]
Unreachable code
gallantlab/pycortex/cortex/dataset/views.py
[ { "content": " def __init__(self, views, description=\"\"):\n for view in views:\n if not isinstance(view, Dataview):\n raise TypeError(\"Must be a View object!\")\n raise NotImplementedError\n self.views = views", "metadata": "root.Multiview.__init__", "header": "['class', 'Multiview', '(', 'Dataview', ')', ':', '___EOS___']", "index": 231 } ]
[ { "span": "self.views = views", "start_line": 236, "start_column": 8, "end_line": 236, "end_column": 26 } ]
[]
1
true
[ "[CLS]_", "Unrea", "chab", "le_", "code_", "[SEP]_", "class_", "Multi", "view_", "(_", "Data", "view_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "def_", "\\u\\u", "init\\u\\u_", "(_", "self_", ",_", "views_", ",_", "description_", "=_", "\"\"_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "for_", "view_", "in_", "views_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "not_", "isinstance_", "(_", "view_", ",_", "Data", "view_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "raise_", "Type", "Error_", "(_", "\"", "Mus", "t", " ", "be", " ", "a", " ", "View", " ", "object", "!\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "raise_", "Not", "Impl", "ement", "ed", "Error_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "views_", "=_", "views_", "\\u\\u\\uNEWLINE\\u\\u\\u_" ]
[ 4, 4, 4, 4, 4, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 1, 1, 1, 1, 2 ]
Unused local variable
enthought/envisage/envisage/plugins/ipython_shell/view/namespace_view.py
[ { "content": " def tno_get_children ( self, node ):\n \"\"\" Gets the object's children.\n\n We overwrite this method for a nicer label on the objects.\n \"\"\"\n node_for = self.node_for\n items = list(self.value.items())\n items.sort( lambda l, r: cmp( l[0], r[0] ) )\n if len( items ) > 500:\n return ([ self.node_for( k, v ) for k, v in items[: 250 ] ] +\n [ StringNode( value = '...', readonly = True ) ] +\n [ self.node_for( k, v ) for k, v in items[ -250: ] ])\n\n return [ self.node_for( k, v ) for k, v in items ]", "metadata": "root.NamespaceNode.tno_get_children", "header": "['class', 'NamespaceNode', '(', 'DictNode', ')', ':', '___EOS___']", "index": 78 } ]
[ { "span": "node_for ", "start_line": 83, "start_column": 8, "end_line": 83, "end_column": 16 } ]
[]
1
true
[ "[CLS]_", "Un", "used_", "local_", "variable_", "[SEP]_", "class_", "Names", "pace", "Node_", "(_", "Dict", "Node_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "tno", "\\u", "get", "\\u", "children_", "(_", "self_", ",_", "node_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", " ", "Get", "s", " ", "the", " ", "object", "'", "s", " ", "child", "ren", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "We", " ", "overwrit", "e", " ", "this", " ", "method", " ", "for", " ", "a", " ", "nice", "r", " ", "label", " ", "on", " ", "the", " ", "object", "s", ".", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "node", "\\u", "for_", "=_", "self_", "._", "node", "\\u", "for_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "items_", "=_", "list_", "(_", "self_", "._", "value_", "._", "items_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "items_", "._", "sort_", "(_", "lambda_", "l_", ",_", "r_", ":_", "cmp_", "(_", "l_", "[_", "0_", "]_", ",_", "r_", "[_", "0_", "]_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "len_", "(_", "items_", ")_", ">_", "500_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "(_", "[_", "self_", "._", "node", "\\u", "for_", "(_", "k_", ",_", "v_", ")_", "for_", "k_", ",_", "v_", "in_", "items_", "[_", ":_", "250_", "]_", "]_", "+_", "\\u\\u\\uNL\\u\\u\\u_", "[_", "String", "Node_", "(_", "value_", "=_", "'...'_", ",_", "readonly_", "=_", "True_", ")_", "]_", "+_", "\\u\\u\\uNL\\u\\u\\u_", "[_", "self_", "._", "node", "\\u", "for_", "(_", "k_", ",_", "v_", ")_", "for_", "k_", ",_", "v_", "in_", "items_", "[_", "-_", "250_", ":_", "]_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "[_", "self_", "._", "node", "\\u", "for_", "(_", "k_", ",_", "v_", ")_", "for_", "k_", ",_", "v_", "in_", "items_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_" ]
[ 4, 4, 4, 4, 4, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 ]
Except block handles 'BaseException'
nasa/CrisisMappingToolkit/bin/test_active_contour.py
[ { "content": "# -----------------------------------------------------------------------------\n# Copyright * 2014, United States Government, as represented by the\n# Administrator of the National Aeronautics and Space Administration. All\n# rights reserved.\n#\n# The Crisis Mapping Toolkit (CMT) v1 platform is licensed under the Apache\n# License, Version 2.0 (the \"License\"); you may not use this file except in\n# compliance with the License. You may obtain a copy of the License at\n# http://www.apache.org/licenses/LICENSE-2.0.\n#\n# Unless required by applicable law or agreed to in writing, software\n# distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the\n# License for the specific language governing permissions and limitations under\n# the License.\n# -----------------------------------------------------------------------------\n\n\nimport logging\nlogging.basicConfig(level=logging.ERROR)\ntry:\n import cmt.ee_authenticate\nexcept:\n import sys\n import os.path\n sys.path.append(os.path.join(os.path.dirname(os.path.realpath(__file__)), '..'))\n import cmt.ee_authenticate\ncmt.ee_authenticate.initialize()\n\nimport time\n\nimport cmt.domain\nfrom cmt.radar.active_contour import *\n\nimport sys\nimport PIL\nfrom PIL import ImageQt\nimport numpy\nfrom PyQt4 import QtGui, QtCore\napp = QtGui.QApplication(sys.argv)\n\n\n# from PIL import Image, ImageChops\n# import matplotlib.pyplot as plt\n# plt.imread('/home/smcmich1/fileTest.tif')\n# raise Exception('DEBUG')\n\n\nTHIS_FILE_FOLDER = os.path.dirname(os.path.realpath(__file__))\n\n\n# DOMAIN SELECTION IS HERE!\n# domain = cmt.domain.Domain(os.path.join(THIS_FILE_FOLDER, '..') + '/config/domains/uavsar/mississippi.xml')\n# domain = cmt.domain.Domain(os.path.join(THIS_FILE_FOLDER, '..') + '/config/domains/sentinel1/malawi_2015_1.xml')\n# domain = cmt.domain.Domain(os.path.join(THIS_FILE_FOLDER, '..') + '/config/domains/sentinel1/rome_small.xml')\n# domain = cmt.domain.Domain(os.path.join(THIS_FILE_FOLDER, '..') + '/config/domains/skybox/malawi_2015.xml')\n# domain = cmt.domain.Domain(os.path.join(THIS_FILE_FOLDER, '..') + '/config/domains/skybox/gloucester_2014_10.xml')\n# domain = cmt.domain.Domain(os.path.join(THIS_FILE_FOLDER, '..') + '/config/domains/skybox/sumatra_2014_10.xml')\ndomain = cmt.domain.Domain(os.path.join(THIS_FILE_FOLDER, '..') + '/config/domains/skybox/new_bedford_2014_10.xml')\n\n# result = active_contour(domain) # Run this to compute the final results!\n\n\n\n\nex = ActiveContourWindow(domain)\nsys.exit(app.exec_())\n", "metadata": "root", "header": "['module', '___EOS___']", "index": 0 }, { "content": " def __init__(self, domain):\n super(ActiveContourWindow, self).__init__()\n self.setGeometry(300, 300, 650, 650)\n self.setWindowTitle('Active Contour')\n self.domain = domain\n\n \"\"\"\n Fetch image and compute statistics\n sensor = domain.get_radar()\n detect_channel = domain.algorithm_params['water_detect_radar_channel']\n ee_image = sensor.image.select([detect_channel]).toUint16()\n if sensor.log_scale:\n statisics_image = ee_image.log10()\n else:\n statisics_image = ee_image\n (band_names, band_statistics) = compute_band_statistics(statisics_image, domain.ground_truth, domain.bounds)\n\n (self.local_image, self.snake) = initialize_active_contour(domain, ee_image, band_statistics, sensor.log_scale)\n\n Retrieve the local image bands and merge them into a fake RGB image\n channels = [self.local_image.get_image(detect_channel), self.local_image.get_image(detect_channel), self.local_image.get_image(detect_channel)]\n channel_images = [PIL.Image.fromarray(numpy.uint8(c*255/1200)) for c in channels] Convert from 16 bit to 8 bit\n self.display_image = PIL.Image.merge('RGB', channel_images)\n self.step = 1\n self.show()\n \"\"\"\n \"\"\"\n Initialize the contour with the selected sensor band\n sensor_name = 'uavsar'\n sensor = getattr(domain, sensor_name)\n ee_image = sensor.image.select(['hh'])\n\n # TODO: Make sure the name and statistics line up inside the class!\n # Compute statistics for each band -> Log10 needs to be applied here!\n (band_names, band_statistics) = compute_band_statistics(statisics_image, domain.ground_truth, domain.bounds)\n\n (self.local_image, self.snake) = initialize_active_contour(domain, ee_image, band_statistics, sensor.log_scale)\n\n # Retrieve the local image bands and merge them into a fake RGB image\n #channels = [self.local_image.get_image('hh'), self.local_image.get_image('hv'), self.local_image.get_image('vv')]\n channels = [self.local_image.get_image('hh'), self.local_image.get_image('hh'), self.local_image.get_image('hh')]\n channel_images = [PIL.Image.fromarray(numpy.uint8(c >> 8)) for c in channels] # Convert from 16 bit to 8 bit\n self.display_image = PIL.Image.merge('RGB', channel_images)\n self.step = 1\n self.show()\n \"\"\"\n\n SKYBOX_SCALE = 1200 / 256\n train_domain = domain.training_domain # For skybox data there is probably no earlier image to train off of\n try: # The Skybox data can be in one of two names\n sensor = domain.skybox\n trainSensor = train_domain.skybox\n except:\n sensor = domain.skybox_nir\n trainSensor = train_domain.skybox_nir\n ee_image = sensor.image.toUint16() # For Skybox, these are almost certainly the same image.\n ee_image_train = trainSensor.image.toUint16()\n\n if train_domain.training_features: # Train using features\n (band_names, band_statistics) = compute_band_statistics_features(ee_image_train, train_domain.training_features)\n else: # Train using training truth\n (band_names, band_statistics) = compute_band_statistics(ee_image_train, train_domain.ground_truth,\n train_domain.bounds)\n (self.local_image, self.snake) = initialize_active_contour(domain, ee_image, band_statistics, False)\n\n # Retrieve the local image bands and merge them into a fake RGB image\n channels = [self.local_image.get_image('Red'), self.local_image.get_image('Green'), self.local_image.get_image('Blue')]\n channel_images = [PIL.Image.fromarray(numpy.uint8(c / SKYBOX_SCALE)) for c in channels] # Convert from Skybox range to 8 bit\n self.display_image = PIL.Image.merge('RGB', channel_images)\n self.step = 1\n self.show()", "metadata": "root.ActiveContourWindow.__init__", "header": "['class', 'ActiveContourWindow', '(', 'QtGui', '.', 'QWidget', ')', ':', '___EOS___']", "index": 81 } ]
[ { "span": "except:", "start_line": 22, "start_column": 0, "end_line": 22, "end_column": 7 }, { "span": "except:", "start_line": 133, "start_column": 8, "end_line": 133, "end_column": 15 } ]
[]
1
true
[ "[CLS]_", "Except", "_", "block_", "handles_", "'", "Base", "Except", "ion", "'_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "#", " ", "--------------", "--------------", "--------------", "--------------", "--------------", "-------", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Copy", "right", " ", "*", " ", "2014", ",", " ", "Unit", "ed", " ", "State", "s", " ", "Gov", "ern", "ment", ",", " ", "as", " ", "represent", "ed", " ", "by", " ", "the_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Administra", "tor", " ", "of", " ", "the", " ", "Nat", "ional", " ", "Aer", "ona", "uti", "cs", " ", "and", " ", "Spac", "e", " ", "Administrati", "on", ".", " ", "All_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "rights", " ", "reserve", "d", "._", "\\u\\u\\uNL\\u\\u\\u_", "#", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "The", " ", "Cri", "sis", " ", "Map", "ping", " ", "Tool", "kit", " ", "(", "CM", "T", ")", " ", "v1", " ", "platform", " ", "is", " ", "license", "d", " ", "under", " ", "the", " ", "Ap", "ache_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "License", ",", " ", "Version", " ", "2.0", " ", "(", "the", " ", "\"", "License", "\");", " ", "you", " ", "may", " ", "not", " ", "use", " ", "this", " ", "file", " ", "except", " ", "in_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "compli", "anc", "e", " ", "with", " ", "the", " ", "License", ".", " ", "You", " ", "may", " ", "obtain", " ", "a", " ", "copy", " ", "of", " ", "the", " ", "License", " ", "at_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "http", "://", "www", ".", "apa", "che", ".", "org", "/", "license", "s", "/", "LICENSE", "-", "2.0", "._", "\\u\\u\\uNL\\u\\u\\u_", "#", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Un", "less", " ", "require", "d", " ", "by", " ", "applica", "ble", " ", "law", " ", "or", " ", "agree", "d", " ", "to", " ", "in", " ", "writ", "ing", ",", " ", "software", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "distributed", " ", "under", " ", "the", " ", "License", " ", "is", " ", "distributed", " ", "on", " ", "an", " ", "\"", "AS", " ", "IS", "\"", " ", "BAS", "IS", ",", " ", "WITH", "OUT_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "WAR", "RAN", "TIES", " ", "OR", " ", "CONDITION", "S", " ", "OF", " ", "ANY", " ", "KIND", ",", " ", "eit", "her", " ", "express", " ", "or", " ", "impli", "ed", ".", " ", "See", " ", "the_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "License", " ", "for", " ", "the", " ", "specific", " ", "language", " ", "govern", "ing", " ", "permissi", "ons", " ", "and", " ", "limit", "ation", "s", " ", "under", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "the", " ", "License", "._", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "--------------", "--------------", "--------------", "--------------", "--------------", "-------", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "import_", "logging_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "logging_", "._", "basic", "Config_", "(_", "level_", "=_", "logging_", "._", "ERROR_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "import_", "cmt", "_", "._", "ee", "\\u", "authenticate_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "import_", "sys_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "os_", "._", "path_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "sys_", "._", "path_", "._", "append_", "(_", "os_", "._", "path_", "._", "join_", "(_", "os_", "._", "path_", "._", "dirname_", "(_", "os_", "._", "path_", "._", "realpath_", "(_", "\\u\\u", "file\\u\\u_", ")_", ")_", ",_", "'..'_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "cmt", "_", "._", "ee", "\\u", "authenticate_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "cmt", "_", "._", "ee", "\\u", "authenticate_", "._", "initialize_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "import_", "time_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "import_", "cmt", "_", "._", "domain_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "cmt", "_", "._", "radar", "_", "._", "active", "\\u", "contour_", "import_", "*_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "import_", "sys_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "PIL_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "PIL_", "import_", "Image", "Qt_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "numpy_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "Py", "Qt4_", "import_", "Qt", "Gui_", ",_", "Qt", "Core_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "app_", "=_", "Qt", "Gui_", "._", "QA", "ppl", "ication", "_", "(_", "sys_", "._", "argv_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "from", " ", "PI", "L", " ", "import", " ", "Image", ",", " ", "Image", "Cho", "ps_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "import", " ", "mat", "plotlib", ".", "pypl", "ot", " ", "as", " ", "plt_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "plt", ".", "im", "read", "('", "/", "home", "/", "sm", "cmi", "ch", "1", "/", "file", "Test", ".", "tif", "')", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "raise", " ", "Except", "ion", "('", "DEBU", "G", "')", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "THIS", "\\u", "FILE", "\\u", "FOLDER_", "=_", "os_", "._", "path_", "._", "dirname_", "(_", "os_", "._", "path_", "._", "realpath_", "(_", "\\u\\u", "file\\u\\u_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "DOM", "AIN", " ", "SELECTION", " ", "IS", " ", "HER", "E", "!", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "domain", " ", "=", " ", "cmt", ".", "domain", ".", "Doma", "in", "(", "os", ".", "path", ".", "join", "(", "THIS", "\\u", "FILE", "\\u", "FOLDER", ",", " ", "'..", "')", " ", "+", " ", "'/", "config", "/", "domains", "/", "ua", "vs", "ar", "/", "missi", "ssi", "ppi", ".", "xml", "')", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "domain", " ", "=", " ", "cmt", ".", "domain", ".", "Doma", "in", "(", "os", ".", "path", ".", "join", "(", "THIS", "\\u", "FILE", "\\u", "FOLDER", ",", " ", "'..", "')", " ", "+", " ", "'/", "config", "/", "domains", "/", "sentinel", "1", "/", "mal", "aw", "i", "\\u", "201", "5", "\\u", "1", ".", "xml", "')", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "domain", " ", "=", " ", "cmt", ".", "domain", ".", "Doma", "in", "(", "os", ".", "path", ".", "join", "(", "THIS", "\\u", "FILE", "\\u", "FOLDER", ",", " ", "'..", "')", " ", "+", " ", "'/", "config", "/", "domains", "/", "sentinel", "1", "/", "rom", "e\\u", "small", ".", "xml", "')", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "domain", " ", "=", " ", "cmt", ".", "domain", ".", "Doma", "in", "(", "os", ".", "path", ".", "join", "(", "THIS", "\\u", "FILE", "\\u", "FOLDER", ",", " ", "'..", "')", " ", "+", " ", "'/", "config", "/", "domains", "/", "sky", "box", "/", "mal", "aw", "i", "\\u", "201", "5", ".", "xml", "')", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "domain", " ", "=", " ", "cmt", ".", "domain", ".", "Doma", "in", "(", "os", ".", "path", ".", "join", "(", "THIS", "\\u", "FILE", "\\u", "FOLDER", ",", " ", "'..", "')", " ", "+", " ", "'/", "config", "/", "domains", "/", "sky", "box", "/", "glo", "uce", "ster", "\\u", "2014", "\\u", "10.", "xml", "')", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "domain", " ", "=", " ", "cmt", ".", "domain", ".", "Doma", "in", "(", "os", ".", "path", ".", "join", "(", "THIS", "\\u", "FILE", "\\u", "FOLDER", ",", " ", "'..", "')", " ", "+", " ", "'/", "config", "/", "domains", "/", "sky", "box", "/", "suma", "tra", "\\u", "2014", "\\u", "10.", "xml", "')", "_", "\\u\\u\\uNL\\u\\u\\u_", "domain_", "=_", "cmt", "_", "._", "domain_", "._", "Domain_", "(_", "os_", "._", "path_", "._", "join_", "(_", "THIS", "\\u", "FILE", "\\u", "FOLDER_", ",_", "'..'_", ")_", "+_", "'/", "config", "/", "domains", "/", "sky", "box", "/", "new", "\\u", "bed", "for", "d\\u", "2014", "\\u", "10.", "xml", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "result", " ", "=", " ", "active", "\\u", "conto", "ur", "(", "domain", ")", " ", "#", " ", "Run", " ", "this", " ", "to", " ", "compute", " ", "the", " ", "final", " ", "results", "!", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "ex_", "=_", "Activ", "e", "Contour", "Window_", "(_", "domain_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "sys_", "._", "exit_", "(_", "app_", "._", "exec\\u_", "(_", ")_", ")_", "[SEP]_", "class_", "Activ", "e", "Contour", "Window_", "(_", "Qt", "Gui_", "._", "QW", "idge", "t_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "\\u\\u", "init\\u\\u_", "(_", "self_", ",_", "domain_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "super_", "(_", "Activ", "e", "Contour", "Window_", ",_", "self_", ")_", "._", "\\u\\u", "init\\u\\u_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "set", "Geometry_", "(_", "300_", ",_", "300_", ",_", "650_", ",_", "650_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "set", "Window", "Title_", "(_", "'", "Activ", "e", " ", "Contour", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "domain_", "=_", "domain_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Fe", "tch", " ", "image", " ", "and", " ", "compute", " ", "statistic", "s", "\\", "10", ";", " ", " ", " ", " ", "sensor", " ", " ", " ", " ", " ", "=", " ", "domain", ".", "get", "\\u", "radar", "()", "\\", "10", ";", " ", " ", " ", " ", "detect", "\\u", "channel", " ", "=", " ", "domain", ".", "algo", "rit", "hm", "\\u", "params", "['", "water", "\\u", "detect", "\\u", "radar", "\\u", "channel", "']", "\\", "10", ";", " ", " ", " ", " ", "ee", "\\u", "image", " ", " ", " ", "=", " ", "sensor", ".", "image", ".", "select", "([", "detect", "\\u", "channel", "])", ".", "to", "Uint", "16", "()", "\\", "10", ";", " ", " ", " ", " ", "if", " ", "sensor", ".", "log", "\\u", "scale", ":", "\\", "10", ";", " ", " ", " ", " ", "stati", "sic", "s", "\\u", "image", " ", "=", " ", "ee", "\\u", "image", ".", "log", "10", "()", "\\", "10", ";", " ", " ", " ", " ", "else", ":", "\\", "10", ";", " ", " ", " ", " ", "stati", "sic", "s", "\\u", "image", " ", "=", " ", "ee", "\\u", "image", "\\", "10", ";", " ", " ", " ", " ", "(", "band", "\\u", "names", ",", " ", "band", "\\u", "statistic", "s", ")", " ", "=", " ", "compute", "\\u", "band", "\\u", "statistic", "s", "(", "stati", "sic", "s", "\\u", "image", ",", " ", "domain", ".", "ground", "\\u", "truth", ",", " ", "domain", ".", "bound", "s", ")", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "(", "self", ".", "local", "\\u", "image", ",", " ", "self", ".", "snake", ")", " ", "=", " ", "initialize", "\\u", "active", "\\u", "conto", "ur", "(", "domain", ",", " ", "ee", "\\u", "image", ",", " ", "band", "\\u", "statistic", "s", ",", " ", "sensor", ".", "log", "\\u", "scale", ")", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", " ", "Retrieve", " ", "the", " ", "local", " ", "image", " ", "band", "s", " ", "and", " ", "merge", " ", "them", " ", "int", "o", " ", "a", " ", "fake", " ", "RGB", " ", "image", "\\", "10", ";", " ", " ", " ", " ", "channel", "s", " ", "=", " ", "[", "self", ".", "local", "\\u", "image", ".", "get", "\\u", "image", "(", "detect", "\\u", "channel", "),", " ", "self", ".", "local", "\\u", "image", ".", "get", "\\u", "image", "(", "detect", "\\u", "channel", "),", " ", "self", ".", "local", "\\u", "image", ".", "get", "\\u", "image", "(", "detect", "\\u", "channel", ")]", "\\", "10", ";", " ", " ", " ", " ", "channel", "\\u", "images", " ", "=", " ", "[", "PI", "L", ".", "Image", ".", "froma", "rray", "(", "nump", "y", ".", "uint", "8", "(", "c", "*", "255", "/", "1200", "))", " ", "for", " ", "c", " ", "in", " ", "channel", "s", "]", " ", " ", "Convert", " ", "from", " ", "16", " ", "bit", " ", "to", " ", "8", " ", "bit", "\\", "10", ";", " ", " ", " ", " ", "self", ".", "display", "\\u", "image", " ", "=", " ", "PI", "L", ".", "Image", ".", "merge", "('", "RGB", "',", " ", "channel", "\\u", "images", ")", "\\", "10", ";", " ", " ", " ", " ", "self", ".", "step", " ", "=", " ", "1", "\\", "10", ";", " ", " ", " ", " ", "self", ".", "show", "()", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Initializ", "e", " ", "the", " ", "conto", "ur", " ", "with", " ", "the", " ", "selecte", "d", " ", "sensor", " ", "band", "\\", "10", ";", " ", " ", " ", " ", "sensor", "\\u", "name", " ", "=", " ", "'", "ua", "vs", "ar", "'", "\\", "10", ";", " ", " ", " ", " ", "sensor", " ", " ", "=", " ", "getattr", "(", "domain", ",", " ", "sensor", "\\u", "name", ")", "\\", "10", ";", " ", " ", " ", " ", "ee", "\\u", "image", " ", " ", " ", " ", "=", " ", "sensor", ".", "image", ".", "select", "([", "'", "hh", "'])", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "#", " ", "TOD", "O", ":", " ", "Make", " ", "sure", " ", "the", " ", "name", " ", "and", " ", "statistic", "s", " ", "line", " ", "up", " ", "insi", "de", " ", "the", " ", "class", "!", "\\", "10", ";", " ", " ", " ", " ", "#", " ", "Compute", " ", "statistic", "s", " ", "for", " ", "each", " ", "band", " ", "->", " ", "Log", "10", " ", "need", "s", " ", "to", " ", "be", " ", "applied", " ", "here", "!", "\\", "10", ";", " ", " ", " ", " ", "(", "band", "\\u", "names", ",", " ", "band", "\\u", "statistic", "s", ")", " ", "=", " ", "compute", "\\u", "band", "\\u", "statistic", "s", "(", "stati", "sic", "s", "\\u", "image", ",", " ", "domain", ".", "ground", "\\u", "truth", ",", " ", "domain", ".", "bound", "s", ")", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "(", "self", ".", "local", "\\u", "image", ",", " ", "self", ".", "snake", ")", " ", "=", " ", "initialize", "\\u", "active", "\\u", "conto", "ur", "(", "domain", ",", " ", "ee", "\\u", "image", ",", " ", "band", "\\u", "statistic", "s", ",", " ", "sensor", ".", "log", "\\u", "scale", ")", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "#", " ", "Retrieve", " ", "the", " ", "local", " ", "image", " ", "band", "s", " ", "and", " ", "merge", " ", "them", " ", "int", "o", " ", "a", " ", "fake", " ", "RGB", " ", "image", "\\", "10", ";", " ", " ", " ", " ", "#", "channel", "s", " ", "=", " ", "[", "self", ".", "local", "\\u", "image", ".", "get", "\\u", "image", "('", "hh", "')", ",", " ", "self", ".", "local", "\\u", "image", ".", "get", "\\u", "image", "('", "hv", "')", ",", " ", "self", ".", "local", "\\u", "image", ".", "get", "\\u", "image", "('", "vv", "')]", "\\", "10", ";", " ", " ", " ", " ", "channel", "s", " ", "=", " ", "[", "self", ".", "local", "\\u", "image", ".", "get", "\\u", "image", "('", "hh", "')", ",", " ", "self", ".", "local", "\\u", "image", ".", "get", "\\u", "image", "('", "hh", "')", ",", " ", "self", ".", "local", "\\u", "image", ".", "get", "\\u", "image", "('", "hh", "')]", "\\", "10", ";", " ", " ", " ", " ", "channel", "\\u", "images", " ", "=", " ", "[", "PI", "L", ".", "Image", ".", "froma", "rray", "(", "nump", "y", ".", "uint", "8", "(", "c", " ", ">>", " ", "8", "))", " ", "for", " ", "c", " ", "in", " ", "channel", "s", "]", " ", "#", " ", "Convert", " ", "from", " ", "16", " ", "bit", " ", "to", " ", "8", " ", "bit", "\\", "10", ";", " ", " ", " ", " ", "self", ".", "display", "\\u", "image", " ", "=", " ", "PI", "L", ".", "Image", ".", "merge", "('", "RGB", "',", " ", "channel", "\\u", "images", ")", "\\", "10", ";", " ", " ", " ", " ", "self", ".", "step", " ", "=", " ", "1", "\\", "10", ";", " ", " ", " ", " ", "self", ".", "show", "()", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "SK", "YB", "OX", "\\u", "SCALE_", "=_", "1200_", "/_", "256_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "train", "\\u", "domain_", "=_", "domain_", "._", "train", "ing", "\\u", "domain_", "#", " ", "For", " ", "sky", "box", " ", "data", " ", "there", " ", "is", " ", "probab", "ly", " ", "no", " ", "ear", "lie", "r", " ", "image", " ", "to", " ", "train", " ", "off", " ", "of_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "try_", ":_", "#", " ", "The", " ", "Sky", "box", " ", "data", " ", "can", " ", "be", " ", "in", " ", "one", " ", "of", " ", "two", " ", "names_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "sensor_", "=_", "domain_", "._", "sky", "box_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "train", "Sensor_", "=_", "train", "\\u", "domain_", "._", "sky", "box_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "sensor_", "=_", "domain_", "._", "sky", "box", "\\u", "ni", "r_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "train", "Sensor_", "=_", "train", "\\u", "domain_", "._", "sky", "box", "\\u", "ni", "r_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "ee", "\\u", "image_", "=_", "sensor_", "._", "image_", "._", "to", "Uint", "16_", "(_", ")_", "#", " ", "For", " ", "Sky", "box", ",", " ", "these", " ", "are", " ", "alm", "ost", " ", "cert", "ain", "ly", " ", "the", " ", "same", " ", "image", "._", "\\u\\u\\uNEWLINE\\u\\u\\u_", "ee", "\\u", "image", "\\u", "train_", "=_", "train", "Sensor_", "._", "image_", "._", "to", "Uint", "16_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "train", "\\u", "domain_", "._", "train", "ing", "\\u", "features_", ":_", "#", " ", "Train", " ", "usi", "ng", " ", "features_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "(_", "band", "\\u", "names_", ",_", "band", "\\u", "statistics_", ")_", "=_", "compute", "\\u", "band", "\\u", "statistic", "s", "\\u", "features_", "(_", "ee", "\\u", "image", "\\u", "train_", ",_", "train", "\\u", "domain_", "._", "train", "ing", "\\u", "features_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "#", " ", "Train", " ", "usi", "ng", " ", "train", "ing", " ", "truth_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "(_", "band", "\\u", "names_", ",_", "band", "\\u", "statistics_", ")_", "=_", "compute", "\\u", "band", "\\u", "statistics_", "(_", "ee", "\\u", "image", "\\u", "train_", ",_", "train", "\\u", "domain_", "._", "ground", "\\u", "truth_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "train", "\\u", "domain_", "._", "bounds_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "(_", "self_", "._", "local", "\\u", "image_", ",_", "self_", "._", "snake", "_", ")_", "=_", "initialize", "\\u", "active", "\\u", "contour_", "(_", "domain_", ",_", "ee", "\\u", "image_", ",_", "band", "\\u", "statistics_", ",_", "False_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Retrieve", " ", "the", " ", "local", " ", "image", " ", "band", "s", " ", "and", " ", "merge", " ", "them", " ", "int", "o", " ", "a", " ", "fake", " ", "RGB", " ", "image_", "\\u\\u\\uNL\\u\\u\\u_", "channels_", "=_", "[_", "self_", "._", "local", "\\u", "image_", "._", "get", "\\u", "image_", "(_", "'", "Red", "'_", ")_", ",_", "self_", "._", "local", "\\u", "image_", "._", "get", "\\u", "image_", "(_", "'", "Green", "'_", ")_", ",_", "self_", "._", "local", "\\u", "image_", "._", "get", "\\u", "image_", "(_", "'", "Blue", "'_", ")_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "channel", "\\u", "images_", "=_", "[_", "PIL_", "._", "Image_", "._", "froma", "rray_", "(_", "numpy_", "._", "uint8_", "(_", "c_", "/_", "SK", "YB", "OX", "\\u", "SCALE_", ")_", ")_", "for_", "c_", "in_", "channels_", "]_", "#", " ", "Convert", " ", "from", " ", "Sky", "box", " ", "range", " ", "to", " ", "8", " ", "bit_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "display", "\\u", "image_", "=_", "PIL_", "._", "Image_", "._", "merge_", "(_", "'", "RGB", "'_", ",_", "channel", "\\u", "images_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "step_", "=_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "show_", "(_", ")_", "\\u\\u\\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, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 ]
Redundant assignment
neuropoly/spinalcordtoolbox/dev/tamag/old/sct_denoising_nlm.py
[ { "content": "def main(file_to_denoise, param, output_file_name) :\n\n path, file, ext = sct.extract_fname(file_to_denoise)\n\n img = nib.load(file_to_denoise)\n hdr_0 = img.get_header()\n\n data = img.get_data()\n aff = img.get_affine()\n\n\n # Process for manual detecting of background\n mask = data[:, :, :] > noise_threshold\n\n data = data[:, :, :]\n\n if '-std' in arguments:\n sigma = std_noise\n # Application of NLM filter to the image\n print 'Applying Non-local mean filter...'\n if param.parameter == 'Rician':\n den = nlmeans(data, sigma=sigma, mask=None, rician=True)\n else : den = nlmeans(data, sigma=sigma, mask=None, rician=False)\n else:\n # # Process for manual detecting of background\n # mask = data[:, :, :] > noise_threshold\n # data = data[:, :, :]\n sigma = np.std(data[~mask])\n\n print(\"vol size\", data.shape)\n\n\n # Application of NLM filter to the image\n print 'Applying Non-local mean filter...'\n if param.parameter == 'Rician':\n den = nlmeans(data, sigma=sigma, mask=mask, rician=True)\n else : den = nlmeans(data, sigma=sigma, mask=mask, rician=False)\n\n t = time()\n print(\"total time\", time() - t)\n print(\"vol size\", den.shape)\n\n\n axial_middle = data.shape[2] / 2\n\n before = data[:, :, axial_middle].T\n after = den[:, :, axial_middle].T\n\n diff_3d = np.absolute(den.astype('f8') - data.astype('f8'))\n difference = np.absolute(after.astype('f8') - before.astype('f8'))\n if '-std' not in arguments:\n difference[~mask[:, :, axial_middle].T] = 0\n\n if param.verbose == 2 :\n fig, ax = plt.subplots(1, 3)\n ax[0].imshow(before, cmap='gray', origin='lower')\n ax[0].set_title('before')\n ax[1].imshow(after, cmap='gray', origin='lower')\n ax[1].set_title('after')\n ax[2].imshow(difference, cmap='gray', origin='lower')\n ax[2].set_title('difference')\n for i in range(3):\n ax[i].set_axis_off()\n\n plt.show()\n plt.savefig('denoised_S0.png', bbox_inches='tight')\n\n #Save files\n img_denoise = nib.Nifti1Image(den, None, hdr_0)\n img_diff = nib.Nifti1Image(diff_3d, None, hdr_0)\n if output_file_name != None :\n output_file_name =output_file_name\n else: output_file_name = file + '_denoised' + ext\n nib.save(img_denoise,output_file_name)\n nib.save(img_diff, file + '_difference' +ext)", "metadata": "root.main", "header": "['module', '___EOS___']", "index": 34 } ]
[ { "span": "output_file_name =output_file_name", "start_line": 105, "start_column": 8, "end_line": 105, "end_column": 42 } ]
[]
1
true
[ "[CLS]_", "Redu", "ndan", "t_", "assignment_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "main_", "(_", "file", "\\u", "to", "\\u", "deno", "ise_", ",_", "param_", ",_", "output", "\\u", "file", "\\u", "name_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "path_", ",_", "file_", ",_", "ext_", "=_", "sct", "_", "._", "extract", "\\u", "fname_", "(_", "file", "\\u", "to", "\\u", "deno", "ise_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "img_", "=_", "nib", "_", "._", "load_", "(_", "file", "\\u", "to", "\\u", "deno", "ise_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "hdr", "\\u", "0_", "=_", "img_", "._", "get", "\\u", "header_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "data_", "=_", "img_", "._", "get", "\\u", "data_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "aff", "_", "=_", "img_", "._", "get", "\\u", "affine_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Process", " ", "for", " ", "manu", "al", " ", "detect", "ing", " ", "of", " ", "background_", "\\u\\u\\uNL\\u\\u\\u_", "mask_", "=_", "data_", "[_", ":_", ",_", ":_", ",_", ":_", "]_", ">_", "noise", "\\u", "threshold_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "data_", "=_", "data_", "[_", ":_", ",_", ":_", ",_", ":_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "'-", "std", "'_", "in_", "arguments_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "sigma_", "=_", "std", "\\u", "noise_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Applica", "tion", " ", "of", " ", "NL", "M", " ", "filter", " ", "to", " ", "the", " ", "image_", "\\u\\u\\uNL\\u\\u\\u_", "print_", "'", "Apply", "ing", " ", "Non", "-", "local", " ", "mean", " ", "filter", "...'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "param_", "._", "parameter_", "==_", "'", "Ric", "ian", "'_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "den_", "=_", "nlm", "ean", "s_", "(_", "data_", ",_", "sigma_", "=_", "sigma_", ",_", "mask_", "=_", "None_", ",_", "ric", "ian_", "=_", "True_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "den_", "=_", "nlm", "ean", "s_", "(_", "data_", ",_", "sigma_", "=_", "sigma_", ",_", "mask_", "=_", "None_", ",_", "ric", "ian_", "=_", "False_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "#", " ", "Process", " ", "for", " ", "manu", "al", " ", "detect", "ing", " ", "of", " ", "background_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "mask", " ", "=", " ", "data", "[:,", " ", ":,", " ", ":]", " ", ">", " ", "noise", "\\u", "threshold_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "data", " ", "=", " ", "data", "[:,", " ", ":,", " ", ":]", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "sigma_", "=_", "np_", "._", "std_", "(_", "data_", "[_", "~_", "mask_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "print_", "(_", "\"", "vol", " ", "size", "\"_", ",_", "data_", "._", "shape_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Applica", "tion", " ", "of", " ", "NL", "M", " ", "filter", " ", "to", " ", "the", " ", "image_", "\\u\\u\\uNL\\u\\u\\u_", "print_", "'", "Apply", "ing", " ", "Non", "-", "local", " ", "mean", " ", "filter", "...'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "param_", "._", "parameter_", "==_", "'", "Ric", "ian", "'_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "den_", "=_", "nlm", "ean", "s_", "(_", "data_", ",_", "sigma_", "=_", "sigma_", ",_", "mask_", "=_", "mask_", ",_", "ric", "ian_", "=_", "True_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "den_", "=_", "nlm", "ean", "s_", "(_", "data_", ",_", "sigma_", "=_", "sigma_", ",_", "mask_", "=_", "mask_", ",_", "ric", "ian_", "=_", "False_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "t_", "=_", "time_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "print_", "(_", "\"", "total", " ", "time", "\"_", ",_", "time_", "(_", ")_", "-_", "t_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "print_", "(_", "\"", "vol", " ", "size", "\"_", ",_", "den_", "._", "shape_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "axi", "al", "\\u", "middle_", "=_", "data_", "._", "shape_", "[_", "2_", "]_", "/_", "2_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "before_", "=_", "data_", "[_", ":_", ",_", ":_", ",_", "axi", "al", "\\u", "middle_", "]_", "._", "T_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "after_", "=_", "den_", "[_", ":_", ",_", ":_", ",_", "axi", "al", "\\u", "middle_", "]_", "._", "T_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "diff", "\\u", "3d_", "=_", "np_", "._", "absolute_", "(_", "den_", "._", "astype_", "(_", "'", "f8", "'_", ")_", "-_", "data_", "._", "astype_", "(_", "'", "f8", "'_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "difference_", "=_", "np_", "._", "absolute_", "(_", "after_", "._", "astype_", "(_", "'", "f8", "'_", ")_", "-_", "before_", "._", "astype_", "(_", "'", "f8", "'_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "'-", "std", "'_", "not_", "in_", "arguments_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "difference_", "[_", "~_", "mask_", "[_", ":_", ",_", ":_", ",_", "axi", "al", "\\u", "middle_", "]_", "._", "T_", "]_", "=_", "0_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "param_", "._", "verbose_", "==_", "2_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "fig_", ",_", "ax_", "=_", "plt_", "._", "subplots_", "(_", "1_", ",_", "3_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "ax_", "[_", "0_", "]_", "._", "imshow_", "(_", "before_", ",_", "cmap_", "=_", "'", "gray", "'_", ",_", "origin_", "=_", "'", "lower", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "ax_", "[_", "0_", "]_", "._", "set\\u", "title_", "(_", "'", "bef", "ore", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "ax_", "[_", "1_", "]_", "._", "imshow_", "(_", "after_", ",_", "cmap_", "=_", "'", "gray", "'_", ",_", "origin_", "=_", "'", "lower", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "ax_", "[_", "1_", "]_", "._", "set\\u", "title_", "(_", "'", "after", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "ax_", "[_", "2_", "]_", "._", "imshow_", "(_", "difference_", ",_", "cmap_", "=_", "'", "gray", "'_", ",_", "origin_", "=_", "'", "lower", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "ax_", "[_", "2_", "]_", "._", "set\\u", "title_", "(_", "'", "difference", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "i_", "in_", "range_", "(_", "3_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "ax_", "[_", "i_", "]_", "._", "set\\u", "axis", "\\u", "off_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "plt_", "._", "show_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "plt_", "._", "savefig_", "(_", "'", "deno", "ise", "d\\u", "S0", ".", "png", "'_", ",_", "bbox", "\\u", "inches_", "=_", "'", "tig", "ht", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", "Save", " ", "files_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "img", "\\u", "deno", "ise_", "=_", "nib", "_", "._", "Ni", "fti", "1", "Image_", "(_", "den_", ",_", "None_", ",_", "hdr", "\\u", "0_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "img", "\\u", "diff_", "=_", "nib", "_", "._", "Ni", "fti", "1", "Image_", "(_", "diff", "\\u", "3d_", ",_", "None_", ",_", "hdr", "\\u", "0_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "output", "\\u", "file", "\\u", "name_", "!=_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "output", "\\u", "file", "\\u", "name_", "=_", "output", "\\u", "file", "\\u", "name_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "output", "\\u", "file", "\\u", "name_", "=_", "file_", "+_", "'\\u", "deno", "ise", "d", "'_", "+_", "ext_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "nib", "_", "._", "save_", "(_", "img", "\\u", "deno", "ise_", ",_", "output", "\\u", "file", "\\u", "name_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "nib", "_", "._", "save_", "(_", "img", "\\u", "diff_", ",_", "file_", "+_", "'\\u", "difference", "'_", "+_", "ext_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_" ]
[ 4, 4, 4, 4, 4, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 ]
First parameter of a method is not named 'self'
snare/voltron/voltron/view.py
[ { "content": " def do_render(error=None):\n pass", "metadata": "root.VoltronView.do_render", "header": "['class', 'VoltronView', '(', 'object', ')', ':', '___EOS___']", "index": 271 } ]
[ { "span": "def do_render(error=None):", "start_line": 271, "start_column": 4, "end_line": 271, "end_column": 30 } ]
[]
1
true
[ "[CLS]_", "First_", "parameter_", "of_", "a_", "method_", "is_", "not_", "named_", "'", "self", "'_", "[SEP]_", "class_", "Volt", "ron", "View_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "do", "\\u", "render_", "(_", "error_", "=_", "None_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "pass_", "\\u\\u\\uNEWLINE\\u\\u\\u_" ]
[ 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2 ]
Unused import
Cimpress-MCP/JustReleaseNotes/JustReleaseNotes/artifacters/versioners/factory.py
[ { "content": "import JustReleaseNotes\nfrom JustReleaseNotes import factory\n", "metadata": "root", "header": "['module', '___EOS___']", "index": 0 }, { "content": "def create(name):\n return JustReleaseNotes.factory.createWithName(\"JustReleaseNotes.artifacters.versioners\", name)", "metadata": "root.create", "header": "['module', '___EOS___']", "index": 3 } ]
[ { "span": "from JustReleaseNotes import factory", "start_line": 1, "start_column": 0, "end_line": 1, "end_column": 36 } ]
[]
1
false
[ "[CLS]_", "Un", "used_", "import_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "import_", "Ju", "st", "Release", "Notes_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "Ju", "st", "Release", "Notes_", "import_", "factory_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "create_", "(_", "name_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "Ju", "st", "Release", "Notes_", "._", "factory_", "._", "create", "With", "Name_", "(_", "\"", "Ju", "st", "Release", "Not", "es", ".", "artifact", "ers", ".", "version", "ers", "\"_", ",_", "name_", ")_" ]
[ 4, 4, 4, 4, 4, 2, 2, 2, 2, 2, 2, 2, 2, 0, 1, 1, 1, 1, 1, 1, 2, 2, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 ]
Unused import
fp7-ofelia/ocf/expedient/src/python/expedient/clearinghouse/project/views.py
[ { "content": "'''\n@author: jnaous\n'''\n\nfrom django.views.generic import list_detail, create_update, simple\nfrom models import Project\nfrom forms import ProjectCreateForm\nfrom django.http import HttpResponseRedirect, HttpResponseNotAllowed, Http404\nfrom django.core.urlresolvers import reverse\nfrom django.core.exceptions import MultipleObjectsReturned\nfrom django.shortcuts import get_object_or_404\nfrom expedient.clearinghouse.aggregate.models import Aggregate\nimport logging\nfrom expedient.common.utils.views import generic_crud\nfrom expedient.common.messaging.models import DatedMessage\nfrom django.db.models import Q\nfrom expedient.common.permissions.decorators import require_objs_permissions_for_view\nfrom expedient.common.permissions.shortcuts import give_permission_to, has_permission, must_have_permission\nfrom expedient.common.permissions.utils import get_queryset, get_user_from_req,\\\n get_queryset_from_class\nfrom expedient.clearinghouse.roles.models import ProjectRole,\\\n ProjectRoleRequest\nfrom expedient.common.permissions.models import ObjectPermission,\\\n PermissionOwnership, Permittee\nfrom expedient.clearinghouse.project.forms import AddMemberForm, MemberForm\nfrom expedient.common.utils.mail import send_mail # Wrapper for django.core.mail__send_mail\nfrom django.contrib.auth.models import User\nfrom django.contrib.contenttypes.models import ContentType\nimport uuid \nfrom django.conf import settings\nfrom django.contrib.auth.models import User\nimport ldap \nfrom django.contrib.sites.models import Site\n\n\nlogger = logging.getLogger(\"project.views\")\n\nTEMPLATE_PATH = \"project\"\n\nDEFAULT_OWNER_PERMISSIONS = [\n \"can_edit_project\", \"can_delete_project\", \"can_view_project\",\n \"can_add_members\", \"can_remove_members\",\n \"can_create_slices\", \"can_edit_slices\", \"can_delete_slices\",\n \"can_start_slices\", \"can_stop_slices\",\n \"can_add_aggregates\", \"can_remove_aggregates\",\n \"can_create_roles\", \"can_edit_roles\",\n]\n\n#DEFAULT_RESEARCHER_PERMISSIONS = [\n# \"can_view_project\",\n# \"can_create_slices\", \"can_edit_slices\", \"can_delete_slices\",\n# \"can_start_slices\", \"can_stop_slices\",\n#]\n\nDEFAULT_RESEARCHER_PERMISSIONS = [\n \"can_view_project\",\n \"can_create_slices\", \"can_edit_slices\", \n \"can_start_slices\", \"can_stop_slices\",\n]\n\n\n\n\n\n\n\n\n \n\n \n\n\n \n \n", "metadata": "root", "header": "['module', '___EOS___']", "index": 0 }, { "content": "def list(request):\n '''Show list of projects'''\n \n qs = Project.objects.get_for_user(request.user).order_by('id')\n \n return list_detail.object_list(\n request,\n queryset=qs,\n template_name=TEMPLATE_PATH+\"/list.html\",\n template_object_name=\"project\",\n )", "metadata": "root.list", "header": "['module', '___EOS___']", "index": 60 }, { "content": "def list_details(request, proj_id):\n\t'''Obtain details (description, slices, users) for a given project'''\n \tproject = get_object_or_404(Project, id=proj_id)\n\treturn simple.direct_to_template(\n\t\trequest,\n\t\ttemplate=TEMPLATE_PATH+\"/list_details.html\",\n\t\textra_context={\"project\": project},\n\t)", "metadata": "root.list_details", "header": "['module', '___EOS___']", "index": 72 }, { "content": "@require_objs_permissions_for_view(\n perm_names=[\"can_delete_slices\"],\n permittee_func=get_user_from_req,\n target_func=get_queryset(Project, \"proj_id\"),\n methods=[\"GET\", \"POST\"],\n)\n@require_objs_permissions_for_view(\n perm_names=[\"can_delete_project\"],\n permittee_func=get_user_from_req,\n target_func=get_queryset(Project, \"proj_id\"),\n methods=[\"GET\", \"POST\"],\n)\ndef delete(request, proj_id):\n '''Delete the project'''\n project = get_object_or_404(Project, id=proj_id)\n if request.method == \"POST\":\n try:\n for s in project.slice_set.all():\n s.stop(request.user)\n project.delete()\n DatedMessage.objects.post_message_to_user(\n \"Successfully deleted project %s\" % project.name,\n request.user, msg_type=DatedMessage.TYPE_SUCCESS)\n except Exception as e:\n if isinstance(e,ldap.LDAPError):\n DatedMessage.objects.post_message_to_user(\n \"Project %s can not be deleted because there is no connection to LDAP\" % project.name,\n request.user, msg_type=DatedMessage.TYPE_ERROR)\n else:\n DatedMessage.objects.post_message_to_user(\n \"Problems ocurred while trying to delete project %s: %s\" % (project.name,str(e)),\n request.user, msg_type=DatedMessage.TYPE_ERROR)\n return HttpResponseRedirect(reverse(\"home\"))\n else:\n from vt_plugin.models.VM import VM\n if VM.objects.filter(projectId = project.uuid):\n DatedMessage.objects.post_message_to_user(\n \"Please delete all VMS inside project '%s' before deleting it\" % project.name,\n request.user, msg_type=DatedMessage.TYPE_ERROR)\n return detail(request, proj_id) \n #return HttpResponseRedirect(reverse(\"home\"))\n return simple.direct_to_template(\n request,\n template=TEMPLATE_PATH+\"/confirm_delete.html\",\n extra_context={\"object\": project},\n )", "metadata": "root.delete", "header": "['module', '___EOS___']", "index": 81 }, { "content": "@require_objs_permissions_for_view(\n perm_names=[\"can_view_project\"],\n permittee_func=get_user_from_req,\n target_func=get_queryset(Project, \"proj_id\"),\n)\ndef detail(request, proj_id):\n '''Show information about the project'''\n project = get_object_or_404(Project, id=proj_id)\n role_reqs = ProjectRoleRequest.objects.filter(\n giver=request.user, requested_role__project=project)\n # Structure with members, ids and roles to pass to project template\n permittees = project.members_as_permittees.all()\n member_roles = dict()\n for permittee in permittees:\n member_roles[str(permittee.object.username)] = {\"id\": str(permittee.object.id), \n\t\t\t\t\t\t\"roles\": permittee.projectrole_set.filter(project__name=project.name)}\n return list_detail.object_detail(\n request,\n Project.objects.all(),\n object_id=proj_id,\n template_name=TEMPLATE_PATH+\"/detail.html\",\n template_object_name=\"project\",\n extra_context={\n \"role_requests\": role_reqs,\n \"member_roles\": member_roles,\n \"breadcrumbs\": (\n (\"Home\", reverse(\"home\")),\n (\"Project %s\" % project.name, reverse(\"project_detail\", args=[project.id])),\n )\n }\n )", "metadata": "root.detail", "header": "['module', '___EOS___']", "index": 128 }, { "content": "def create_project_roles(project, user):\n \"\"\"Create the default roles in a project.\"\"\"\n\n owner_role = ProjectRole.objects.create(\n name=\"owner\",\n description=\\\n \"The 'owner' role is a special role that has permission to \"\n \"do everything \"\n \"in the project and can give the permissions to everyone. \"\n \"In addition every time a slice is created, users with \"\n \"the 'owner' role get full permissions over those.\",\n project=project,\n )\n for permission in DEFAULT_OWNER_PERMISSIONS:\n obj_perm = ObjectPermission.objects.\\\n get_or_create_for_object_or_class(\n permission, project)[0]\n owner_role.obj_permissions.add(obj_perm)\n \n researcher_role = ProjectRole.objects.create(\n name=\"researcher\",\n description=\\\n \"By default users with the 'researcher' role can only \"\n \"create slices and \"\n \"delete slices they created. They have full permissions over \"\n \"their created slices.\",\n project=project,\n )\n for permission in DEFAULT_RESEARCHER_PERMISSIONS:\n obj_perm = ObjectPermission.objects.\\\n get_or_create_for_object_or_class(\n permission, project)[0]\n researcher_role.obj_permissions.add(obj_perm)\n \n # give the creator of the project an owner role\n owner_role.give_to_permittee(\n user,\n can_delegate=True,\n )", "metadata": "root.create_project_roles", "header": "['module', '___EOS___']", "index": 160 }, { "content": "@require_objs_permissions_for_view(\n perm_names=[\"can_create_project\"],\n permittee_func=get_user_from_req,\n target_func=get_queryset_from_class(Project),\n)\ndef create(request):\n '''Create a new project'''\n \n def post_save(instance, created):\n # Create default roles in the project\n\t#Generate UUID: fixes caching problem on model default value\n\tinstance.uuid = uuid.uuid4()\n\tcreate_project_roles(instance, request.user)\n\tinstance.save()\n\t#if settings.LDAP_STORE_PROJECTS:\n\t# instance.sync_netgroup_ldap()\n \n def redirect(instance):\n return reverse(\"project_detail\", args=[instance.id])\n \n try:\n return generic_crud(\n request, None,\n model=Project,\n form_class=ProjectCreateForm,\n template=TEMPLATE_PATH+\"/create_update.html\",\n post_save=post_save,\n redirect=redirect,\n template_object_name=\"project\",\n extra_context={\n \"breadcrumbs\": (\n (\"Home\", reverse(\"home\")),\n (\"Create Project\", request.path),\n ),\n },\n success_msg = lambda instance: \"Successfully created project %s.\" % instance.name,\n )\n except Exception as e:\n if isinstance(e,ldap.LDAPError):\n DatedMessage.objects.post_message_to_user(\n \"Project has been created but only locally since LDAP is not reachable. You will not be able to add users to the project until connection is restored.\",\n request.user, msg_type=DatedMessage.TYPE_ERROR)\n else:\n DatedMessage.objects.post_message_to_user(\n \"Project may have been created, but some problem ocurred: %s\" % str(e),\n request.user, msg_type=DatedMessage.TYPE_ERROR)\n return HttpResponseRedirect(reverse(\"home\"))", "metadata": "root.create", "header": "['module', '___EOS___']", "index": 200 }, { "content": "@require_objs_permissions_for_view(\n perm_names=[\"can_view_project\"],\n permittee_func=get_user_from_req,\n target_func=get_queryset(Project, \"proj_id\"),\n)\n@require_objs_permissions_for_view(\n perm_names=[\"can_edit_project\"],\n permittee_func=get_user_from_req,\n target_func=get_queryset(Project, \"proj_id\"),\n methods=[\"POST\"],\n)\ndef update(request, proj_id, iframe=False):\n '''Update information about a project'''\n \n project = get_object_or_404(Project, id=proj_id)\n must_have_permission(request.user, project, \"can_edit_project\") \n\n def redirect(instance):\n if iframe:\n return reverse(\"project_list\")\n else:\n return reverse(\"project_detail\", args=[instance.id])\n \n return generic_crud(\n request, proj_id,\n model=Project,\n form_class=ProjectCreateForm,\n template=TEMPLATE_PATH+\"/create_update.html\",\n redirect=redirect,\n template_object_name=\"project\",\n extra_context={\n \"breadcrumbs\": (\n (\"Home\", reverse(\"home\")),\n (\"Project %s\" % project.name, reverse(\"project_detail\", args=[project.id])),\n (\"Update Info\", request.path),\n ),\n },\n success_msg = lambda instance: \"Successfully updated project %s.\" % instance.name,\n )", "metadata": "root.update", "header": "['module', '___EOS___']", "index": 250 }, { "content": "@require_objs_permissions_for_view(\n perm_names=[\"can_add_aggregates\"],\n permittee_func=get_user_from_req,\n target_func=get_queryset(Project, \"proj_id\"),\n)\ndef add_aggregate(request, proj_id):\n '''Add/remove aggregates to/from a project'''\n \n project = get_object_or_404(Project, id=proj_id)\n aggregate_list = Aggregate.objects.exclude(\n id__in=project.aggregates.all().values_list(\"id\", flat=True))\n \n if request.method == \"GET\":\n return simple.direct_to_template(\n request, template=TEMPLATE_PATH+\"/add_aggregates.html\",\n extra_context={\n \"aggregate_list\": aggregate_list,\n \"project\": project,\n \"breadcrumbs\": (\n (\"Home\", reverse(\"home\")),\n (\"Project %s\" % project.name, reverse(\"project_detail\", args=[project.id])),\n (\"Add Project Aggregates\", request.path),\n ),\n }\n )\n \n elif request.method == \"POST\":\n # check which submit button was pressed\n try:\n agg_id = int(request.POST.get(\"id\", 0))\n except ValueError:\n raise Http404\n\n if agg_id not in aggregate_list.values_list(\"id\", flat=True):\n raise Http404\n\n aggregate = get_object_or_404(Aggregate, id=agg_id).as_leaf_class()\n\n #Look for the users in the project and give them permission to use the new AM.\n for member in project.members.exclude(is_superuser=True):\n #if not has_permission(member, project, \"can_delete_slices\"):\n give_permission_to(\"can_use_aggregate\", aggregate, member, giver=None, can_delegate=False)\n\n return HttpResponseRedirect(aggregate.add_to_project(\n project, reverse(\"project_add_agg\", args=[proj_id])))\n else:\n return HttpResponseNotAllowed(\"GET\", \"POST\")", "metadata": "root.add_aggregate", "header": "['module', '___EOS___']", "index": 290 }, { "content": "@require_objs_permissions_for_view(\n perm_names=[\"can_add_aggregates\"],\n permittee_func=get_user_from_req,\n target_func=get_queryset(Project, \"proj_id\"),\n)\ndef update_aggregate(request, proj_id, agg_id):\n '''Update any info stored at the aggregate'''\n project = get_object_or_404(Project, id=proj_id)\n aggregate = get_object_or_404(\n Aggregate, id=agg_id, id__in=project.aggregates.values_list(\n \"id\", flat=True)).as_leaf_class()\n\n if request.method == \"POST\":\n return HttpResponseRedirect(aggregate.add_to_project(\n project, reverse(\"project_detail\", args=[proj_id])))\n else:\n return HttpResponseNotAllowed([\"POST\"])", "metadata": "root.update_aggregate", "header": "['module', '___EOS___']", "index": 338 }, { "content": "@require_objs_permissions_for_view(\n perm_names=[\"can_remove_aggregates\"],\n permittee_func=get_user_from_req,\n target_func=get_queryset(Project, \"proj_id\"),\n)\ndef remove_aggregate(request, proj_id, agg_id):\n \"\"\"Remove the aggregate from the project\"\"\"\n project = get_object_or_404(Project, id=proj_id)\n aggregate = get_object_or_404(\n Aggregate, id=agg_id, id__in=project.aggregates.values_list(\n \"id\", flat=True)).as_leaf_class()\n\n if request.method == \"POST\":\n try:\n return HttpResponseRedirect(aggregate.remove_from_project(\n project, reverse(\"project_detail\", args=[proj_id])))\n except MultipleObjectsReturned as e:\n DatedMessage.objects.post_message_to_user(\n str(e), request.user, msg_type=DatedMessage.TYPE_ERROR)\n except:\n pass\n # If any error occurs, redirect to slice detail page\n return HttpResponseRedirect(\n reverse('project_detail', args=[proj_id]))\n else:\n return HttpResponseNotAllowed([\"POST\"])", "metadata": "root.remove_aggregate", "header": "['module', '___EOS___']", "index": 356 }, { "content": "@require_objs_permissions_for_view(\n perm_names=[\"can_add_members\"],\n permittee_func=get_user_from_req,\n target_func=get_queryset(Project, \"proj_id\"),\n)\ndef add_member(request, proj_id):\n \"\"\"Add a member to the project\"\"\"\n \n project = get_object_or_404(Project, id=proj_id)\n \n if request.method == \"POST\":\n form = AddMemberForm(project=project, giver=request.user, data=request.POST)\n if form.is_valid():\n user = User.objects.get(id = request.POST['user'] )\n form.save()\n try:\n #Sync LDAP\n project.save()\n except:\n logger.warning(\"User '%s' may have not been added to project '%s'. It could be a bug within LDAP.\" % (user.username, project.name))\n DatedMessage.objects.post_message_to_user(\n \"User '%s' may not own the requested permissions. It could be a bug within LDAP.\" % user.username,\n request.user, msg_type=DatedMessage.TYPE_ERROR)\n return HttpResponseRedirect(reverse(\"project_detail\", args=[proj_id]))\n #Send mail notification to the user\n roles = ', '.join(repr(role.encode('ascii')) for role in ProjectRole.objects.filter( id__in = request.POST.getlist('roles')).values_list('name', flat=True))\n #XXX: Not sure about this... maybe give_permission_to...\n for aggregate in project._get_aggregates():\n if not has_permission(user, aggregate, \"can_use_aggregate\"):\n aggregate.add_to_user(user,\"/\")\n try:\n # Get project detail URL to send via e-mail\n from expedient.clearinghouse.project import urls\n project_detail_url = reverse(\"project_detail\", args=[project.id]) or \"/\"\n # No \"https://\" check should be needed if settings are OK\n site_domain_url = \"https://\" + Site.objects.get_current().domain + project_detail_url\n send_mail(\n settings.EMAIL_SUBJECT_PREFIX + \"Project %s membership notification\" % (project.name),\n \"You have been added to project '%s' as a user with the following roles: %s.\\nYou may start experimenting now by going to %s\\n\\n\" % (project.name, roles, site_domain_url),\n from_email=settings.DEFAULT_FROM_EMAIL,\n recipient_list=[user.email],\n )\n except Exception as e:\n print \"[WARNING] User e-mail notification could not be sent. Details: %s\" % str(e)\n \n return HttpResponseRedirect(reverse(\"project_detail\", args=[proj_id]))\n\n else:\n form = AddMemberForm(project=project, giver=request.user)\n \n return simple.direct_to_template(\n request,\n template=TEMPLATE_PATH+\"/add_member.html\",\n extra_context={\n \"form\": form,\n \"project\": project,\n \"breadcrumbs\": (\n (\"Home\", reverse(\"home\")),\n (\"Project %s\" % project.name, reverse(\"project_detail\", args=[project.id])),\n (\"Add Member\", request.path),\n ),\n },\n )", "metadata": "root.add_member", "header": "['module', '___EOS___']", "index": 383 }, { "content": "@require_objs_permissions_for_view(\n perm_names=[\"can_add_members\"],\n permittee_func=get_user_from_req,\n target_func=get_queryset(Project, \"proj_id\"),\n)\ndef update_member(request, proj_id, user_id):\n \"\"\"Update a member's roles\"\"\"\n \n project = get_object_or_404(Project, id=proj_id)\n member = get_object_or_404(User, id=user_id)\n \n if request.method == \"POST\":\n form = MemberForm(\n project=project, user=member,\n giver=request.user, data=request.POST)\n \n if form.is_valid():\n form.save()\n return HttpResponseRedirect(\n reverse(\"project_detail\", args=[proj_id]))\n\n else:\n form = MemberForm(\n project=project, user=member,\n giver=request.user)\n \n return simple.direct_to_template(\n request,\n template=TEMPLATE_PATH+\"/update_member.html\",\n extra_context={\n \"form\": form,\n \"project\": project,\n \"member\": member,\n \"breadcrumbs\": (\n (\"Home\", reverse(\"home\")),\n (\"Project %s\" % project.name, reverse(\"project_detail\", args=[project.id])),\n (\"Update Member %s\" % member.username, request.path),\n ),\n },\n )", "metadata": "root.update_member", "header": "['module', '___EOS___']", "index": 447 }, { "content": "@require_objs_permissions_for_view(\n perm_names=[\"can_remove_members\"],\n permittee_func=get_user_from_req,\n target_func=get_queryset(Project, \"proj_id\"),\n)\ndef remove_member(request, proj_id, user_id):\n \"\"\"Kick a member out by stripping his roles\"\"\"\n \n project = get_object_or_404(Project, id=proj_id)\n member = get_object_or_404(User, id=user_id)\n\n if request.method == \"POST\":\n member = Permittee.objects.get_as_permittee(member)\n # Remove the roles\n for role in ProjectRole.objects.filter(project=project):\n role.remove_from_permittee(member)\n # Remove other permissions\n PermissionOwnership.objects.delete_all_for_target(project, member)\n\n #Remove can_use_aggregate if user is not member of any other project using the aggregates of this project\n for projectAgg in project._get_aggregates():\n aggNotUsedAnymoreByMember=1\n for p in Project.objects.exclude(id=project.id):\n if projectAgg in p._get_aggregates() and unicode(member) in p.members.values_list(\"username\", flat=True):\n aggNotUsedAnymoreByMember=0\n break;\n if aggNotUsedAnymoreByMember and not has_permission(member, projectAgg, \"can_use_aggregate\"):\n projectAgg.remove_from_user(member,\"/\")\n\n try:\n #Sync LDAP\n project.save()\n except:\n logger.warning(\"User '%s' may have not been deleted from project '%s'. It could be a bug within LDAP.\" % (member.object.username, project.name))\n\n return HttpResponseRedirect(\n reverse(\"project_detail\", args=[proj_id]))\n \n return simple.direct_to_template(\n request,\n template=TEMPLATE_PATH+\"/remove_member.html\",\n extra_context={\n \"project\": project,\n \"member\": member,\n \"breadcrumbs\": (\n (\"Home\", reverse(\"home\")),\n (\"Project %s\" % project.name, reverse(\"project_detail\", args=[project.id])),\n (\"Remove Member %s\" % member.username, request.path),\n ),\n },\n )", "metadata": "root.remove_member", "header": "['module', '___EOS___']", "index": 488 } ]
[ { "span": "from django.views.generic import list_detail, create_update, simple", "start_line": 4, "start_column": 0, "end_line": 4, "end_column": 67 }, { "span": "from django.db.models import Q", "start_line": 15, "start_column": 0, "end_line": 15, "end_column": 30 }, { "span": "from django.contrib.contenttypes.models import ContentType", "start_line": 27, "start_column": 0, "end_line": 27, "end_column": 58 } ]
[]
1
false
[ "[CLS]_", "Un", "used_", "import_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "'''", "\\", "10", ";", "@", "author", ":", " ", "jn", "ao", "us", "\\", "10", ";'", "''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "from_", "django_", "._", "views_", "._", "generic_", "import_", "list", "\\u", "detail_", ",_", "create", "\\u", "update_", ",_", "simple_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "models_", "import_", "Project_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "forms_", "import_", "Project", "Creat", "e", "Form_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "django_", "._", "http_", "import_", "Http", "Respons", "e", "Redirect_", ",_", "Http", "Respons", "e", "Not", "Allowed_", ",_", "Http404_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "django_", "._", "core_", "._", "urlresolvers_", "import_", "reverse_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "django_", "._", "core_", "._", "exceptions_", "import_", "Multipl", "e", "Object", "s", "Return", "ed_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "django_", "._", "shortcuts_", "import_", "get", "\\u", "object\\u", "or", "\\u", "404_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "expe", "die", "nt_", "._", "clear", "ing", "house_", "._", "aggregate_", "._", "models_", "import_", "Aggregate", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "logging_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "expe", "die", "nt_", "._", "common_", "._", "utils_", "._", "views_", "import_", "gener", "ic", "\\u", "crud", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "expe", "die", "nt_", "._", "common_", "._", "messaging_", "._", "models_", "import_", "Date", "d", "Message_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "django_", "._", "db_", "._", "models_", "import_", "Q_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "expe", "die", "nt_", "._", "common_", "._", "permissions_", "._", "decorators_", "import_", "require", "\\u", "objs", "\\u", "permissi", "ons", "\\u", "for", "\\u", "view_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "expe", "die", "nt_", "._", "common_", "._", "permissions_", "._", "shortcuts_", "import_", "give", "\\u", "permissi", "on", "\\u", "to_", ",_", "has", "\\u", "permission_", ",_", "must", "\\u", "have", "\\u", "permission_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "expe", "die", "nt_", "._", "common_", "._", "permissions_", "._", "utils_", "import_", "get", "\\u", "queryset_", ",_", "get", "\\u", "user", "\\u", "from", "\\u", "req_", ",_", "get", "\\u", "querys", "et", "\\u", "from", "\\u", "class_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "expe", "die", "nt_", "._", "clear", "ing", "house_", "._", "roles_", "._", "models_", "import_", "Project", "Role_", ",_", "Project", "Ro", "le", "Request_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "expe", "die", "nt_", "._", "common_", "._", "permissions_", "._", "models_", "import_", "Object", "Permission_", ",_", "Permi", "ssion", "Owne", "rshi", "p_", ",_", "Permi", "tte", "e_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "expe", "die", "nt_", "._", "clear", "ing", "house_", "._", "project_", "._", "forms_", "import_", "Add", "Mem", "ber", "Form_", ",_", "Mem", "ber", "Form_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "expe", "die", "nt_", "._", "common_", "._", "utils_", "._", "mail_", "import_", "send", "\\u", "mail_", "#", " ", "Wrapper", " ", "for", " ", "django", ".", "core", ".", "mail", "\\u\\u", "send", "\\u", "mail_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "django_", "._", "contrib_", "._", "auth_", "._", "models_", "import_", "User_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "django_", "._", "contrib_", "._", "contenttype", "s_", "._", "models_", "import_", "Conten", "t", "Type_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "uuid_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "django_", "._", "conf_", "import_", "settings_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "django_", "._", "contrib_", "._", "auth_", "._", "models_", "import_", "User_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "ldap_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "django_", "._", "contrib_", "._", "sites_", "._", "models_", "import_", "Site_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "logger_", "=_", "logging_", "._", "get", "Logger_", "(_", "\"", "project", ".", "views", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "TEMPL", "ATE", "\\u", "PATH_", "=_", "\"", "project", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "DEF", "AUL", "T", "\\u", "OWNER", "\\u", "PERMISSION", "S_", "=_", "[_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "can", "\\u", "edit", "\\u", "project", "\"_", ",_", "\"", "can", "\\u", "delete", "\\u", "project", "\"_", ",_", "\"", "can", "\\u", "view", "\\u", "project", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "can", "\\u", "add", "\\u", "member", "s", "\"_", ",_", "\"", "can", "\\u", "remove", "\\u", "member", "s", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "can", "\\u", "create", "\\u", "slice", "s", "\"_", ",_", "\"", "can", "\\u", "edit", "\\u", "slice", "s", "\"_", ",_", "\"", "can", "\\u", "delete", "\\u", "slice", "s", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "can", "\\u", "start", "\\u", "slice", "s", "\"_", ",_", "\"", "can", "\\u", "stop", "\\u", "slice", "s", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "can", "\\u", "add", "\\u", "aggregates", "\"_", ",_", "\"", "can", "\\u", "remove", "\\u", "aggregates", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "can", "\\u", "create", "\\u", "role", "s", "\"_", ",_", "\"", "can", "\\u", "edit", "\\u", "role", "s", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", "DEF", "AUL", "T", "\\u", "RESE", "ARCH", "ER", "\\u", "PERMISSION", "S", " ", "=", " ", "[_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", " ", " ", " ", "\"", "can", "\\u", "view", "\\u", "project", "\",", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", " ", " ", " ", "\"", "can", "\\u", "create", "\\u", "slice", "s", "\",", " ", "\"", "can", "\\u", "edit", "\\u", "slice", "s", "\",", " ", "\"", "can", "\\u", "delete", "\\u", "slice", "s", "\",", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", " ", " ", " ", "\"", "can", "\\u", "start", "\\u", "slice", "s", "\",", " ", "\"", "can", "\\u", "stop", "\\u", "slice", "s", "\",", "_", "\\u\\u\\uNL\\u\\u\\u_", "#]", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "DEF", "AUL", "T", "\\u", "RESE", "ARCH", "ER", "\\u", "PERMISSION", "S_", "=_", "[_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "can", "\\u", "view", "\\u", "project", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "can", "\\u", "create", "\\u", "slice", "s", "\"_", ",_", "\"", "can", "\\u", "edit", "\\u", "slice", "s", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "can", "\\u", "start", "\\u", "slice", "s", "\"_", ",_", "\"", "can", "\\u", "stop", "\\u", "slice", "s", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "list_", "(_", "request_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "'''", "Show", " ", "list", " ", "of", " ", "project", "s", "'''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "qs_", "=_", "Project_", "._", "objects_", "._", "get", "\\u", "for", "\\u", "user_", "(_", "request_", "._", "user_", ")_", "._", "order", "\\u", "by_", "(_", "'", "id", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "return_", "list", "\\u", "detail_", "._", "object\\u", "list_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "request_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "queryset_", "=_", "qs_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "template", "\\u", "name_", "=_", "TEMPL", "ATE", "\\u", "PATH_", "+_", "\"/", "list", ".", "html", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "template", "\\u", "object\\u", "name_", "=_", "\"", "project", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "list", "\\u", "details_", "(_", "request_", ",_", "proj", "\\u", "id_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "_", "'''", "Obtain", " ", "deta", "il", "s", " ", "(", "description", ",", " ", "slice", "s", ",", " ", "users", ")", " ", "for", " ", "a", " ", "give", "n", " ", "project", "'''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "project_", "=_", "get", "\\u", "object\\u", "or", "\\u", "404_", "(_", "Project_", ",_", "id_", "=_", "proj", "\\u", "id_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "simple_", "._", "direct", "\\u", "to", "\\u", "template_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "request_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "template_", "=_", "TEMPL", "ATE", "\\u", "PATH_", "+_", "\"/", "list", "\\u", "deta", "il", "s", ".", "html", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "extra", "\\u", "context_", "=_", "{_", "\"", "project", "\"_", ":_", "project_", "}_", ",_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "@_", "require", "\\u", "objs", "\\u", "permissi", "ons", "\\u", "for", "\\u", "view_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "perm", "\\u", "names_", "=_", "[_", "\"", "can", "\\u", "delete", "\\u", "slice", "s", "\"_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "permit", "tee", "\\u", "func_", "=_", "get", "\\u", "user", "\\u", "from", "\\u", "req_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "target", "\\u", "func_", "=_", "get", "\\u", "queryset_", "(_", "Project_", ",_", "\"", "proj", "\\u", "id", "\"_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "methods_", "=_", "[_", "\"", "GET", "\"_", ",_", "\"", "POST", "\"_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "@_", "require", "\\u", "objs", "\\u", "permissi", "ons", "\\u", "for", "\\u", "view_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "perm", "\\u", "names_", "=_", "[_", "\"", "can", "\\u", "delete", "\\u", "project", "\"_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "permit", "tee", "\\u", "func_", "=_", "get", "\\u", "user", "\\u", "from", "\\u", "req_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "target", "\\u", "func_", "=_", "get", "\\u", "queryset_", "(_", "Project_", ",_", "\"", "proj", "\\u", "id", "\"_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "methods_", "=_", "[_", "\"", "GET", "\"_", ",_", "\"", "POST", "\"_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "delete_", "(_", "request_", ",_", "proj", "\\u", "id_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "'''", "Delete", " ", "the", " ", "project", "'''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "project_", "=_", "get", "\\u", "object\\u", "or", "\\u", "404_", "(_", "Project_", ",_", "id_", "=_", "proj", "\\u", "id_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "request_", "._", "method_", "==_", "\"", "POST", "\"_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "for_", "s_", "in_", "project_", "._", "slice", "\\u", "set_", "._", "all_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "s_", "._", "stop_", "(_", "request_", "._", "user_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "project_", "._", "delete_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "Date", "d", "Message_", "._", "objects_", "._", "post", "\\u", "message", "\\u", "to", "\\u", "user_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "Success", "full", "y", " ", "delete", "d", " ", "project", " ", "%", "s", "\"_", "%_", "project_", "._", "name_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "request_", "._", "user_", ",_", "msg", "\\u", "type_", "=_", "Date", "d", "Message_", "._", "TYPE", "\\u", "SUCCESS_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "Exception_", "as_", "e_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "isinstance_", "(_", "e_", ",_", "ldap_", "._", "LDA", "PE", "rror_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "Date", "d", "Message_", "._", "objects_", "._", "post", "\\u", "message", "\\u", "to", "\\u", "user_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "Project", " ", "%", "s", " ", "can", " ", "not", " ", "be", " ", "delete", "d", " ", "bec", "aus", "e", " ", "there", " ", "is", " ", "no", " ", "connecti", "on", " ", "to", " ", "LDA", "P", "\"_", "%_", "project_", "._", "name_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "request_", "._", "user_", ",_", "msg", "\\u", "type_", "=_", "Date", "d", "Message_", "._", "TYPE", "\\u", "ERROR_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "Date", "d", "Message_", "._", "objects_", "._", "post", "\\u", "message", "\\u", "to", "\\u", "user_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "Problems", " ", "ocu", "rre", "d", " ", "whi", "le", " ", "try", "ing", " ", "to", " ", "delete", " ", "project", " ", "%", "s", ":", " ", "%", "s", "\"_", "%_", "(_", "project_", "._", "name_", ",_", "str_", "(_", "e_", ")_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "request_", "._", "user_", ",_", "msg", "\\u", "type_", "=_", "Date", "d", "Message_", "._", "TYPE", "\\u", "ERROR_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "Http", "Respons", "e", "Redirect_", "(_", "reverse_", "(_", "\"", "home", "\"_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "from_", "vt", "\\u", "plugin_", "._", "models_", "._", "VM_", "import_", "VM_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "VM_", "._", "objects_", "._", "filter_", "(_", "project", "Id_", "=_", "project_", "._", "uuid_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "Date", "d", "Message_", "._", "objects_", "._", "post", "\\u", "message", "\\u", "to", "\\u", "user_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "Ple", "ase", " ", "delete", " ", "all", " ", "VM", "S", " ", "insi", "de", " ", "project", " ", "'%", "s", "'", " ", "bef", "ore", " ", "delet", "ing", " ", "it", "\"_", "%_", "project_", "._", "name_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "request_", "._", "user_", ",_", "msg", "\\u", "type_", "=_", "Date", "d", "Message_", "._", "TYPE", "\\u", "ERROR_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "detail_", "(_", "request_", ",_", "proj", "\\u", "id_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", "return", " ", "Http", "Respons", "e", "Redirect", "(", "reverse", "(\"", "home", "\"))", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "simple_", "._", "direct", "\\u", "to", "\\u", "template_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "request_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "template_", "=_", "TEMPL", "ATE", "\\u", "PATH_", "+_", "\"/", "confirm", "\\u", "delete", ".", "html", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "extra", "\\u", "context_", "=_", "{_", "\"", "object", "\"_", ":_", "project_", "}_", ",_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "@_", "require", "\\u", "objs", "\\u", "permissi", "ons", "\\u", "for", "\\u", "view_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "perm", "\\u", "names_", "=_", "[_", "\"", "can", "\\u", "view", "\\u", "project", "\"_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "permit", "tee", "\\u", "func_", "=_", "get", "\\u", "user", "\\u", "from", "\\u", "req_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "target", "\\u", "func_", "=_", "get", "\\u", "queryset_", "(_", "Project_", ",_", "\"", "proj", "\\u", "id", "\"_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "detail_", "(_", "request_", ",_", "proj", "\\u", "id_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "'''", "Show", " ", "informati", "on", " ", "abo", "ut", " ", "the", " ", "project", "'''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "project_", "=_", "get", "\\u", "object\\u", "or", "\\u", "404_", "(_", "Project_", ",_", "id_", "=_", "proj", "\\u", "id_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "role", "\\u", "reqs_", "=_", "Project", "Ro", "le", "Request_", "._", "objects_", "._", "filter_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "give", "r_", "=_", "request_", "._", "user_", ",_", "request", "ed", "\\u", "role", "\\u\\u", "project_", "=_", "project_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Structur", "e", " ", "with", " ", "member", "s", ",", " ", "ids", " ", "and", " ", "role", "s", " ", "to", " ", "pass", " ", "to", " ", "project", " ", "template_", "\\u\\u\\uNL\\u\\u\\u_", "permit", "tee", "s_", "=_", "project_", "._", "member", "s", "\\u", "as", "\\u", "permit", "tee", "s_", "._", "all_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "member", "\\u", "roles_", "=_", "dict_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "permit", "tee", "_", "in_", "permit", "tee", "s_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "member", "\\u", "roles_", "[_", "str_", "(_", "permit", "tee", "_", "._", "object_", "._", "username_", ")_", "]_", "=_", "{_", "\"", "id", "\"_", ":_", "str_", "(_", "permit", "tee", "_", "._", "object_", "._", "id_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "role", "s", "\"_", ":_", "permit", "tee", "_", "._", "project", "role", "\\u", "set_", "._", "filter_", "(_", "project", "\\u\\u", "name_", "=_", "project_", "._", "name_", ")_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "list", "\\u", "detail_", "._", "object\\u", "detail_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "request_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "Project_", "._", "objects_", "._", "all_", "(_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "object\\u", "id_", "=_", "proj", "\\u", "id_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "template", "\\u", "name_", "=_", "TEMPL", "ATE", "\\u", "PATH_", "+_", "\"/", "deta", "il", ".", "html", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "template", "\\u", "object\\u", "name_", "=_", "\"", "project", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "extra", "\\u", "context_", "=_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "role", "\\u", "request", "s", "\"_", ":_", "role", "\\u", "reqs_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "member", "\\u", "role", "s", "\"_", ":_", "member", "\\u", "roles_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "breadcrumb", "s", "\"_", ":_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "\"", "Home", "\"_", ",_", "reverse_", "(_", "\"", "home", "\"_", ")_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "\"", "Project", " ", "%", "s", "\"_", "%_", "project_", "._", "name_", ",_", "reverse_", "(_", "\"", "project", "\\u", "deta", "il", "\"_", ",_", "args_", "=_", "[_", "project_", "._", "id_", "]_", ")_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNL\\u\\u\\u_", "}_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "create", "\\u", "project", "\\u", "roles_", "(_", "project_", ",_", "user_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "Creat", "e", " ", "the", " ", "default", " ", "role", "s", " ", "in", " ", "a", " ", "project", ".\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "owner", "\\u", "role_", "=_", "Project", "Role_", "._", "objects_", "._", "create_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "name_", "=_", "\"", "owner", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "description_", "=_", "\"", "The", " ", "'", "owner", "'", " ", "role", " ", "is", " ", "a", " ", "special", " ", "role", " ", "tha", "t", " ", "has", " ", "permissi", "on", " ", "to", " ", "\"_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "do", " ", "every", "thing", " ", "\"_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "in", " ", "the", " ", "project", " ", "and", " ", "can", " ", "give", " ", "the", " ", "permissi", "ons", " ", "to", " ", "everyone", ".", " ", "\"_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "In", " ", "addition", " ", "every", " ", "time", " ", "a", " ", "slice", " ", "is", " ", "created", ",", " ", "users", " ", "with", " ", "\"_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "the", " ", "'", "owner", "'", " ", "role", " ", "get", " ", "full", " ", "permissi", "ons", " ", "over", " ", "tho", "se", ".\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "project_", "=_", "project_", ",_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "permission_", "in_", "DEF", "AUL", "T", "\\u", "OWNER", "\\u", "PERMISSION", "S_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "obj", "\\u", "perm_", "=_", "Object", "Permission_", "._", "objects_", "._", "get", "\\u", "or", "\\u", "create", "\\u", "for", "\\u", "object\\u", "or", "\\u", "class_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "permission_", ",_", "project_", ")_", "[_", "0_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "owner", "\\u", "role_", "._", "obj", "\\u", "permissions_", "._", "add_", "(_", "obj", "\\u", "perm_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "research", "er", "\\u", "role_", "=_", "Project", "Role_", "._", "objects_", "._", "create_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "name_", "=_", "\"", "research", "er", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "description_", "=_", "\"", "By", " ", "default", " ", "users", " ", "with", " ", "the", " ", "'", "research", "er", "'", " ", "role", " ", "can", " ", "only", " ", "\"_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "create", " ", "slice", "s", " ", "and", " ", "\"_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "delete", " ", "slice", "s", " ", "the", "y", " ", "created", ".", " ", "The", "y", " ", "have", " ", "full", " ", "permissi", "ons", " ", "over", " ", "\"_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "thei", "r", " ", "created", " ", "slice", "s", ".\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "project_", "=_", "project_", ",_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "permission_", "in_", "DEF", "AUL", "T", "\\u", "RESE", "ARCH", "ER", "\\u", "PERMISSION", "S_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "obj", "\\u", "perm_", "=_", "Object", "Permission_", "._", "objects_", "._", "get", "\\u", "or", "\\u", "create", "\\u", "for", "\\u", "object\\u", "or", "\\u", "class_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "permission_", ",_", "project_", ")_", "[_", "0_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "research", "er", "\\u", "role_", "._", "obj", "\\u", "permissions_", "._", "add_", "(_", "obj", "\\u", "perm_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "give", " ", "the", " ", "creat", "or", " ", "of", " ", "the", " ", "project", " ", "an", " ", "owner", " ", "role_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "owner", "\\u", "role_", "._", "give", "\\u", "to", "\\u", "permit", "tee", "_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "user_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "can", "\\u", "delegate_", "=_", "True_", ",_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "@_", "require", "\\u", "objs", "\\u", "permissi", "ons", "\\u", "for", "\\u", "view_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "perm", "\\u", "names_", "=_", "[_", "\"", "can", "\\u", "create", "\\u", "project", "\"_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "permit", "tee", "\\u", "func_", "=_", "get", "\\u", "user", "\\u", "from", "\\u", "req_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "target", "\\u", "func_", "=_", "get", "\\u", "querys", "et", "\\u", "from", "\\u", "class_", "(_", "Project_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "create_", "(_", "request_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "'''", "Creat", "e", " ", "a", " ", "new", " ", "project", "'''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "post", "\\u", "save_", "(_", "instance_", ",_", "created_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Creat", "e", " ", "default", " ", "role", "s", " ", "in", " ", "the", " ", "project_", "\\u\\u\\uNL\\u\\u\\u_", "#", "Generate", " ", "UU", "ID", ":", " ", "fixes", " ", "caching", " ", "problem", " ", "on", " ", "model", " ", "default", " ", "value_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "_", "instance_", "._", "uuid_", "=_", "uuid_", "._", "uuid4_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "create", "\\u", "project", "\\u", "roles_", "(_", "instance_", ",_", "request_", "._", "user_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "instance_", "._", "save_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", "if", " ", "settings", ".", "LDA", "P", "\\u", "STORE", "\\u", "PROJECT", "S", ":_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", " ", " ", " ", "instance", ".", "sync", "\\u", "net", "group", "\\u", "ldap", "()", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "redirect_", "(_", "instance_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "reverse_", "(_", "\"", "project", "\\u", "deta", "il", "\"_", ",_", "args_", "=_", "[_", "instance_", "._", "id_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "gener", "ic", "\\u", "crud", "_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "request_", ",_", "None_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "model_", "=_", "Project_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "form", "\\u", "class_", "=_", "Project", "Creat", "e", "Form_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "template_", "=_", "TEMPL", "ATE", "\\u", "PATH_", "+_", "\"/", "create", "\\u", "update", ".", "html", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "post", "\\u", "save_", "=_", "post", "\\u", "save_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "redirect_", "=_", "redirect_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "template", "\\u", "object\\u", "name_", "=_", "\"", "project", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "extra", "\\u", "context_", "=_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "breadcrumb", "s", "\"_", ":_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "\"", "Home", "\"_", ",_", "reverse_", "(_", "\"", "home", "\"_", ")_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "\"", "Creat", "e", " ", "Project", "\"_", ",_", "request_", "._", "path_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "}_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "success", "\\u", "msg_", "=_", "lambda_", "instance_", ":_", "\"", "Success", "full", "y", " ", "created", " ", "project", " ", "%", "s", ".\"_", "%_", "instance_", "._", "name_", ",_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "Exception_", "as_", "e_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "isinstance_", "(_", "e_", ",_", "ldap_", "._", "LDA", "PE", "rror_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "Date", "d", "Message_", "._", "objects_", "._", "post", "\\u", "message", "\\u", "to", "\\u", "user_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "Project", " ", "has", " ", "bee", "n", " ", "created", " ", "but", " ", "only", " ", "local", "ly", " ", "sinc", "e", " ", "LDA", "P", " ", "is", " ", "not", " ", "reachable", ".", " ", "You", " ", "will", " ", "not", " ", "be", " ", "able", " ", "to", " ", "add", " ", "users", " ", "to", " ", "the", " ", "project", " ", "unti", "l", " ", "connecti", "on", " ", "is", " ", "restore", "d", ".\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "request_", "._", "user_", ",_", "msg", "\\u", "type_", "=_", "Date", "d", "Message_", "._", "TYPE", "\\u", "ERROR_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "Date", "d", "Message_", "._", "objects_", "._", "post", "\\u", "message", "\\u", "to", "\\u", "user_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "Project", " ", "may", " ", "have", " ", "bee", "n", " ", "created", ",", " ", "but", " ", "some", " ", "problem", " ", "ocu", "rre", "d", ":", " ", "%", "s", "\"_", "%_", "str_", "(_", "e_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "request_", "._", "user_", ",_", "msg", "\\u", "type_", "=_", "Date", "d", "Message_", "._", "TYPE", "\\u", "ERROR_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "Http", "Respons", "e", "Redirect_", "(_", "reverse_", "(_", "\"", "home", "\"_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "@_", "require", "\\u", "objs", "\\u", "permissi", "ons", "\\u", "for", "\\u", "view_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "perm", "\\u", "names_", "=_", "[_", "\"", "can", "\\u", "view", "\\u", "project", "\"_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "permit", "tee", "\\u", "func_", "=_", "get", "\\u", "user", "\\u", "from", "\\u", "req_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "target", "\\u", "func_", "=_", "get", "\\u", "queryset_", "(_", "Project_", ",_", "\"", "proj", "\\u", "id", "\"_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "@_", "require", "\\u", "objs", "\\u", "permissi", "ons", "\\u", "for", "\\u", "view_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "perm", "\\u", "names_", "=_", "[_", "\"", "can", "\\u", "edit", "\\u", "project", "\"_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "permit", "tee", "\\u", "func_", "=_", "get", "\\u", "user", "\\u", "from", "\\u", "req_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "target", "\\u", "func_", "=_", "get", "\\u", "queryset_", "(_", "Project_", ",_", "\"", "proj", "\\u", "id", "\"_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "methods_", "=_", "[_", "\"", "POST", "\"_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "update_", "(_", "request_", ",_", "proj", "\\u", "id_", ",_", "iframe", "_", "=_", "False_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "'''", "Update", " ", "informati", "on", " ", "abo", "ut", " ", "a", " ", "project", "'''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "project_", "=_", "get", "\\u", "object\\u", "or", "\\u", "404_", "(_", "Project_", ",_", "id_", "=_", "proj", "\\u", "id_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "must", "\\u", "have", "\\u", "permission_", "(_", "request_", "._", "user_", ",_", "project_", ",_", "\"", "can", "\\u", "edit", "\\u", "project", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "redirect_", "(_", "instance_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "iframe", "_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "reverse_", "(_", "\"", "project", "\\u", "list", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "reverse_", "(_", "\"", "project", "\\u", "deta", "il", "\"_", ",_", "args_", "=_", "[_", "instance_", "._", "id_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "gener", "ic", "\\u", "crud", "_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "request_", ",_", "proj", "\\u", "id_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "model_", "=_", "Project_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "form", "\\u", "class_", "=_", "Project", "Creat", "e", "Form_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "template_", "=_", "TEMPL", "ATE", "\\u", "PATH_", "+_", "\"/", "create", "\\u", "update", ".", "html", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "redirect_", "=_", "redirect_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "template", "\\u", "object\\u", "name_", "=_", "\"", "project", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "extra", "\\u", "context_", "=_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "breadcrumb", "s", "\"_", ":_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "\"", "Home", "\"_", ",_", "reverse_", "(_", "\"", "home", "\"_", ")_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "\"", "Project", " ", "%", "s", "\"_", "%_", "project_", "._", "name_", ",_", "reverse_", "(_", "\"", "project", "\\u", "deta", "il", "\"_", ",_", "args_", "=_", "[_", "project_", "._", "id_", "]_", ")_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "\"", "Update", " ", "Info", "\"_", ",_", "request_", "._", "path_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "}_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "success", "\\u", "msg_", "=_", "lambda_", "instance_", ":_", "\"", "Success", "full", "y", " ", "update", "d", " ", "project", " ", "%", "s", ".\"_", "%_", "instance_", "._", "name_", ",_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "@_", "require", "\\u", "objs", "\\u", "permissi", "ons", "\\u", "for", "\\u", "view_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "perm", "\\u", "names_", "=_", "[_", "\"", "can", "\\u", "add", "\\u", "aggregates", "\"_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "permit", "tee", "\\u", "func_", "=_", "get", "\\u", "user", "\\u", "from", "\\u", "req_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "target", "\\u", "func_", "=_", "get", "\\u", "queryset_", "(_", "Project_", ",_", "\"", "proj", "\\u", "id", "\"_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "add", "\\u", "aggregate_", "(_", "request_", ",_", "proj", "\\u", "id_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "'''", "Add", "/", "remove", " ", "aggregates", " ", "to", "/", "from", " ", "a", " ", "project", "'''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "project_", "=_", "get", "\\u", "object\\u", "or", "\\u", "404_", "(_", "Project_", ",_", "id_", "=_", "proj", "\\u", "id_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "aggre", "gate", "\\u", "list_", "=_", "Aggregate", "_", "._", "objects_", "._", "exclude_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "id", "\\u\\u", "in_", "=_", "project_", "._", "aggregates", "_", "._", "all_", "(_", ")_", "._", "values", "\\u", "list_", "(_", "\"", "id", "\"_", ",_", "flat_", "=_", "True_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "request_", "._", "method_", "==_", "\"", "GET", "\"_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "simple_", "._", "direct", "\\u", "to", "\\u", "template_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "request_", ",_", "template_", "=_", "TEMPL", "ATE", "\\u", "PATH_", "+_", "\"/", "add", "\\u", "aggregates", ".", "html", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "extra", "\\u", "context_", "=_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "aggre", "gate", "\\u", "list", "\"_", ":_", "aggre", "gate", "\\u", "list_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "project", "\"_", ":_", "project_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "breadcrumb", "s", "\"_", ":_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "\"", "Home", "\"_", ",_", "reverse_", "(_", "\"", "home", "\"_", ")_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "\"", "Project", " ", "%", "s", "\"_", "%_", "project_", "._", "name_", ",_", "reverse_", "(_", "\"", "project", "\\u", "deta", "il", "\"_", ",_", "args_", "=_", "[_", "project_", "._", "id_", "]_", ")_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "\"", "Add", " ", "Project", " ", "Aggregate", "s", "\"_", ",_", "request_", "._", "path_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "}_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "request_", "._", "method_", "==_", "\"", "POST", "\"_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "check", " ", "whi", "ch", " ", "submit", " ", "button", " ", "was", " ", "pressed_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "agg", "\\u", "id_", "=_", "int_", "(_", "request_", "._", "POST_", "._", "get_", "(_", "\"", "id", "\"_", ",_", "0_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "Value", "Error_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "raise_", "Http404_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "agg", "\\u", "id_", "not_", "in_", "aggre", "gate", "\\u", "list_", "._", "values", "\\u", "list_", "(_", "\"", "id", "\"_", ",_", "flat_", "=_", "True_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "raise_", "Http404_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "aggregate_", "=_", "get", "\\u", "object\\u", "or", "\\u", "404_", "(_", "Aggregate", "_", ",_", "id_", "=_", "agg", "\\u", "id_", ")_", "._", "as", "\\u", "leaf", "\\u", "class_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", "Look", " ", "for", " ", "the", " ", "users", " ", "in", " ", "the", " ", "project", " ", "and", " ", "give", " ", "them", " ", "permissi", "on", " ", "to", " ", "use", " ", "the", " ", "new", " ", "AM", "._", "\\u\\u\\uNL\\u\\u\\u_", "for_", "member_", "in_", "project_", "._", "members_", "._", "exclude_", "(_", "is", "\\u", "superuser_", "=_", "True_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", "if", " ", "not", " ", "has", "\\u", "permissi", "on", "(", "member", ",", " ", "project", ",", " ", "\"", "can", "\\u", "delete", "\\u", "slice", "s", "\"):", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "give", "\\u", "permissi", "on", "\\u", "to_", "(_", "\"", "can", "\\u", "use", "\\u", "aggre", "gate", "\"_", ",_", "aggregate_", ",_", "member_", ",_", "give", "r_", "=_", "None_", ",_", "can", "\\u", "delegate_", "=_", "False_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "Http", "Respons", "e", "Redirect_", "(_", "aggregate_", "._", "add", "\\u", "to", "\\u", "project_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "project_", ",_", "reverse_", "(_", "\"", "project", "\\u", "add", "\\u", "agg", "\"_", ",_", "args_", "=_", "[_", "proj", "\\u", "id_", "]_", ")_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "Http", "Respons", "e", "Not", "Allowed_", "(_", "\"", "GET", "\"_", ",_", "\"", "POST", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "@_", "require", "\\u", "objs", "\\u", "permissi", "ons", "\\u", "for", "\\u", "view_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "perm", "\\u", "names_", "=_", "[_", "\"", "can", "\\u", "add", "\\u", "aggregates", "\"_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "permit", "tee", "\\u", "func_", "=_", "get", "\\u", "user", "\\u", "from", "\\u", "req_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "target", "\\u", "func_", "=_", "get", "\\u", "queryset_", "(_", "Project_", ",_", "\"", "proj", "\\u", "id", "\"_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "update", "\\u", "aggregate_", "(_", "request_", ",_", "proj", "\\u", "id_", ",_", "agg", "\\u", "id_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "'''", "Update", " ", "any", " ", "info", " ", "store", "d", " ", "at", " ", "the", " ", "aggre", "gate", "'''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "project_", "=_", "get", "\\u", "object\\u", "or", "\\u", "404_", "(_", "Project_", ",_", "id_", "=_", "proj", "\\u", "id_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "aggregate_", "=_", "get", "\\u", "object\\u", "or", "\\u", "404_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "Aggregate", "_", ",_", "id_", "=_", "agg", "\\u", "id_", ",_", "id", "\\u\\u", "in_", "=_", "project_", "._", "aggregates", "_", "._", "values", "\\u", "list_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "id", "\"_", ",_", "flat_", "=_", "True_", ")_", ")_", "._", "as", "\\u", "leaf", "\\u", "class_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "request_", "._", "method_", "==_", "\"", "POST", "\"_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "Http", "Respons", "e", "Redirect_", "(_", "aggregate_", "._", "add", "\\u", "to", "\\u", "project_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "project_", ",_", "reverse_", "(_", "\"", "project", "\\u", "deta", "il", "\"_", ",_", "args_", "=_", "[_", "proj", "\\u", "id_", "]_", ")_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "Http", "Respons", "e", "Not", "Allowed_", "(_", "[_", "\"", "POST", "\"_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "@_", "require", "\\u", "objs", "\\u", "permissi", "ons", "\\u", "for", "\\u", "view_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "perm", "\\u", "names_", "=_", "[_", "\"", "can", "\\u", "remove", "\\u", "aggregates", "\"_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "permit", "tee", "\\u", "func_", "=_", "get", "\\u", "user", "\\u", "from", "\\u", "req_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "target", "\\u", "func_", "=_", "get", "\\u", "queryset_", "(_", "Project_", ",_", "\"", "proj", "\\u", "id", "\"_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "remove", "\\u", "aggregate_", "(_", "request_", ",_", "proj", "\\u", "id_", ",_", "agg", "\\u", "id_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "Remove", " ", "the", " ", "aggre", "gate", " ", "from", " ", "the", " ", "project", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "project_", "=_", "get", "\\u", "object\\u", "or", "\\u", "404_", "(_", "Project_", ",_", "id_", "=_", "proj", "\\u", "id_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "aggregate_", "=_", "get", "\\u", "object\\u", "or", "\\u", "404_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "Aggregate", "_", ",_", "id_", "=_", "agg", "\\u", "id_", ",_", "id", "\\u\\u", "in_", "=_", "project_", "._", "aggregates", "_", "._", "values", "\\u", "list_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "id", "\"_", ",_", "flat_", "=_", "True_", ")_", ")_", "._", "as", "\\u", "leaf", "\\u", "class_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "request_", "._", "method_", "==_", "\"", "POST", "\"_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "Http", "Respons", "e", "Redirect_", "(_", "aggregate_", "._", "remove", "\\u", "from", "\\u", "project_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "project_", ",_", "reverse_", "(_", "\"", "project", "\\u", "deta", "il", "\"_", ",_", "args_", "=_", "[_", "proj", "\\u", "id_", "]_", ")_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "Multipl", "e", "Object", "s", "Return", "ed_", "as_", "e_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "Date", "d", "Message_", "._", "objects_", "._", "post", "\\u", "message", "\\u", "to", "\\u", "user_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "str_", "(_", "e_", ")_", ",_", "request_", "._", "user_", ",_", "msg", "\\u", "type_", "=_", "Date", "d", "Message_", "._", "TYPE", "\\u", "ERROR_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "pass_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "If", " ", "any", " ", "error", " ", "occur", "s", ",", " ", "redirec", "t", " ", "to", " ", "slice", " ", "deta", "il", " ", "page_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "Http", "Respons", "e", "Redirect_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "reverse_", "(_", "'", "project", "\\u", "deta", "il", "'_", ",_", "args_", "=_", "[_", "proj", "\\u", "id_", "]_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "Http", "Respons", "e", "Not", "Allowed_", "(_", "[_", "\"", "POST", "\"_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "@_", "require", "\\u", "objs", "\\u", "permissi", "ons", "\\u", "for", "\\u", "view_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "perm", "\\u", "names_", "=_", "[_", "\"", "can", "\\u", "add", "\\u", "member", "s", "\"_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "permit", "tee", "\\u", "func_", "=_", "get", "\\u", "user", "\\u", "from", "\\u", "req_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "target", "\\u", "func_", "=_", "get", "\\u", "queryset_", "(_", "Project_", ",_", "\"", "proj", "\\u", "id", "\"_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "add", "\\u", "member_", "(_", "request_", ",_", "proj", "\\u", "id_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "Add", " ", "a", " ", "member", " ", "to", " ", "the", " ", "project", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "project_", "=_", "get", "\\u", "object\\u", "or", "\\u", "404_", "(_", "Project_", ",_", "id_", "=_", "proj", "\\u", "id_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "request_", "._", "method_", "==_", "\"", "POST", "\"_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "form_", "=_", "Add", "Mem", "ber", "Form_", "(_", "project_", "=_", "project_", ",_", "give", "r_", "=_", "request_", "._", "user_", ",_", "data_", "=_", "request_", "._", "POST_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "form_", "._", "is", "\\u", "valid_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "user_", "=_", "User_", "._", "objects_", "._", "get_", "(_", "id_", "=_", "request_", "._", "POST_", "[_", "'", "user", "'_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "form_", "._", "save_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", "Sync", " ", "LDA", "P_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "project_", "._", "save_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "logger_", "._", "warning_", "(_", "\"", "User", " ", "'%", "s", "'", " ", "may", " ", "have", " ", "not", " ", "bee", "n", " ", "adde", "d", " ", "to", " ", "project", " ", "'%", "s", "'.", " ", "It", " ", "coul", "d", " ", "be", " ", "a", " ", "bug", " ", "within", " ", "LDA", "P", ".\"_", "%_", "(_", "user_", "._", "username_", ",_", "project_", "._", "name_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "Date", "d", "Message_", "._", "objects_", "._", "post", "\\u", "message", "\\u", "to", "\\u", "user_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "User", " ", "'%", "s", "'", " ", "may", " ", "not", " ", "own", " ", "the", " ", "request", "ed", " ", "permissi", "ons", ".", " ", "It", " ", "coul", "d", " ", "be", " ", "a", " ", "bug", " ", "within", " ", "LDA", "P", ".\"_", "%_", "user_", "._", "username_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "request_", "._", "user_", ",_", "msg", "\\u", "type_", "=_", "Date", "d", "Message_", "._", "TYPE", "\\u", "ERROR_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "Http", "Respons", "e", "Redirect_", "(_", "reverse_", "(_", "\"", "project", "\\u", "deta", "il", "\"_", ",_", "args_", "=_", "[_", "proj", "\\u", "id_", "]_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", "Sen", "d", " ", "mail", " ", "notification", " ", "to", " ", "the", " ", "user_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "roles_", "=_", "',", " ", "'_", "._", "join_", "(_", "repr_", "(_", "role_", "._", "encode_", "(_", "'", "ascii", "'_", ")_", ")_", "for_", "role_", "in_", "Project", "Role_", "._", "objects_", "._", "filter_", "(_", "id", "\\u\\u", "in_", "=_", "request_", "._", "POST_", "._", "getlist_", "(_", "'", "role", "s", "'_", ")_", ")_", "._", "values", "\\u", "list_", "(_", "'", "name", "'_", ",_", "flat_", "=_", "True_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", "XX", "X", ":", " ", "Not", " ", "sure", " ", "abo", "ut", " ", "this", "...", " ", " ", "may", "be", " ", " ", "give", "\\u", "permissi", "on", "\\u", "to", "..._", "\\u\\u\\uNL\\u\\u\\u_", "for_", "aggregate_", "in_", "project_", "._", "\\u", "get", "\\u", "aggregates", "_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "not_", "has", "\\u", "permission_", "(_", "user_", ",_", "aggregate_", ",_", "\"", "can", "\\u", "use", "\\u", "aggre", "gate", "\"_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "aggregate_", "._", "add", "\\u", "to", "\\u", "user_", "(_", "user_", ",_", "\"/\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Get", " ", "project", " ", "deta", "il", " ", "URL", " ", "to", " ", "send", " ", "via", " ", "e-", "mail_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "from_", "expe", "die", "nt_", "._", "clear", "ing", "house_", "._", "project_", "import_", "urls_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "project", "\\u", "deta", "il", "\\u", "url_", "=_", "reverse_", "(_", "\"", "project", "\\u", "deta", "il", "\"_", ",_", "args_", "=_", "[_", "project_", "._", "id_", "]_", ")_", "or_", "\"/\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "No", " ", "\"", "https", "://", "\"", " ", "check", " ", "shou", "ld", " ", "be", " ", "need", "ed", " ", "if", " ", "settings", " ", "are", " ", "OK_", "\\u\\u\\uNL\\u\\u\\u_", "site", "\\u", "domain", "\\u", "url_", "=_", "\"", "https", "://\"_", "+_", "Site_", "._", "objects_", "._", "get", "\\u", "current_", "(_", ")_", "._", "domain_", "+_", "project", "\\u", "deta", "il", "\\u", "url_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "send", "\\u", "mail_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "settings_", "._", "EMA", "IL", "\\u", "SUBJECT", "\\u", "PREFIX_", "+_", "\"", "Project", " ", "%", "s", " ", "member", "ship", " ", "notification", "\"_", "%_", "(_", "project_", "._", "name_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "You", " ", "have", " ", "bee", "n", " ", "adde", "d", " ", "to", " ", "project", " ", "'%", "s", "'", " ", "as", " ", "a", " ", "user", " ", "with", " ", "the", " ", "follow", "ing", " ", "role", "s", ":", " ", "%", "s", ".\\\\", "n", "You", " ", "may", " ", "start", " ", "experiment", "ing", " ", "now", " ", "by", " ", "goi", "ng", " ", "to", " ", "%", "s", "\\\\", "n", "\\\\", "n", "\"_", "%_", "(_", "project_", "._", "name_", ",_", "roles_", ",_", "site", "\\u", "domain", "\\u", "url_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "from", "\\u", "email_", "=_", "settings_", "._", "DEF", "AUL", "T", "\\u", "FROM", "\\u", "EMAIL_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "recip", "ient", "\\u", "list_", "=_", "[_", "user_", "._", "email_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "Exception_", "as_", "e_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "print_", "\"[", "WARN", "ING", "]", " ", "User", " ", "e-", "mail", " ", "notification", " ", "coul", "d", " ", "not", " ", "be", " ", "sent", ".", " ", "Det", "ail", "s", ":", " ", "%", "s", "\"_", "%_", "str_", "(_", "e_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "Http", "Respons", "e", "Redirect_", "(_", "reverse_", "(_", "\"", "project", "\\u", "deta", "il", "\"_", ",_", "args_", "=_", "[_", "proj", "\\u", "id_", "]_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "form_", "=_", "Add", "Mem", "ber", "Form_", "(_", "project_", "=_", "project_", ",_", "give", "r_", "=_", "request_", "._", "user_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "simple_", "._", "direct", "\\u", "to", "\\u", "template_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "request_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "template_", "=_", "TEMPL", "ATE", "\\u", "PATH_", "+_", "\"/", "add", "\\u", "member", ".", "html", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "extra", "\\u", "context_", "=_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "form", "\"_", ":_", "form_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "project", "\"_", ":_", "project_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "breadcrumb", "s", "\"_", ":_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "\"", "Home", "\"_", ",_", "reverse_", "(_", "\"", "home", "\"_", ")_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "\"", "Project", " ", "%", "s", "\"_", "%_", "project_", "._", "name_", ",_", "reverse_", "(_", "\"", "project", "\\u", "deta", "il", "\"_", ",_", "args_", "=_", "[_", "project_", "._", "id_", "]_", ")_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "\"", "Add", " ", "Mem", "ber", "\"_", ",_", "request_", "._", "path_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "}_", ",_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "@_", "require", "\\u", "objs", "\\u", "permissi", "ons", "\\u", "for", "\\u", "view_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "perm", "\\u", "names_", "=_", "[_", "\"", "can", "\\u", "add", "\\u", "member", "s", "\"_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "permit", "tee", "\\u", "func_", "=_", "get", "\\u", "user", "\\u", "from", "\\u", "req_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "target", "\\u", "func_", "=_", "get", "\\u", "queryset_", "(_", "Project_", ",_", "\"", "proj", "\\u", "id", "\"_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "update", "\\u", "member_", "(_", "request_", ",_", "proj", "\\u", "id_", ",_", "user", "\\u", "id_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "Update", " ", "a", " ", "member", "'", "s", " ", "role", "s", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "project_", "=_", "get", "\\u", "object\\u", "or", "\\u", "404_", "(_", "Project_", ",_", "id_", "=_", "proj", "\\u", "id_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "member_", "=_", "get", "\\u", "object\\u", "or", "\\u", "404_", "(_", "User_", ",_", "id_", "=_", "user", "\\u", "id_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "request_", "._", "method_", "==_", "\"", "POST", "\"_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "form_", "=_", "Mem", "ber", "Form_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "project_", "=_", "project_", ",_", "user_", "=_", "member_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "give", "r_", "=_", "request_", "._", "user_", ",_", "data_", "=_", "request_", "._", "POST_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "form_", "._", "is", "\\u", "valid_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "form_", "._", "save_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "Http", "Respons", "e", "Redirect_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "reverse_", "(_", "\"", "project", "\\u", "deta", "il", "\"_", ",_", "args_", "=_", "[_", "proj", "\\u", "id_", "]_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "form_", "=_", "Mem", "ber", "Form_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "project_", "=_", "project_", ",_", "user_", "=_", "member_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "give", "r_", "=_", "request_", "._", "user_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "simple_", "._", "direct", "\\u", "to", "\\u", "template_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "request_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "template_", "=_", "TEMPL", "ATE", "\\u", "PATH_", "+_", "\"/", "update", "\\u", "member", ".", "html", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "extra", "\\u", "context_", "=_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "form", "\"_", ":_", "form_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "project", "\"_", ":_", "project_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "member", "\"_", ":_", "member_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "breadcrumb", "s", "\"_", ":_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "\"", "Home", "\"_", ",_", "reverse_", "(_", "\"", "home", "\"_", ")_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "\"", "Project", " ", "%", "s", "\"_", "%_", "project_", "._", "name_", ",_", "reverse_", "(_", "\"", "project", "\\u", "deta", "il", "\"_", ",_", "args_", "=_", "[_", "project_", "._", "id_", "]_", ")_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "\"", "Update", " ", "Mem", "ber", " ", "%", "s", "\"_", "%_", "member_", "._", "username_", ",_", "request_", "._", "path_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "}_", ",_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "@_", "require", "\\u", "objs", "\\u", "permissi", "ons", "\\u", "for", "\\u", "view_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "perm", "\\u", "names_", "=_", "[_", "\"", "can", "\\u", "remove", "\\u", "member", "s", "\"_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "permit", "tee", "\\u", "func_", "=_", "get", "\\u", "user", "\\u", "from", "\\u", "req_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "target", "\\u", "func_", "=_", "get", "\\u", "queryset_", "(_", "Project_", ",_", "\"", "proj", "\\u", "id", "\"_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "remove", "\\u", "member_", "(_", "request_", ",_", "proj", "\\u", "id_", ",_", "user", "\\u", "id_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "Kick", " ", "a", " ", "member", " ", "out", " ", "by", " ", "strip", "ping", " ", "his", " ", "role", "s", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "project_", "=_", "get", "\\u", "object\\u", "or", "\\u", "404_", "(_", "Project_", ",_", "id_", "=_", "proj", "\\u", "id_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "member_", "=_", "get", "\\u", "object\\u", "or", "\\u", "404_", "(_", "User_", ",_", "id_", "=_", "user", "\\u", "id_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "request_", "._", "method_", "==_", "\"", "POST", "\"_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "member_", "=_", "Permi", "tte", "e_", "._", "objects_", "._", "get", "\\u", "as", "\\u", "permit", "tee", "_", "(_", "member_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Remove", " ", "the", " ", "roles_", "\\u\\u\\uNL\\u\\u\\u_", "for_", "role_", "in_", "Project", "Role_", "._", "objects_", "._", "filter_", "(_", "project_", "=_", "project_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "role_", "._", "remove", "\\u", "from", "\\u", "permit", "tee", "_", "(_", "member_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Remove", " ", "other", " ", "permissions_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "Permi", "ssion", "Owne", "rshi", "p_", "._", "objects_", "._", "delete", "\\u", "all", "\\u", "for", "\\u", "target_", "(_", "project_", ",_", "member_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", "Remove", " ", "can", "\\u", "use", "\\u", "aggre", "gate", " ", "if", " ", "user", " ", "is", " ", "not", " ", "member", " ", "of", " ", "any", " ", "other", " ", "project", " ", "usi", "ng", " ", "the", " ", "aggregates", " ", "of", " ", "this", " ", "project_", "\\u\\u\\uNL\\u\\u\\u_", "for_", "project", "Agg", "_", "in_", "project_", "._", "\\u", "get", "\\u", "aggregates", "_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "agg", "Not", "Us", "ed", "Any", "more", "By", "Member_", "=_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "p_", "in_", "Project_", "._", "objects_", "._", "exclude_", "(_", "id_", "=_", "project_", "._", "id_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "project", "Agg", "_", "in_", "p_", "._", "\\u", "get", "\\u", "aggregates", "_", "(_", ")_", "and_", "unicode_", "(_", "member_", ")_", "in_", "p_", "._", "members_", "._", "values", "\\u", "list_", "(_", "\"", "user", "name", "\"_", ",_", "flat_", "=_", "True_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "agg", "Not", "Us", "ed", "Any", "more", "By", "Member_", "=_", "0_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "break_", ";_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "agg", "Not", "Us", "ed", "Any", "more", "By", "Member_", "and_", "not_", "has", "\\u", "permission_", "(_", "member_", ",_", "project", "Agg", "_", ",_", "\"", "can", "\\u", "use", "\\u", "aggre", "gate", "\"_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "project", "Agg", "_", "._", "remove", "\\u", "from", "\\u", "user_", "(_", "member_", ",_", "\"/\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", "Sync", " ", "LDA", "P_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "project_", "._", "save_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "logger_", "._", "warning_", "(_", "\"", "User", " ", "'%", "s", "'", " ", "may", " ", "have", " ", "not", " ", "bee", "n", " ", "delete", "d", " ", "from", " ", "project", " ", "'%", "s", "'.", " ", "It", " ", "coul", "d", " ", "be", " ", "a", " ", "bug", " ", "within", " ", "LDA", "P", ".\"_", "%_", "(_", "member_", "._", "object_", "._", "username_", ",_", "project_", "._", "name_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "Http", "Respons", "e", "Redirect_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "reverse_", "(_", "\"", "project", "\\u", "deta", "il", "\"_", ",_", "args_", "=_", "[_", "proj", "\\u", "id_", "]_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "simple_", "._", "direct", "\\u", "to", "\\u", "template_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "request_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "template_", "=_", "TEMPL", "ATE", "\\u", "PATH_", "+_", "\"/", "remove", "\\u", "member", ".", "html", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "extra", "\\u", "context_", "=_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "project", "\"_", ":_", "project_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "member", "\"_", ":_", "member_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "breadcrumb", "s", "\"_", ":_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "\"", "Home", "\"_", ",_", "reverse_", "(_", "\"", "home", "\"_", ")_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "\"", "Project", " ", "%", "s", "\"_", "%_", "project_", "._", "name_", ",_", "reverse_", "(_", "\"", "project", "\\u", "deta", "il", "\"_", ",_", "args_", "=_", "[_", "project_", "._", "id_", "]_", ")_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "\"", "Remove", " ", "Mem", "ber", " ", "%", "s", "\"_", "%_", "member_", "._", "username_", ",_", "request_", "._", "path_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "}_", ",_", "\\u\\u\\uNL\\u\\u\\u_", ")_" ]
[ 4, 4, 4, 4, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2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 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 ]
Unused local variable
AppScale/appscale/AppServer/lib/django-1.5/django/contrib/gis/utils/srs.py
[ { "content": "def add_srs_entry(srs, auth_name='EPSG', auth_srid=None, ref_sys_name=None,\n database=None):\n \"\"\"\n This function takes a GDAL SpatialReference system and adds its information\n to the `spatial_ref_sys` table of the spatial backend. Doing this enables\n database-level spatial transformations for the backend. Thus, this utility\n is useful for adding spatial reference systems not included by default with\n the backend -- for example, the so-called \"Google Maps Mercator Projection\"\n is excluded in PostGIS 1.3 and below, and the following adds it to the\n `spatial_ref_sys` table:\n\n >>> from django.contrib.gis.utils import add_srs_entry\n >>> add_srs_entry(900913)\n\n Keyword Arguments:\n auth_name:\n This keyword may be customized with the value of the `auth_name` field.\n Defaults to 'EPSG'.\n\n auth_srid:\n This keyword may be customized with the value of the `auth_srid` field.\n Defaults to the SRID determined by GDAL.\n\n ref_sys_name:\n For SpatiaLite users only, sets the value of the `ref_sys_name` field.\n Defaults to the name determined by GDAL.\n\n database:\n The name of the database connection to use; the default is the value\n of `django.db.DEFAULT_DB_ALIAS` (at the time of this writing, it's value\n is 'default').\n \"\"\"\n from django.db import connections, DEFAULT_DB_ALIAS\n if not database:\n database = DEFAULT_DB_ALIAS\n connection = connections[database]\n\n if not hasattr(connection.ops, 'spatial_version'):\n raise Exception('The `add_srs_entry` utility only works '\n 'with spatial backends.')\n if connection.ops.oracle or connection.ops.mysql:\n raise Exception('This utility does not support the '\n 'Oracle or MySQL spatial backends.')\n SpatialRefSys = connection.ops.spatial_ref_sys()\n\n # If argument is not a `SpatialReference` instance, use it as parameter\n # to construct a `SpatialReference` instance.\n if not isinstance(srs, SpatialReference):\n srs = SpatialReference(srs)\n\n if srs.srid is None:\n raise Exception('Spatial reference requires an SRID to be '\n 'compatible with the spatial backend.')\n\n # Initializing the keyword arguments dictionary for both PostGIS\n # and SpatiaLite.\n kwargs = {'srid' : srs.srid,\n 'auth_name' : auth_name,\n 'auth_srid' : auth_srid or srs.srid,\n 'proj4text' : srs.proj4,\n }\n\n # Backend-specific fields for the SpatialRefSys model.\n if connection.ops.postgis:\n kwargs['srtext'] = srs.wkt\n if connection.ops.spatialite:\n kwargs['ref_sys_name'] = ref_sys_name or srs.name\n\n # Creating the spatial_ref_sys model.\n try:\n # Try getting via SRID only, because using all kwargs may\n # differ from exact wkt/proj in database.\n sr = SpatialRefSys.objects.using(database).get(srid=srs.srid)\n except SpatialRefSys.DoesNotExist:\n sr = SpatialRefSys.objects.using(database).create(**kwargs)", "metadata": "root.add_srs_entry", "header": "['module', '___EOS___']", "index": 2 } ]
[ { "span": "sr ", "start_line": 74, "start_column": 8, "end_line": 74, "end_column": 10 }, { "span": "sr ", "start_line": 76, "start_column": 8, "end_line": 76, "end_column": 10 } ]
[]
1
true
[ "[CLS]_", "Un", "used_", "local_", "variable_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "add", "\\u", "sr", "s", "\\u", "entry_", "(_", "srs_", ",_", "auth", "\\u", "name_", "=_", "'", "EPS", "G", "'_", ",_", "auth", "\\u", "srid_", "=_", "None_", ",_", "ref", "\\u", "sys", "\\u", "name_", "=_", "None_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "database_", "=_", "None_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Thi", "s", " ", "function", " ", "take", "s", " ", "a", " ", "GDA", "L", " ", "Spa", "tial", "Reference", " ", "system", " ", "and", " ", "adds", " ", "its", " ", "informati", "on", "\\", "10", ";", " ", " ", " ", " ", "to", " ", "the", " ", "`", "spat", "ial", "\\u", "ref", "\\u", "sys", "`", " ", "table", " ", "of", " ", "the", " ", "spat", "ial", " ", "back", "end", ".", " ", " ", "Do", "ing", " ", "this", " ", "enable", "s", "\\", "10", ";", " ", " ", " ", " ", "databa", "se", "-", "level", " ", "spat", "ial", " ", "transformation", "s", " ", "for", " ", "the", " ", "back", "end", ".", " ", " ", "Thu", "s", ",", " ", "this", " ", "utility", "\\", "10", ";", " ", " ", " ", " ", "is", " ", "usef", "ul", " ", "for", " ", "addin", "g", " ", "spat", "ial", " ", "reference", " ", "system", "s", " ", "not", " ", "include", "d", " ", "by", " ", "default", " ", "with", "\\", "10", ";", " ", " ", " ", " ", "the", " ", "back", "end", " ", "--", " ", "for", " ", "example", ",", " ", "the", " ", "so", "-", "call", "ed", " ", "\"", "Goo", "gle", " ", "Map", "s", " ", "Merc", "ator", " ", "Projection", "\"", "\\", "10", ";", " ", " ", " ", " ", "is", " ", "exclu", "ded", " ", "in", " ", "Post", "GI", "S", " ", "1.3", " ", "and", " ", "belo", "w", ",", " ", "and", " ", "the", " ", "follow", "ing", " ", "adds", " ", "it", " ", "to", " ", "the", "\\", "10", ";", " ", " ", " ", " ", "`", "spat", "ial", "\\u", "ref", "\\u", "sys", "`", " ", "table", ":", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", ">>>", " ", "from", " ", "django", ".", "contrib", ".", "gi", "s", ".", "util", "s", " ", "import", " ", "add", "\\u", "sr", "s", "\\u", "entry", "\\", "10", ";", " ", " ", " ", " ", ">>>", " ", "add", "\\u", "sr", "s", "\\u", "entry", "(", "900", "913", ")", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "Key", "word", " ", "Arg", "ument", "s", ":", "\\", "10", ";", " ", "auth", "\\u", "name", ":", "\\", "10", ";", " ", " ", " ", "Thi", "s", " ", "keyw", "ord", " ", "may", " ", "be", " ", "customize", "d", " ", "with", " ", "the", " ", "value", " ", "of", " ", "the", " ", "`", "auth", "\\u", "name", "`", " ", "field", ".", "\\", "10", ";", " ", " ", " ", "Default", "s", " ", "to", " ", "'", "EPS", "G", "'.", "\\", "10", ";", "\\", "10", ";", " ", "auth", "\\u", "sri", "d", ":", "\\", "10", ";", " ", " ", " ", "Thi", "s", " ", "keyw", "ord", " ", "may", " ", "be", " ", "customize", "d", " ", "with", " ", "the", " ", "value", " ", "of", " ", "the", " ", "`", "auth", "\\u", "sri", "d", "`", " ", "field", ".", "\\", "10", ";", " ", " ", " ", "Default", "s", " ", "to", " ", "the", " ", "SR", "ID", " ", "dete", "rmin", "ed", " ", "by", " ", "GDA", "L", ".", "\\", "10", ";", "\\", "10", ";", " ", "ref", "\\u", "sys", "\\u", "name", ":", "\\", "10", ";", " ", " ", " ", "For", " ", "Spa", "tia", "Lite", " ", "users", " ", "only", ",", " ", "sets", " ", "the", " ", "value", " ", "of", " ", "the", " ", "`", "ref", "\\u", "sys", "\\u", "name", "`", " ", "field", ".", "\\", "10", ";", " ", " ", " ", "Default", "s", " ", "to", " ", "the", " ", "name", " ", "dete", "rmin", "ed", " ", "by", " ", "GDA", "L", ".", "\\", "10", ";", "\\", "10", ";", " ", "databa", "se", ":", "\\", "10", ";", " ", " ", "The", " ", "name", " ", "of", " ", "the", " ", "databa", "se", " ", "connecti", "on", " ", "to", " ", "use", ";", " ", "the", " ", "default", " ", "is", " ", "the", " ", "value", "\\", "10", ";", " ", " ", "of", " ", "`", "django", ".", "db", ".", "DEF", "AUL", "T", "\\u", "DB", "\\u", "ALIAS", "`", " ", "(", "at", " ", "the", " ", "time", " ", "of", " ", "this", " ", "writ", "ing", ",", " ", "it", "'", "s", " ", "value", "\\", "10", ";", " ", " ", "is", " ", "'", "default", "')", ".", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "django_", "._", "db_", "import_", "connections_", ",_", "DEF", "AUL", "T", "\\u", "DB", "\\u", "ALIAS_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "not_", "database_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "database_", "=_", "DEF", "AUL", "T", "\\u", "DB", "\\u", "ALIAS_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "connection_", "=_", "connections_", "[_", "database_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "not_", "hasattr_", "(_", "connection_", "._", "ops_", ",_", "'", "spat", "ial", "\\u", "version", "'_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "raise_", "Exception_", "(_", "'", "The", " ", "`", "add", "\\u", "sr", "s", "\\u", "entry", "`", " ", "utility", " ", "only", " ", "works", " ", "'_", "\\u\\u\\uNL\\u\\u\\u_", "'", "with", " ", "spat", "ial", " ", "back", "ends", ".'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "connection_", "._", "ops_", "._", "oracle", "_", "or_", "connection_", "._", "ops_", "._", "mysql_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "raise_", "Exception_", "(_", "'", "Thi", "s", " ", "utility", " ", "doe", "s", " ", "not", " ", "support", " ", "the", " ", "'_", "\\u\\u\\uNL\\u\\u\\u_", "'", "Ora", "cle", " ", "or", " ", "My", "SQL", " ", "spat", "ial", " ", "back", "ends", ".'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "Spa", "tial", "Ref", "Sys_", "=_", "connection_", "._", "ops_", "._", "spat", "ial", "\\u", "ref", "\\u", "sys_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "If", " ", "argu", "ment", " ", "is", " ", "not", " ", "a", " ", "`", "Spa", "tial", "Reference", "`", " ", "instance", ",", " ", "use", " ", "it", " ", "as", " ", "parameter_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "to", " ", "construct", " ", "a", " ", "`", "Spa", "tial", "Reference", "`", " ", "instance", "._", "\\u\\u\\uNL\\u\\u\\u_", "if_", "not_", "isinstance_", "(_", "srs_", ",_", "Spa", "tial", "Reference_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "srs_", "=_", "Spa", "tial", "Reference_", "(_", "srs_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "srs_", "._", "srid_", "is_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "raise_", "Exception_", "(_", "'", "Spa", "tial", " ", "reference", " ", "require", "s", " ", "an", " ", "SR", "ID", " ", "to", " ", "be", " ", "'_", "\\u\\u\\uNL\\u\\u\\u_", "'", "compatible", " ", "with", " ", "the", " ", "spat", "ial", " ", "back", "end", ".'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Initializ", "ing", " ", "the", " ", "keyw", "ord", " ", "argu", "ment", "s", " ", "dictionar", "y", " ", "for", " ", "bot", "h", " ", "Post", "GI", "S_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "and", " ", "Spa", "tia", "Lite", "._", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "kwargs_", "=_", "{_", "'", "sri", "d", "'_", ":_", "srs_", "._", "srid_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "auth", "\\u", "name", "'_", ":_", "auth", "\\u", "name_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "auth", "\\u", "sri", "d", "'_", ":_", "auth", "\\u", "srid_", "or_", "srs_", "._", "srid_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "proj", "4", "text", "'_", ":_", "srs_", "._", "proj", "4_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Back", "end", "-", "specific", " ", "fields", " ", "for", " ", "the", " ", "Spa", "tial", "Ref", "Sys", " ", "model", "._", "\\u\\u\\uNL\\u\\u\\u_", "if_", "connection_", "._", "ops_", "._", "post", "gis_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "kwargs_", "[_", "'", "srt", "ext", "'_", "]_", "=_", "srs_", "._", "wkt_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "connection_", "._", "ops_", "._", "spat", "iali", "te_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "kwargs_", "[_", "'", "ref", "\\u", "sys", "\\u", "name", "'_", "]_", "=_", "ref", "\\u", "sys", "\\u", "name_", "or_", "srs_", "._", "name_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Creat", "ing", " ", "the", " ", "spat", "ial", "\\u", "ref", "\\u", "sys", " ", "model", "._", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Tr", "y", " ", "getti", "ng", " ", "via", " ", "SR", "ID", " ", "only", ",", " ", "bec", "aus", "e", " ", "usi", "ng", " ", "all", " ", "kwarg", "s", " ", "may", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "differ", " ", "from", " ", "exact", " ", "wk", "t", "/", "proj", " ", "in", " ", "databa", "se", "._", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "sr_", "=_", "Spa", "tial", "Ref", "Sys_", "._", "objects_", "._", "using_", "(_", "database_", ")_", "._", "get_", "(_", "srid_", "=_", "srs_", "._", "srid_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "Spa", "tial", "Ref", "Sys_", "._", "Do", "es", "Not", "Exist_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "sr_", "=_", "Spa", "tial", "Ref", "Sys_", "._", "objects_", "._", "using_", "(_", "database_", ")_", "._", "create_", "(_", "**_", "kwargs_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_" ]
[ 4, 4, 4, 4, 4, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 ]
Unused local variable
cowrie/cowrie/cowrie/core/interact.py
[ { "content": " def connectionMade(self):\n \"\"\"\n \"\"\"\n self.interacting = None\n self.cmdbuf = ''\n self.honeypotFactory = self.factory.honeypotFactory\n\n # Someone tell me if i'm doing this wrong?\n d = self.do(telnet.LINEMODE)\n self.requestNegotiation(telnet.LINEMODE, telnet.LINEMODE_EDIT + '\\0')\n self.will(telnet.ECHO)\n\n self.transport.write('*** cowrie session management console ***\\r\\n')\n self.cmd_help()", "metadata": "root.Interact.connectionMade", "header": "['class', 'Interact', '(', 'telnet', '.', 'Telnet', ')', ':', '___EOS___']", "index": 18 } ]
[ { "span": "d ", "start_line": 26, "start_column": 8, "end_line": 26, "end_column": 9 } ]
[]
1
true
[ "[CLS]_", "Un", "used_", "local_", "variable_", "[SEP]_", "class_", "Interact", "_", "(_", "telnet", "_", "._", "Tel", "net_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "connecti", "on", "Made", "_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "interacti", "ng_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "cmd", "buf_", "=_", "''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "honey", "pot", "Factory_", "=_", "self_", "._", "factory_", "._", "honey", "pot", "Factory_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Some", "one", " ", "tell", " ", "me", " ", "if", " ", "i", "'", "m", " ", "doi", "ng", " ", "this", " ", "wrong", "?", "_", "\\u\\u\\uNL\\u\\u\\u_", "d_", "=_", "self_", "._", "do_", "(_", "telnet", "_", "._", "LINE", "MODE_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "request", "Nego", "tiat", "ion_", "(_", "telnet", "_", "._", "LINE", "MODE_", ",_", "telnet", "_", "._", "LINE", "MODE", "\\u", "EDIT", "_", "+_", "'\\\\", "0", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "will", "_", "(_", "telnet", "_", "._", "ECHO", "_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "transport_", "._", "write_", "(_", "'**", "*", " ", "cow", "rie", " ", "session", " ", "manage", "ment", " ", "console", " ", "***", "\\\\", "r", "\\\\", "n", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "cmd", "\\u", "help_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_" ]
[ 4, 4, 4, 4, 4, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 ]
Unused import
fordham-css/ptp/vis-api-server.py
[ { "content": "from flask import Flask, url_for, json\nfrom flask import request, jsonify\nfrom functools import wraps\nimport time\nimport sys\nimport datetime\napp = Flask(__name__)\n\nimport logging\nfile_handler = logging.FileHandler('server.log')\napp.logger.addHandler(file_handler)\napp.logger.setLevel(logging.INFO)\n\n\nfrom utils import *\nimport redis\n\nr = redis.Redis(host='localhost',port=6669)\nr.set_response_callback('SMEMBERS', list)\n\nstock = sys.argv[1]\n\n \nif __name__ == '__main__':\n\tapp.run(debug=True,port=5000)", "metadata": "root", "header": "['module', '___EOS___']", "index": 0 }, { "content": "@app.route('/api/last_row', methods = ['GET'])\ndef last_row():\n \n # Make timestamp\n timestamp = datetime.datetime.fromtimestamp(time.time()).strftime('%Y-%m-%d %H:%M:%S')\n \n # Log init request\n app.logger.info('[+] [' + timestamp + '] ' + 'GET request recieved.')\n \n # Prepare bot response\n #therapy(parse_user_says(user_says))\n \n row = get_range_row(stock,-1,-1,r)[0]\n \n return jsonify({'stock':stock,'stamp':row[0],'price':row[1],'bid':row[2],'ask':row[3]})", "metadata": "root.last_row", "header": "['module', '___EOS___']", "index": 22 } ]
[ { "span": "from flask import Flask, url_for, json", "start_line": 0, "start_column": 0, "end_line": 0, "end_column": 38 }, { "span": "from flask import request, jsonify", "start_line": 1, "start_column": 0, "end_line": 1, "end_column": 34 }, { "span": "from functools import wraps", "start_line": 2, "start_column": 0, "end_line": 2, "end_column": 27 } ]
[]
1
false
[ "[CLS]_", "Un", "used_", "import_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "from_", "flask_", "import_", "Flask_", ",_", "url", "\\u", "for_", ",_", "json_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "flask_", "import_", "request_", ",_", "jsonify_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "functools_", "import_", "wraps_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "time_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "sys_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "datetime_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "app_", "=_", "Flask_", "(_", "\\u\\u", "name\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "import_", "logging_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "file", "\\u", "handler_", "=_", "logging_", "._", "File", "Handler_", "(_", "'", "server", ".", "log", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "app_", "._", "logger_", "._", "add", "Handler_", "(_", "file", "\\u", "handler_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "app_", "._", "logger_", "._", "set", "Level_", "(_", "logging_", "._", "INFO_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "from_", "utils_", "import_", "*_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "redis_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "r_", "=_", "redis_", "._", "Redis_", "(_", "host_", "=_", "'", "local", "host", "'_", ",_", "port_", "=_", "666", "9_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "r_", "._", "set\\u", "response", "\\u", "callback_", "(_", "'", "SM", "EM", "BER", "S", "'_", ",_", "list_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "stock_", "=_", "sys_", "._", "argv_", "[_", "1_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "\\u\\u", "name\\u\\u_", "==_", "'\\u", "\\u", "main", "\\u\\u'_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "_", "app_", "._", "run_", "(_", "debug_", "=_", "True_", ",_", "port_", "=_", "5000_", ")_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "@_", "app_", "._", "route_", "(_", "'/", "api", "/", "last", "\\u", "row", "'_", ",_", "methods_", "=_", "[_", "'", "GET", "'_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "last", "\\u", "row_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Make", " ", "timestamp_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "timestamp_", "=_", "datetime_", "._", "datetime_", "._", "fromtimestamp_", "(_", "time_", "._", "time_", "(_", ")_", ")_", "._", "strftime_", "(_", "'%", "Y", "-%", "m", "-%", "d", " ", "%", "H", ":", "%", "M", ":", "%", "S", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Log", " ", "init", " ", "request_", "\\u\\u\\uNL\\u\\u\\u_", "app_", "._", "logger_", "._", "info_", "(_", "'[", "+]", " ", "['_", "+_", "timestamp_", "+_", "']", " ", "'_", "+_", "'", "GET", " ", "request", " ", "recieve", "d", ".'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Prepare", " ", "bot", " ", "response_", "\\u\\u\\uNL\\u\\u\\u_", "#", "ther", "ap", "y", "(", "parse", "\\u", "user", "\\u", "say", "s", "(", "user", "\\u", "say", "s", "))", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "row_", "=_", "get", "\\u", "range", "\\u", "row_", "(_", "stock_", ",_", "-_", "1_", ",_", "-_", "1_", ",_", "r_", ")_", "[_", "0_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "return_", "jsonify_", "(_", "{_", "'", "stock", "'_", ":_", "stock_", ",_", "'", "stamp", "'_", ":_", "row_", "[_", "0_", "]_", ",_", "'", "price", "'_", ":_", "row_", "[_", "1_", "]_", ",_", "'", "bid", "'_", ":_", "row_", "[_", "2_", "]_", ",_", "'", "ask", "'_", ":_", "row_", "[_", "3_", "]_", "}_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_" ]
[ 4, 4, 4, 4, 4, 2, 2, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 0, 1, 1, 1, 1, 1, 2, 0, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 ]
Unused import
AnyMesh/anyMesh-Python/example/urwid/main_loop.py
[ { "content": "#!/usr/bin/python\n#\n# Urwid main loop code\n# Copyright (C) 2004-2012 Ian Ward\n# Copyright (C) 2008 Walter Mundt\n# Copyright (C) 2009 Andrew Psaltis\n#\n# This library is free software; you can redistribute it and/or\n# modify it under the terms of the GNU Lesser General Public\n# License as published by the Free Software Foundation; either\n# version 2.1 of the License, or (at your option) any later version.\n#\n# This library is distributed in the hope that it will be useful,\n# but WITHOUT ANY WARRANTY; without even the implied warranty of\n# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n# Lesser General Public License for more details.\n#\n# You should have received a copy of the GNU Lesser General Public\n# License along with this library; if not, write to the Free Software\n# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\n#\n# Urwid web site: http://excess.org/urwid/\n\n\nimport time\nimport heapq\nimport select\nimport fcntl\nimport os\nfrom functools import wraps\nfrom weakref import WeakKeyDictionary\n\nfrom urwid.util import is_mouse_event\nfrom urwid.compat import PYTHON3\nfrom urwid.command_map import command_map, REDRAW_SCREEN\nfrom urwid.wimp import PopUpTarget\nfrom urwid import signals\nfrom urwid.display_common import INPUT_DESCRIPTORS_CHANGED\n\nPIPE_BUFFER_READ_SIZE = 4096 # can expect this much on Linux, so try for that\n\n\n\n\n\n\n\n\n\n\ntry:\n from twisted.internet.abstract import FileDescriptor\nexcept ImportError:\n FileDescriptor = object\n\n\n\n\n\n\n\n\nif __name__=='__main__':\n _test()\n", "metadata": "root", "header": "['module', '___EOS___']", "index": 0 }, { "content": "class ExitMainLoop(Exception):\n \"\"\"\n When this exception is raised within a main loop the main loop\n will exit cleanly.\n \"\"\"\n pass", "metadata": "root.ExitMainLoop", "header": "['module', '___EOS___']", "index": 41 }, { "content": "class MainLoop(object):\n \"\"\"\n This is the standard main loop implementation for a single interactive\n session.\n\n :param widget: the topmost widget used for painting the screen, stored as\n :attr:`widget` and may be modified. Must be a box widget.\n :type widget: widget instance\n\n :param palette: initial palette for screen\n :type palette: iterable of palette entries\n\n :param screen: screen to use, default is a new :class:`raw_display.Screen`\n instance; stored as :attr:`screen`\n :type screen: display module screen instance\n\n :param handle_mouse: ``True`` to ask :attr:`.screen` to process mouse events\n :type handle_mouse: bool\n\n :param input_filter: a function to filter input before sending it to\n :attr:`.widget`, called from :meth:`.input_filter`\n :type input_filter: callable\n\n :param unhandled_input: a function called when input is not handled by\n :attr:`.widget`, called from :meth:`.unhandled_input`\n :type unhandled_input: callable\n\n :param event_loop: if :attr:`.screen` supports external an event loop it may be\n given here, default is a new :class:`SelectEventLoop` instance;\n stored as :attr:`.event_loop`\n :type event_loop: event loop instance\n\n :param pop_ups: `True` to wrap :attr:`.widget` with a :class:`PopUpTarget`\n instance to allow any widget to open a pop-up anywhere on the screen\n :type pop_ups: boolean\n\n\n .. attribute:: screen\n\n The screen object this main loop uses for screen updates and reading input\n\n .. attribute:: event_loop\n\n The event loop object this main loop uses for waiting on alarms and IO\n \"\"\"\n\n\n widget = property(lambda self:self._widget, _set_widget, doc=\n \"\"\"\n Property for the topmost widget used to draw the screen.\n This must be a box widget.\n \"\"\")\n\n pop_ups = property(lambda self:self._pop_ups, _set_pop_ups)\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n", "metadata": "root.MainLoop", "header": "['module', '___EOS___']", "index": 48 }, { "content": " def __init__(self, widget, palette=(), screen=None,\n handle_mouse=True, input_filter=None, unhandled_input=None,\n event_loop=None, pop_ups=False):\n self._widget = widget\n self.handle_mouse = handle_mouse\n self.pop_ups = pop_ups # triggers property setting side-effect\n\n if not screen:\n from urwid import raw_display\n screen = raw_display.Screen()\n\n if palette:\n screen.register_palette(palette)\n\n self.screen = screen\n self.screen_size = None\n\n self._unhandled_input = unhandled_input\n self._input_filter = input_filter\n\n if not hasattr(screen, 'get_input_descriptors'\n ) and event_loop is not None:\n raise NotImplementedError(\"screen object passed \"\n \"%r does not support external event loops\" % (screen,))\n if event_loop is None:\n event_loop = SelectEventLoop()\n self.event_loop = event_loop\n\n self._input_timeout = None\n self._watch_pipes = {}", "metadata": "root.MainLoop.__init__", "header": "['class', 'MainLoop', '(', 'object', ')', ':', '___EOS___']", "index": 94 }, { "content": " def _set_widget(self, widget):\n self._widget = widget\n if self.pop_ups:\n self._topmost_widget.original_widget = self._widget\n else:\n self._topmost_widget = self._widget", "metadata": "root.MainLoop._set_widget", "header": "['class', 'MainLoop', '(', 'object', ')', ':', '___EOS___']", "index": 125 }, { "content": " def _set_pop_ups(self, pop_ups):\n self._pop_ups = pop_ups\n if pop_ups:\n self._topmost_widget = PopUpTarget(self._widget)\n else:\n self._topmost_widget = self._widget", "metadata": "root.MainLoop._set_pop_ups", "header": "['class', 'MainLoop', '(', 'object', ')', ':', '___EOS___']", "index": 137 }, { "content": " def set_alarm_in(self, sec, callback, user_data=None):\n \"\"\"\n Schedule an alarm in *sec* seconds that will call *callback* from the\n within the :meth:`run` method.\n\n :param sec: seconds until alarm\n :type sec: float\n :param callback: function to call with two parameters: this main loop\n object and *user_data*\n :type callback: callable\n \"\"\"\n def cb():\n callback(self, user_data)\n return self.event_loop.alarm(sec, cb)", "metadata": "root.MainLoop.set_alarm_in", "header": "['class', 'MainLoop', '(', 'object', ')', ':', '___EOS___']", "index": 145 }, { "content": " def set_alarm_at(self, tm, callback, user_data=None):\n \"\"\"\n Schedule an alarm at *tm* time that will call *callback* from the\n within the :meth:`run` function. Returns a handle that may be passed to\n :meth:`remove_alarm`.\n\n :param tm: time to call callback e.g. ``time.time() + 5``\n :type tm: float\n :param callback: function to call with two parameters: this main loop\n object and *user_data*\n :type callback: callable\n \"\"\"\n def cb():\n callback(self, user_data)\n return self.event_loop.alarm(tm - time.time(), cb)", "metadata": "root.MainLoop.set_alarm_at", "header": "['class', 'MainLoop', '(', 'object', ')', ':', '___EOS___']", "index": 160 }, { "content": " def remove_alarm(self, handle):\n \"\"\"\n Remove an alarm. Return ``True`` if *handle* was found, ``False``\n otherwise.\n \"\"\"\n return self.event_loop.remove_alarm(handle)", "metadata": "root.MainLoop.remove_alarm", "header": "['class', 'MainLoop', '(', 'object', ')', ':', '___EOS___']", "index": 176 }, { "content": " def watch_pipe(self, callback):\n \"\"\"\n Create a pipe for use by a subprocess or thread to trigger a callback\n in the process/thread running the main loop.\n\n :param callback: function taking one parameter to call from within\n the process/thread running the main loop\n :type callback: callable\n\n This method returns a file descriptor attached to the write end of a\n pipe. The read end of the pipe is added to the list of files\n :attr:`event_loop` is watching. When data is written to the pipe the\n callback function will be called and passed a single value containing\n data read from the pipe.\n\n This method may be used any time you want to update widgets from\n another thread or subprocess.\n\n Data may be written to the returned file descriptor with\n ``os.write(fd, data)``. Ensure that data is less than 512 bytes (or 4K\n on Linux) so that the callback will be triggered just once with the\n complete value of data passed in.\n\n If the callback returns ``False`` then the watch will be removed from\n :attr:`event_loop` and the read end of the pipe will be closed. You\n are responsible for closing the write end of the pipe with\n ``os.close(fd)``.\n \"\"\"\n pipe_rd, pipe_wr = os.pipe()\n fcntl.fcntl(pipe_rd, fcntl.F_SETFL, os.O_NONBLOCK)\n watch_handle = None\n\n def cb():\n data = os.read(pipe_rd, PIPE_BUFFER_READ_SIZE)\n rval = callback(data)\n if rval is False:\n self.event_loop.remove_watch_file(watch_handle)\n os.close(pipe_rd)\n\n watch_handle = self.event_loop.watch_file(pipe_rd, cb)\n self._watch_pipes[pipe_wr] = (watch_handle, pipe_rd)\n return pipe_wr", "metadata": "root.MainLoop.watch_pipe", "header": "['class', 'MainLoop', '(', 'object', ')', ':', '___EOS___']", "index": 183 }, { "content": " def remove_watch_pipe(self, write_fd):\n \"\"\"\n Close the read end of the pipe and remove the watch created by\n :meth:`watch_pipe`. You are responsible for closing the write end of\n the pipe.\n\n Returns ``True`` if the watch pipe exists, ``False`` otherwise\n \"\"\"\n try:\n watch_handle, pipe_rd = self._watch_pipes.pop(write_fd)\n except KeyError:\n return False\n\n if not self.event_loop.remove_watch_file(watch_handle):\n return False\n os.close(pipe_rd)\n return True", "metadata": "root.MainLoop.remove_watch_pipe", "header": "['class', 'MainLoop', '(', 'object', ')', ':', '___EOS___']", "index": 226 }, { "content": " def watch_file(self, fd, callback):\n \"\"\"\n Call *callback* when *fd* has some data to read. No parameters are\n passed to callback.\n\n Returns a handle that may be passed to :meth:`remove_watch_file`.\n \"\"\"\n return self.event_loop.watch_file(fd, callback)", "metadata": "root.MainLoop.watch_file", "header": "['class', 'MainLoop', '(', 'object', ')', ':', '___EOS___']", "index": 244 }, { "content": " def remove_watch_file(self, handle):\n \"\"\"\n Remove a watch file. Returns ``True`` if the watch file\n exists, ``False`` otherwise.\n \"\"\"\n return self.event_loop.remove_watch_file(handle)", "metadata": "root.MainLoop.remove_watch_file", "header": "['class', 'MainLoop', '(', 'object', ')', ':', '___EOS___']", "index": 253 }, { "content": " def run(self):\n \"\"\"\n Start the main loop handling input events and updating the screen. The\n loop will continue until an :exc:`ExitMainLoop` exception is raised.\n\n This method will use :attr:`screen`'s run_wrapper() method if\n :attr:`screen`'s start() method has not already been called.\n \"\"\"\n try:\n if self.screen.started:\n self._run()\n else:\n self.screen.run_wrapper(self._run)\n except ExitMainLoop:\n pass", "metadata": "root.MainLoop.run", "header": "['class', 'MainLoop', '(', 'object', ')', ':', '___EOS___']", "index": 261 }, { "content": " def _test_run(self):\n \"\"\"\n >>> w = _refl(\"widget\") # _refl prints out function calls\n >>> w.render_rval = \"fake canvas\" # *_rval is used for return values\n >>> scr = _refl(\"screen\")\n >>> scr.get_input_descriptors_rval = [42]\n >>> scr.get_cols_rows_rval = (20, 10)\n >>> scr.started = True\n >>> scr._urwid_signals = {}\n >>> evl = _refl(\"event_loop\")\n >>> evl.enter_idle_rval = 1\n >>> evl.watch_file_rval = 2\n >>> ml = MainLoop(w, [], scr, event_loop=evl)\n >>> ml.run() # doctest:+ELLIPSIS\n screen.set_mouse_tracking()\n screen.get_cols_rows()\n widget.render((20, 10), focus=True)\n screen.draw_screen((20, 10), 'fake canvas')\n screen.get_input_descriptors()\n event_loop.watch_file(42, <bound method ...>)\n event_loop.enter_idle(<bound method ...>)\n event_loop.run()\n event_loop.remove_enter_idle(1)\n event_loop.remove_watch_file(2)\n >>> scr.started = False\n >>> ml.run() # doctest:+ELLIPSIS\n screen.run_wrapper(<bound method ...>)\n \"\"\"", "metadata": "root.MainLoop._test_run", "header": "['class', 'MainLoop', '(', 'object', ')', ':', '___EOS___']", "index": 277 }, { "content": " def _run(self):\n if self.handle_mouse:\n self.screen.set_mouse_tracking()\n\n if not hasattr(self.screen, 'get_input_descriptors'):\n return self._run_screen_event_loop()\n\n self.draw_screen()\n\n fd_handles = []\n def reset_input_descriptors(only_remove=False):\n for handle in fd_handles:\n self.event_loop.remove_watch_file(handle)\n if only_remove:\n del fd_handles[:]\n else:\n fd_handles[:] = [\n self.event_loop.watch_file(fd, self._update)\n for fd in self.screen.get_input_descriptors()]\n if not fd_handles and self._input_timeout is not None:\n self.event_loop.remove_alarm(self._input_timeout)\n\n try:\n signals.connect_signal(self.screen, INPUT_DESCRIPTORS_CHANGED,\n reset_input_descriptors)\n except NameError:\n pass\n # watch our input descriptors\n reset_input_descriptors()\n idle_handle = self.event_loop.enter_idle(self.entering_idle)\n\n # Go..\n self.event_loop.run()\n\n # tidy up\n self.event_loop.remove_enter_idle(idle_handle)\n reset_input_descriptors(True)\n signals.disconnect_signal(self.screen, INPUT_DESCRIPTORS_CHANGED,\n reset_input_descriptors)", "metadata": "root.MainLoop._run", "header": "['class', 'MainLoop', '(', 'object', ')', ':', '___EOS___']", "index": 306 }, { "content": " def _update(self, timeout=False):\n \"\"\"\n >>> w = _refl(\"widget\")\n >>> w.selectable_rval = True\n >>> w.mouse_event_rval = True\n >>> scr = _refl(\"screen\")\n >>> scr.get_cols_rows_rval = (15, 5)\n >>> scr.get_input_nonblocking_rval = 1, ['y'], [121]\n >>> evl = _refl(\"event_loop\")\n >>> ml = MainLoop(w, [], scr, event_loop=evl)\n >>> ml._input_timeout = \"old timeout\"\n >>> ml._update() # doctest:+ELLIPSIS\n event_loop.remove_alarm('old timeout')\n screen.get_input_nonblocking()\n event_loop.alarm(1, <function ...>)\n screen.get_cols_rows()\n widget.selectable()\n widget.keypress((15, 5), 'y')\n >>> scr.get_input_nonblocking_rval = None, [(\"mouse press\", 1, 5, 4)\n ... ], []\n >>> ml._update()\n screen.get_input_nonblocking()\n widget.mouse_event((15, 5), 'mouse press', 1, 5, 4, focus=True)\n >>> scr.get_input_nonblocking_rval = None, [], []\n >>> ml._update()\n screen.get_input_nonblocking()\n \"\"\"\n if self._input_timeout is not None and not timeout:\n # cancel the timeout, something else triggered the update\n self.event_loop.remove_alarm(self._input_timeout)\n self._input_timeout = None\n\n max_wait, keys, raw = self.screen.get_input_nonblocking()\n \n if max_wait is not None:\n # if get_input_nonblocking wants to be called back\n # make sure it happens with an alarm\n self._input_timeout = self.event_loop.alarm(max_wait, \n lambda: self._update(timeout=True)) \n\n keys = self.input_filter(keys, raw)\n\n if keys:\n self.process_input(keys)\n if 'window resize' in keys:\n self.screen_size = None", "metadata": "root.MainLoop._update", "header": "['class', 'MainLoop', '(', 'object', ')', ':', '___EOS___']", "index": 346 }, { "content": " def _run_screen_event_loop(self):\n \"\"\"\n This method is used when the screen does not support using\n external event loops.\n\n The alarms stored in the SelectEventLoop in :attr:`event_loop`\n are modified by this method.\n \"\"\"\n next_alarm = None\n\n while True:\n self.draw_screen()\n\n if not next_alarm and self.event_loop._alarms:\n next_alarm = heapq.heappop(self.event_loop._alarms)\n\n keys = None\n while not keys:\n if next_alarm:\n sec = max(0, next_alarm[0] - time.time())\n self.screen.set_input_timeouts(sec)\n else:\n self.screen.set_input_timeouts(None)\n keys, raw = self.screen.get_input(True)\n if not keys and next_alarm: \n sec = next_alarm[0] - time.time()\n if sec <= 0:\n break\n\n keys = self.input_filter(keys, raw)\n\n if keys:\n self.process_input(keys)\n\n while next_alarm:\n sec = next_alarm[0] - time.time()\n if sec > 0:\n break\n tm, callback = next_alarm\n callback()\n\n if self.event_loop._alarms:\n next_alarm = heapq.heappop(self.event_loop._alarms)\n else:\n next_alarm = None\n\n if 'window resize' in keys:\n self.screen_size = None", "metadata": "root.MainLoop._run_screen_event_loop", "header": "['class', 'MainLoop', '(', 'object', ')', ':', '___EOS___']", "index": 393 }, { "content": " def _test_run_screen_event_loop(self):\n \"\"\"\n >>> w = _refl(\"widget\")\n >>> scr = _refl(\"screen\")\n >>> scr.get_cols_rows_rval = (10, 5)\n >>> scr.get_input_rval = [], []\n >>> ml = MainLoop(w, screen=scr)\n >>> def stop_now(loop, data):\n ... raise ExitMainLoop()\n >>> handle = ml.set_alarm_in(0, stop_now)\n >>> try:\n ... ml._run_screen_event_loop()\n ... except ExitMainLoop:\n ... pass\n screen.get_cols_rows()\n widget.render((10, 5), focus=True)\n screen.draw_screen((10, 5), None)\n screen.set_input_timeouts(0)\n screen.get_input(True)\n \"\"\"", "metadata": "root.MainLoop._test_run_screen_event_loop", "header": "['class', 'MainLoop', '(', 'object', ')', ':', '___EOS___']", "index": 442 }, { "content": " def process_input(self, keys):\n \"\"\"\n This method will pass keyboard input and mouse events to :attr:`widget`.\n This method is called automatically from the :meth:`run` method when\n there is input, but may also be called to simulate input from the user.\n\n *keys* is a list of input returned from :attr:`screen`'s get_input()\n or get_input_nonblocking() methods.\n\n Returns ``True`` if any key was handled by a widget or the\n :meth:`unhandled_input` method.\n \"\"\"\n if not self.screen_size:\n self.screen_size = self.screen.get_cols_rows()\n\n something_handled = False\n\n for k in keys:\n if k == 'window resize':\n continue\n if is_mouse_event(k):\n event, button, col, row = k\n if self._topmost_widget.mouse_event(self.screen_size,\n event, button, col, row, focus=True ):\n k = None\n elif self._topmost_widget.selectable():\n k = self._topmost_widget.keypress(self.screen_size, k)\n if k:\n if command_map[k] == REDRAW_SCREEN:\n self.screen.clear()\n something_handled = True\n else:\n something_handled |= bool(self.unhandled_input(k))\n else:\n something_handled = True\n\n return something_handled", "metadata": "root.MainLoop.process_input", "header": "['class', 'MainLoop', '(', 'object', ')', ':', '___EOS___']", "index": 463 }, { "content": " def _test_process_input(self):\n \"\"\"\n >>> w = _refl(\"widget\")\n >>> w.selectable_rval = True\n >>> scr = _refl(\"screen\")\n >>> scr.get_cols_rows_rval = (10, 5)\n >>> ml = MainLoop(w, [], scr)\n >>> ml.process_input(['enter', ('mouse drag', 1, 14, 20)])\n screen.get_cols_rows()\n widget.selectable()\n widget.keypress((10, 5), 'enter')\n widget.mouse_event((10, 5), 'mouse drag', 1, 14, 20, focus=True)\n True\n \"\"\"", "metadata": "root.MainLoop._test_process_input", "header": "['class', 'MainLoop', '(', 'object', ')', ':', '___EOS___']", "index": 501 }, { "content": " def input_filter(self, keys, raw):\n \"\"\"\n This function is passed each all the input events and raw keystroke\n values. These values are passed to the *input_filter* function\n passed to the constructor. That function must return a list of keys to\n be passed to the widgets to handle. If no *input_filter* was\n defined this implementation will return all the input events.\n \"\"\"\n if self._input_filter:\n return self._input_filter(keys, raw)\n return keys", "metadata": "root.MainLoop.input_filter", "header": "['class', 'MainLoop', '(', 'object', ')', ':', '___EOS___']", "index": 516 }, { "content": " def unhandled_input(self, input):\n \"\"\"\n This function is called with any input that was not handled by the\n widgets, and calls the *unhandled_input* function passed to the\n constructor. If no *unhandled_input* was defined then the input\n will be ignored.\n\n *input* is the keyboard or mouse input.\n\n The *unhandled_input* function should return ``True`` if it handled\n the input.\n \"\"\"\n if self._unhandled_input:\n return self._unhandled_input(input)", "metadata": "root.MainLoop.unhandled_input", "header": "['class', 'MainLoop', '(', 'object', ')', ':', '___EOS___']", "index": 528 }, { "content": " def entering_idle(self):\n \"\"\"\n This method is called whenever the event loop is about to enter the\n idle state. :meth:`draw_screen` is called here to update the\n screen when anything has changed.\n \"\"\"\n if self.screen.started:\n self.draw_screen()", "metadata": "root.MainLoop.entering_idle", "header": "['class', 'MainLoop', '(', 'object', ')', ':', '___EOS___']", "index": 543 }, { "content": " def draw_screen(self):\n \"\"\"\n Render the widgets and paint the screen. This method is called\n automatically from :meth:`entering_idle`.\n\n If you modify the widgets displayed outside of handling input or\n responding to an alarm you will need to call this method yourself\n to repaint the screen.\n \"\"\"\n if not self.screen_size:\n self.screen_size = self.screen.get_cols_rows()\n\n canvas = self._topmost_widget.render(self.screen_size, focus=True)\n self.screen.draw_screen(self.screen_size, canvas)", "metadata": "root.MainLoop.draw_screen", "header": "['class', 'MainLoop', '(', 'object', ')', ':', '___EOS___']", "index": 552 }, { "content": "class SelectEventLoop(object):\n \"\"\"\n Event loop based on :func:`select.select`\n \"\"\"\n\n\n\n\n\n\n\n\n\n", "metadata": "root.SelectEventLoop", "header": "['module', '___EOS___']", "index": 568 }, { "content": " def __init__(self):\n self._alarms = []\n self._watch_files = {}\n self._idle_handle = 0\n self._idle_callbacks = {}", "metadata": "root.SelectEventLoop.__init__", "header": "['class', 'SelectEventLoop', '(', 'object', ')', ':', '___EOS___']", "index": 573 }, { "content": " def alarm(self, seconds, callback):\n \"\"\"\n Call callback() given time from from now. No parameters are\n passed to callback.\n\n Returns a handle that may be passed to remove_alarm()\n\n seconds -- floating point time to wait before calling callback\n callback -- function to call from event loop\n \"\"\"\n tm = time.time() + seconds\n heapq.heappush(self._alarms, (tm, callback))\n return (tm, callback)", "metadata": "root.SelectEventLoop.alarm", "header": "['class', 'SelectEventLoop', '(', 'object', ')', ':', '___EOS___']", "index": 579 }, { "content": " def remove_alarm(self, handle):\n \"\"\"\n Remove an alarm.\n\n Returns True if the alarm exists, False otherwise\n \"\"\"\n try:\n self._alarms.remove(handle)\n heapq.heapify(self._alarms)\n return True\n except ValueError:\n return False", "metadata": "root.SelectEventLoop.remove_alarm", "header": "['class', 'SelectEventLoop', '(', 'object', ')', ':', '___EOS___']", "index": 593 }, { "content": " def watch_file(self, fd, callback):\n \"\"\"\n Call callback() when fd has some data to read. No parameters\n are passed to callback.\n\n Returns a handle that may be passed to remove_watch_file()\n\n fd -- file descriptor to watch for input\n callback -- function to call when input is available\n \"\"\"\n self._watch_files[fd] = callback\n return fd", "metadata": "root.SelectEventLoop.watch_file", "header": "['class', 'SelectEventLoop', '(', 'object', ')', ':', '___EOS___']", "index": 606 }, { "content": " def remove_watch_file(self, handle):\n \"\"\"\n Remove an input file.\n\n Returns True if the input file exists, False otherwise\n \"\"\"\n if handle in self._watch_files:\n del self._watch_files[handle]\n return True\n return False", "metadata": "root.SelectEventLoop.remove_watch_file", "header": "['class', 'SelectEventLoop', '(', 'object', ')', ':', '___EOS___']", "index": 619 }, { "content": " def enter_idle(self, callback):\n \"\"\"\n Add a callback for entering idle.\n\n Returns a handle that may be passed to remove_idle()\n \"\"\"\n self._idle_handle += 1\n self._idle_callbacks[self._idle_handle] = callback\n return self._idle_handle", "metadata": "root.SelectEventLoop.enter_idle", "header": "['class', 'SelectEventLoop', '(', 'object', ')', ':', '___EOS___']", "index": 630 }, { "content": " def remove_enter_idle(self, handle):\n \"\"\"\n Remove an idle callback.\n\n Returns True if the handle was removed.\n \"\"\"\n try:\n del self._idle_callbacks[handle]\n except KeyError:\n return False\n return True", "metadata": "root.SelectEventLoop.remove_enter_idle", "header": "['class', 'SelectEventLoop', '(', 'object', ')', ':', '___EOS___']", "index": 640 }, { "content": " def _entering_idle(self):\n \"\"\"\n Call all the registered idle callbacks.\n \"\"\"\n for callback in self._idle_callbacks.values():\n callback()", "metadata": "root.SelectEventLoop._entering_idle", "header": "['class', 'SelectEventLoop', '(', 'object', ')', ':', '___EOS___']", "index": 652 }, { "content": " def run(self):\n \"\"\"\n Start the event loop. Exit the loop when any callback raises\n an exception. If ExitMainLoop is raised, exit cleanly.\n \"\"\"\n try:\n self._did_something = True\n while True:\n try:\n self._loop()\n except select.error, e:\n if e.args[0] != 4:\n # not just something we need to retry\n raise\n except ExitMainLoop:\n pass", "metadata": "root.SelectEventLoop.run", "header": "['class', 'SelectEventLoop', '(', 'object', ')', ':', '___EOS___']", "index": 659 }, { "content": " def _loop(self):\n \"\"\"\n A single iteration of the event loop\n \"\"\"\n fds = self._watch_files.keys()\n if self._alarms or self._did_something:\n if self._alarms:\n tm = self._alarms[0][0]\n timeout = max(0, tm - time.time())\n if self._did_something and (not self._alarms or \n (self._alarms and timeout > 0)):\n timeout = 0\n tm = 'idle'\n ready, w, err = select.select(fds, [], fds, timeout)\n else:\n tm = None\n ready, w, err = select.select(fds, [], fds)\n\n if not ready:\n if tm == 'idle':\n self._entering_idle()\n self._did_something = False\n elif tm is not None:\n # must have been a timeout\n tm, alarm_callback = self._alarms.pop(0)\n alarm_callback()\n self._did_something = True\n\n for fd in ready:\n self._watch_files[fd]()\n self._did_something = True", "metadata": "root.SelectEventLoop._loop", "header": "['class', 'SelectEventLoop', '(', 'object', ')', ':', '___EOS___']", "index": 676 }, { "content": "class GLibEventLoop(object):\n \"\"\"\n Event loop based on GLib.MainLoop\n \"\"\"\n\n\n\n\n\n\n\n\n\n\n", "metadata": "root.GLibEventLoop", "header": "['module', '___EOS___']", "index": 709 }, { "content": " def __init__(self):\n from gi.repository import GLib\n self.GLib = GLib\n self._alarms = []\n self._watch_files = {}\n self._idle_handle = 0\n self._glib_idle_enabled = False # have we called glib.idle_add?\n self._idle_callbacks = {}\n self._loop = GLib.MainLoop()\n self._exc_info = None\n self._enable_glib_idle()", "metadata": "root.GLibEventLoop.__init__", "header": "['class', 'GLibEventLoop', '(', 'object', ')', ':', '___EOS___']", "index": 714 }, { "content": " def alarm(self, seconds, callback):\n \"\"\"\n Call callback() given time from from now. No parameters are\n passed to callback.\n\n Returns a handle that may be passed to remove_alarm()\n\n seconds -- floating point time to wait before calling callback\n callback -- function to call from event loop\n \"\"\"\n @self.handle_exit\n def ret_false():\n callback()\n self._enable_glib_idle()\n return False\n fd = self.GLib.timeout_add(int(seconds*1000), ret_false)\n self._alarms.append(fd)\n return (fd, callback)", "metadata": "root.GLibEventLoop.alarm", "header": "['class', 'GLibEventLoop', '(', 'object', ')', ':', '___EOS___']", "index": 726 }, { "content": " def remove_alarm(self, handle):\n \"\"\"\n Remove an alarm.\n\n Returns True if the alarm exists, False otherwise\n \"\"\"\n try:\n self._alarms.remove(handle[0])\n self.GLib.source_remove(handle[0])\n return True\n except ValueError:\n return False", "metadata": "root.GLibEventLoop.remove_alarm", "header": "['class', 'GLibEventLoop', '(', 'object', ')', ':', '___EOS___']", "index": 745 }, { "content": " def watch_file(self, fd, callback):\n \"\"\"\n Call callback() when fd has some data to read. No parameters\n are passed to callback.\n\n Returns a handle that may be passed to remove_watch_file()\n\n fd -- file descriptor to watch for input\n callback -- function to call when input is available\n \"\"\"\n @self.handle_exit\n def io_callback(source, cb_condition):\n callback()\n self._enable_glib_idle()\n return True\n self._watch_files[fd] = \\\n self.GLib.io_add_watch(fd,self.GLib.IO_IN,io_callback)\n return fd", "metadata": "root.GLibEventLoop.watch_file", "header": "['class', 'GLibEventLoop', '(', 'object', ')', ':', '___EOS___']", "index": 758 }, { "content": " def remove_watch_file(self, handle):\n \"\"\"\n Remove an input file.\n\n Returns True if the input file exists, False otherwise\n \"\"\"\n if handle in self._watch_files:\n self.GLib.source_remove(self._watch_files[handle])\n del self._watch_files[handle]\n return True\n return False", "metadata": "root.GLibEventLoop.remove_watch_file", "header": "['class', 'GLibEventLoop', '(', 'object', ')', ':', '___EOS___']", "index": 777 }, { "content": " def enter_idle(self, callback):\n \"\"\"\n Add a callback for entering idle.\n\n Returns a handle that may be passed to remove_enter_idle()\n \"\"\"\n self._idle_handle += 1\n self._idle_callbacks[self._idle_handle] = callback\n return self._idle_handle", "metadata": "root.GLibEventLoop.enter_idle", "header": "['class', 'GLibEventLoop', '(', 'object', ')', ':', '___EOS___']", "index": 789 }, { "content": " def _enable_glib_idle(self):\n if self._glib_idle_enabled:\n return\n self.GLib.idle_add(self._glib_idle_callback)\n self._glib_idle_enabled = True", "metadata": "root.GLibEventLoop._enable_glib_idle", "header": "['class', 'GLibEventLoop', '(', 'object', ')', ':', '___EOS___']", "index": 799 }, { "content": " def _glib_idle_callback(self):\n for callback in self._idle_callbacks.values():\n callback()\n self._glib_idle_enabled = False\n return False # ask glib not to call again (or we would be called", "metadata": "root.GLibEventLoop._glib_idle_callback", "header": "['class', 'GLibEventLoop', '(', 'object', ')', ':', '___EOS___']", "index": 805 }, { "content": " def remove_enter_idle(self, handle):\n \"\"\"\n Remove an idle callback.\n\n Returns True if the handle was removed.\n \"\"\"\n try:\n del self._idle_callbacks[handle]\n except KeyError:\n return False\n return True", "metadata": "root.GLibEventLoop.remove_enter_idle", "header": "['class', 'GLibEventLoop', '(', 'object', ')', ':', '___EOS___']", "index": 811 }, { "content": " def run(self):\n \"\"\"\n Start the event loop. Exit the loop when any callback raises\n an exception. If ExitMainLoop is raised, exit cleanly.\n \"\"\"\n try:\n self._loop.run()\n finally:\n if self._loop.is_running():\n self._loop.quit()\n if self._exc_info:\n # An exception caused us to exit, raise it now\n exc_info = self._exc_info\n self._exc_info = None\n raise exc_info[0], exc_info[1], exc_info[2]", "metadata": "root.GLibEventLoop.run", "header": "['class', 'GLibEventLoop', '(', 'object', ')', ':', '___EOS___']", "index": 823 }, { "content": " def handle_exit(self,f):\n \"\"\"\n Decorator that cleanly exits the :class:`GLibEventLoop` if\n :exc:`ExitMainLoop` is thrown inside of the wrapped function. Store the\n exception info if some other exception occurs, it will be reraised after\n the loop quits.\n\n *f* -- function to be wrapped\n \"\"\"\n def wrapper(*args,**kargs):\n try:\n return f(*args,**kargs)\n except ExitMainLoop:\n self._loop.quit()\n except:\n import sys\n self._exc_info = sys.exc_info()\n if self._loop.is_running():\n self._loop.quit()\n return False\n return wrapper", "metadata": "root.GLibEventLoop.handle_exit", "header": "['class', 'GLibEventLoop', '(', 'object', ')', ':', '___EOS___']", "index": 839 }, { "content": "class TornadoEventLoop(object):\n \"\"\" This is an Urwid-specific event loop to plug into its MainLoop.\n It acts as an adaptor for Tornado's IOLoop which does all\n heavy lifting except idle-callbacks.\n\n Notice, since Tornado has no concept of idle callbacks we\n monkey patch ioloop._impl.poll() function to be able to detect\n potential idle periods.\n \"\"\"\n _ioloop_registry = WeakKeyDictionary() # {<ioloop> : {<handle> : <idle_func>}}\n _max_idle_handle = 0\n\n class PollProxy(object):\n \"\"\" A simple proxy for a Python's poll object that wraps the .poll() method\n in order to detect idle periods and call Urwid callbacks\n \"\"\"\n def __init__(self, poll_obj, idle_map):\n self.__poll_obj = poll_obj\n self.__idle_map = idle_map\n self._idle_done = False\n self._prev_timeout = 0\n\n def __getattr__(self, name):\n return getattr(self.__poll_obj, name)\n\n def poll(self, timeout):\n if timeout > self._prev_timeout:\n # if timeout increased we assume a timer event was handled\n self._idle_done = False\n self._prev_timeout = timeout\n start = time.time()\n\n # any IO pending wins\n events = self.__poll_obj.poll(0)\n if events:\n self._idle_done = False\n return events\n\n # our chance to enter idle\n if not self._idle_done:\n for callback in self.__idle_map.values():\n callback()\n self._idle_done = True\n\n # then complete the actual request (adjusting timeout)\n timeout = max(0, min(timeout, timeout + start - time.time()))\n events = self.__poll_obj.poll(timeout)\n if events:\n self._idle_done = False\n return events\n\n\n\n\n\n\n\n\n\n", "metadata": "root.TornadoEventLoop", "header": "['module', '___EOS___']", "index": 862 }, { "content": " @classmethod\n def _patch_poll_impl(cls, ioloop):\n \"\"\" Wraps original poll object in the IOLoop's poll object\n \"\"\"\n if ioloop in cls._ioloop_registry:\n return # we already patched this instance\n\n cls._ioloop_registry[ioloop] = idle_map = {}\n ioloop._impl = cls.PollProxy(ioloop._impl, idle_map)", "metadata": "root.TornadoEventLoop._patch_poll_impl", "header": "['class', 'TornadoEventLoop', '(', 'object', ')', ':', '___EOS___']", "index": 913 }, { "content": " def __init__(self, ioloop=None):\n if not ioloop:\n from tornado.ioloop import IOLoop\n ioloop = IOLoop.instance()\n self._ioloop = ioloop\n self._patch_poll_impl(ioloop)\n self._pending_alarms = {}\n self._watch_handles = {} # {<watch_handle> : <file_descriptor>}\n self._max_watch_handle = 0\n self._exception = None", "metadata": "root.TornadoEventLoop.__init__", "header": "['class', 'TornadoEventLoop', '(', 'object', ')', ':', '___EOS___']", "index": 923 }, { "content": " def alarm(self, secs, callback):\n ioloop = self._ioloop\n def wrapped():\n try:\n del self._pending_alarms[handle]\n except KeyError:\n pass\n self.handle_exit(callback)()\n handle = ioloop.add_timeout(ioloop.time() + secs, wrapped)\n self._pending_alarms[handle] = 1\n return handle", "metadata": "root.TornadoEventLoop.alarm", "header": "['class', 'TornadoEventLoop', '(', 'object', ')', ':', '___EOS___']", "index": 934 }, { "content": " def remove_alarm(self, handle):\n self._ioloop.remove_timeout(handle)\n try:\n del self._pending_alarms[handle]\n except KeyError:\n return False\n else:\n return True", "metadata": "root.TornadoEventLoop.remove_alarm", "header": "['class', 'TornadoEventLoop', '(', 'object', ')', ':', '___EOS___']", "index": 946 }, { "content": " def watch_file(self, fd, callback):\n from tornado.ioloop import IOLoop\n handler = lambda fd,events: self.handle_exit(callback)()\n self._ioloop.add_handler(fd, handler, IOLoop.READ)\n self._max_watch_handle += 1\n handle = self._max_watch_handle\n self._watch_handles[handle] = fd\n return handle", "metadata": "root.TornadoEventLoop.watch_file", "header": "['class', 'TornadoEventLoop', '(', 'object', ')', ':', '___EOS___']", "index": 955 }, { "content": " def remove_watch_file(self, handle):\n fd = self._watch_handles.pop(handle, None)\n if fd is None:\n return False\n else:\n self._ioloop.remove_handler(fd)\n return True", "metadata": "root.TornadoEventLoop.remove_watch_file", "header": "['class', 'TornadoEventLoop', '(', 'object', ')', ':', '___EOS___']", "index": 964 }, { "content": " def enter_idle(self, callback):\n self._max_idle_handle += 1\n handle = self._max_idle_handle\n idle_map = self._ioloop_registry[self._ioloop]\n idle_map[handle] = callback\n return handle", "metadata": "root.TornadoEventLoop.enter_idle", "header": "['class', 'TornadoEventLoop', '(', 'object', ')', ':', '___EOS___']", "index": 972 }, { "content": " def remove_enter_idle(self, handle):\n idle_map = self._ioloop_registry[self._ioloop]\n cb = idle_map.pop(handle, None)\n return cb is not None", "metadata": "root.TornadoEventLoop.remove_enter_idle", "header": "['class', 'TornadoEventLoop', '(', 'object', ')', ':', '___EOS___']", "index": 979 }, { "content": " def handle_exit(self, func):\n @wraps(func)\n def wrapper(*args, **kw):\n try:\n return func(*args, **kw)\n except ExitMainLoop:\n self._ioloop.stop()\n except Exception as exc:\n self._exception = exc\n self._ioloop.stop()\n return False\n return wrapper", "metadata": "root.TornadoEventLoop.handle_exit", "header": "['class', 'TornadoEventLoop', '(', 'object', ')', ':', '___EOS___']", "index": 984 }, { "content": " def run(self):\n self._ioloop.start()\n if self._exception:\n exc, self._exception = self._exception, None\n raise exc", "metadata": "root.TornadoEventLoop.run", "header": "['class', 'TornadoEventLoop', '(', 'object', ')', ':', '___EOS___']", "index": 997 }, { "content": "class TwistedInputDescriptor(FileDescriptor):\n\n", "metadata": "root.TwistedInputDescriptor", "header": "['module', '___EOS___']", "index": 1009 }, { "content": " def __init__(self, reactor, fd, cb):\n self._fileno = fd\n self.cb = cb\n FileDescriptor.__init__(self, reactor)", "metadata": "root.TwistedInputDescriptor.__init__", "header": "['class', 'TwistedInputDescriptor', '(', 'FileDescriptor', ')', ':', '___EOS___']", "index": 1010 }, { "content": " def fileno(self):\n return self._fileno", "metadata": "root.TwistedInputDescriptor.fileno", "header": "['class', 'TwistedInputDescriptor', '(', 'FileDescriptor', ')', ':', '___EOS___']", "index": 1015 }, { "content": " def doRead(self):\n return self.cb()", "metadata": "root.TwistedInputDescriptor.doRead", "header": "['class', 'TwistedInputDescriptor', '(', 'FileDescriptor', ')', ':', '___EOS___']", "index": 1018 }, { "content": "class TwistedEventLoop(object):\n \"\"\"\n Event loop based on Twisted_\n \"\"\"\n _idle_emulation_delay = 1.0/256 # a short time (in seconds)\n\n\n\n\n\n\n\n\n\n\n", "metadata": "root.TwistedEventLoop", "header": "['module', '___EOS___']", "index": 1022 }, { "content": " def __init__(self, reactor=None, manage_reactor=True):\n \"\"\"\n :param reactor: reactor to use\n :type reactor: :class:`twisted.internet.reactor`.\n :param: manage_reactor: `True` if you want this event loop to run\n and stop the reactor.\n :type manage_reactor: boolean\n\n .. WARNING::\n Twisted's reactor doesn't like to be stopped and run again. If you\n need to stop and run your :class:`MainLoop`, consider setting\n ``manage_reactor=False`` and take care of running/stopping the reactor\n at the beginning/ending of your program yourself.\n\n .. _Twisted: http://twistedmatrix.com/trac/\n \"\"\"\n if reactor is None:\n import twisted.internet.reactor\n reactor = twisted.internet.reactor\n self.reactor = reactor\n self._alarms = []\n self._watch_files = {}\n self._idle_handle = 0\n self._twisted_idle_enabled = False\n self._idle_callbacks = {}\n self._exc_info = None\n self.manage_reactor = manage_reactor\n self._enable_twisted_idle()", "metadata": "root.TwistedEventLoop.__init__", "header": "['class', 'TwistedEventLoop', '(', 'object', ')', ':', '___EOS___']", "index": 1028 }, { "content": " def alarm(self, seconds, callback):\n \"\"\"\n Call callback() given time from from now. No parameters are\n passed to callback.\n\n Returns a handle that may be passed to remove_alarm()\n\n seconds -- floating point time to wait before calling callback\n callback -- function to call from event loop\n \"\"\"\n handle = self.reactor.callLater(seconds, self.handle_exit(callback))\n return handle", "metadata": "root.TwistedEventLoop.alarm", "header": "['class', 'TwistedEventLoop', '(', 'object', ')', ':', '___EOS___']", "index": 1057 }, { "content": " def remove_alarm(self, handle):\n \"\"\"\n Remove an alarm.\n\n Returns True if the alarm exists, False otherwise\n \"\"\"\n from twisted.internet.error import AlreadyCancelled, AlreadyCalled\n try:\n handle.cancel()\n return True\n except AlreadyCancelled:\n return False\n except AlreadyCalled:\n return False", "metadata": "root.TwistedEventLoop.remove_alarm", "header": "['class', 'TwistedEventLoop', '(', 'object', ')', ':', '___EOS___']", "index": 1070 }, { "content": " def watch_file(self, fd, callback):\n \"\"\"\n Call callback() when fd has some data to read. No parameters\n are passed to callback.\n\n Returns a handle that may be passed to remove_watch_file()\n\n fd -- file descriptor to watch for input\n callback -- function to call when input is available\n \"\"\"\n ind = TwistedInputDescriptor(self.reactor, fd,\n self.handle_exit(callback))\n self._watch_files[fd] = ind\n self.reactor.addReader(ind)\n return fd", "metadata": "root.TwistedEventLoop.watch_file", "header": "['class', 'TwistedEventLoop', '(', 'object', ')', ':', '___EOS___']", "index": 1085 }, { "content": " def remove_watch_file(self, handle):\n \"\"\"\n Remove an input file.\n\n Returns True if the input file exists, False otherwise\n \"\"\"\n if handle in self._watch_files:\n self.reactor.removeReader(self._watch_files[handle])\n del self._watch_files[handle]\n return True\n return False", "metadata": "root.TwistedEventLoop.remove_watch_file", "header": "['class', 'TwistedEventLoop', '(', 'object', ')', ':', '___EOS___']", "index": 1101 }, { "content": " def enter_idle(self, callback):\n \"\"\"\n Add a callback for entering idle.\n\n Returns a handle that may be passed to remove_enter_idle()\n \"\"\"\n self._idle_handle += 1\n self._idle_callbacks[self._idle_handle] = callback\n return self._idle_handle", "metadata": "root.TwistedEventLoop.enter_idle", "header": "['class', 'TwistedEventLoop', '(', 'object', ')', ':', '___EOS___']", "index": 1113 }, { "content": " def _enable_twisted_idle(self):\n \"\"\"\n Twisted's reactors don't have an idle or enter-idle callback\n so the best we can do for now is to set a timer event in a very\n short time to approximate an enter-idle callback.\n\n .. WARNING::\n This will perform worse than the other event loops until we can find a\n fix or workaround\n \"\"\"\n if self._twisted_idle_enabled:\n return\n self.reactor.callLater(self._idle_emulation_delay,\n self.handle_exit(self._twisted_idle_callback, enable_idle=False))\n self._twisted_idle_enabled = True", "metadata": "root.TwistedEventLoop._enable_twisted_idle", "header": "['class', 'TwistedEventLoop', '(', 'object', ')', ':', '___EOS___']", "index": 1123 }, { "content": " def _twisted_idle_callback(self):\n for callback in self._idle_callbacks.values():\n callback()\n self._twisted_idle_enabled = False", "metadata": "root.TwistedEventLoop._twisted_idle_callback", "header": "['class', 'TwistedEventLoop', '(', 'object', ')', ':', '___EOS___']", "index": 1139 }, { "content": " def remove_enter_idle(self, handle):\n \"\"\"\n Remove an idle callback.\n\n Returns True if the handle was removed.\n \"\"\"\n try:\n del self._idle_callbacks[handle]\n except KeyError:\n return False\n return True", "metadata": "root.TwistedEventLoop.remove_enter_idle", "header": "['class', 'TwistedEventLoop', '(', 'object', ')', ':', '___EOS___']", "index": 1144 }, { "content": " def run(self):\n \"\"\"\n Start the event loop. Exit the loop when any callback raises\n an exception. If ExitMainLoop is raised, exit cleanly.\n \"\"\"\n if not self.manage_reactor:\n return\n self.reactor.run()\n if self._exc_info:\n # An exception caused us to exit, raise it now\n exc_info = self._exc_info\n self._exc_info = None\n raise exc_info[0], exc_info[1], exc_info[2]", "metadata": "root.TwistedEventLoop.run", "header": "['class', 'TwistedEventLoop', '(', 'object', ')', ':', '___EOS___']", "index": 1156 }, { "content": " def handle_exit(self, f, enable_idle=True):\n \"\"\"\n Decorator that cleanly exits the :class:`TwistedEventLoop` if\n :class:`ExitMainLoop` is thrown inside of the wrapped function. Store the\n exception info if some other exception occurs, it will be reraised after\n the loop quits.\n\n *f* -- function to be wrapped\n \"\"\"\n def wrapper(*args,**kargs):\n rval = None\n try:\n rval = f(*args,**kargs)\n except ExitMainLoop:\n if self.manage_reactor:\n self.reactor.stop()\n except:\n import sys\n print sys.exc_info()\n self._exc_info = sys.exc_info()\n if self.manage_reactor:\n self.reactor.crash()\n if enable_idle:\n self._enable_twisted_idle()\n return rval\n return wrapper", "metadata": "root.TwistedEventLoop.handle_exit", "header": "['class', 'TwistedEventLoop', '(', 'object', ')', ':', '___EOS___']", "index": 1170 }, { "content": "def _refl(name, rval=None, exit=False):\n \"\"\"\n This function is used to test the main loop classes.\n\n >>> scr = _refl(\"screen\")\n >>> scr.function(\"argument\")\n screen.function('argument')\n >>> scr.callme(when=\"now\")\n screen.callme(when='now')\n >>> scr.want_something_rval = 42\n >>> x = scr.want_something()\n screen.want_something()\n >>> x\n 42\n\n \"\"\"\n class Reflect(object):\n def __init__(self, name, rval=None):\n self._name = name\n self._rval = rval\n def __call__(self, *argl, **argd):\n args = \", \".join([repr(a) for a in argl])\n if args and argd:\n args = args + \", \"\n args = args + \", \".join([k+\"=\"+repr(v) for k,v in argd.items()])\n print self._name+\"(\"+args+\")\"\n if exit:\n raise ExitMainLoop()\n return self._rval\n def __getattr__(self, attr):\n if attr.endswith(\"_rval\"):\n raise AttributeError()\n #print self._name+\".\"+attr\n if hasattr(self, attr+\"_rval\"):\n return Reflect(self._name+\".\"+attr, getattr(self, attr+\"_rval\"))\n return Reflect(self._name+\".\"+attr)\n return Reflect(name)", "metadata": "root._refl", "header": "['module', '___EOS___']", "index": 1199 }, { "content": "def _test():\n import doctest\n doctest.testmod()", "metadata": "root._test", "header": "['module', '___EOS___']", "index": 1237 } ]
[ { "span": "from urwid.compat import PYTHON3", "start_line": 33, "start_column": 0, "end_line": 33, "end_column": 32 } ]
[]
1
false
[ "[CLS]_", "Un", "used_", "import_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "#!", "/", "usr", "/", "bin", "/", "python_", "\\u\\u\\uNL\\u\\u\\u_", "#", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Ur", "wid", " ", "main", " ", "loop", " ", "code_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", " ", " ", " ", "Copy", "right", " ", "(", "C", ")", " ", "2004", "-", "2012", " ", " ", "Ia", "n", " ", "War", "d_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", " ", " ", " ", "Copy", "right", " ", "(", "C", ")", " ", "2008", " ", "Wal", "ter", " ", "Mun", "dt_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", " ", " ", " ", "Copy", "right", " ", "(", "C", ")", " ", "200", "9", " ", "Andre", "w", " ", "Ps", "alti", "s_", "\\u\\u\\uNL\\u\\u\\u_", "#", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", " ", " ", " ", "Thi", "s", " ", "librar", "y", " ", "is", " ", "free", " ", "software", ";", " ", "you", " ", "can", " ", "redis", "tribut", "e", " ", "it", " ", "and", "/", "or_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", " ", " ", " ", "modif", "y", " ", "it", " ", "under", " ", "the", " ", "term", "s", " ", "of", " ", "the", " ", "GN", "U", " ", "Less", "er", " ", "General", " ", "Public", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", " ", " ", " ", "License", " ", "as", " ", "publi", "shed", " ", "by", " ", "the", " ", "Free", " ", "Sof", "twa", "re", " ", "Foun", "dati", "on", ";", " ", "eit", "her_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", " ", " ", " ", "version", " ", "2.1", " ", "of", " ", "the", " ", "License", ",", " ", "or", " ", "(", "at", " ", "your", " ", "option", ")", " ", "any", " ", "late", "r", " ", "version", "._", "\\u\\u\\uNL\\u\\u\\u_", "#", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", " ", " ", " ", "Thi", "s", " ", "librar", "y", " ", "is", " ", "distributed", " ", "in", " ", "the", " ", "hop", "e", " ", "tha", "t", " ", "it", " ", "will", " ", "be", " ", "usef", "ul", ",_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", " ", " ", " ", "but", " ", "WITH", "OUT", " ", "ANY", " ", "WAR", "RAN", "TY", ";", " ", "with", "out", " ", "even", " ", "the", " ", "impli", "ed", " ", "warr", "ant", "y", " ", "of_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", " ", " ", " ", "MER", "CHAN", "TAB", "ILI", "TY", " ", "or", " ", "FIT", "NESS", " ", "FOR", " ", "A", " ", "PARTI", "CUL", "AR", " ", "PUR", "POS", "E", ".", " ", " ", "See", " ", "the", " ", "GN", "U_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", " ", " ", " ", "Less", "er", " ", "General", " ", "Public", " ", "License", " ", "for", " ", "more", " ", "deta", "il", "s", "._", "\\u\\u\\uNL\\u\\u\\u_", "#", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", " ", " ", " ", "You", " ", "shou", "ld", " ", "have", " ", "receive", "d", " ", "a", " ", "copy", " ", "of", " ", "the", " ", "GN", "U", " ", "Less", "er", " ", "General", " ", "Public", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", " ", " ", " ", "License", " ", "along", " ", "with", " ", "this", " ", "librar", "y", ";", " ", "if", " ", "not", ",", " ", "write", " ", "to", " ", "the", " ", "Free", " ", "Sof", "twa", "re_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", " ", " ", " ", "Foun", "dati", "on", ",", " ", "Inc", ".,", " ", "5", "9", " ", "Temp", "le", " ", "Place", ",", " ", "Suit", "e", " ", "330", ",", " ", "Bo", "ston", ",", " ", "MA", " ", " ", "0211", "1", "-1", "307", " ", " ", "USA", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Ur", "wid", " ", "web", " ", "site", ":", " ", "http", "://", "excess", ".", "org", "/", "ur", "wid", "/_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "import_", "time_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "heapq_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "select_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "fcntl_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "os_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "functools_", "import_", "wraps_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "weakref_", "import_", "Wea", "k", "Key", "Dictionary_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "from_", "urwid_", "._", "util_", "import_", "is", "\\u", "mouse", "\\u", "event_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "urwid_", "._", "compat_", "import_", "PYTHON", "3_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "urwid_", "._", "command", "\\u", "map_", "import_", "command", "\\u", "map_", ",_", "RED", "RA", "W", "\\u", "SCREEN", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "urwid_", "._", "wi", "mp_", "import_", "Pop", "Up", "Target_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "urwid_", "import_", "signals_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "urwid_", "._", "display", "\\u", "common_", "import_", "INPUT", "\\u", "DESCRIPT", "ORS", "\\u", "CHANGED", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "PIPE", "\\u", "BUFF", "ER", "\\u", "READ", "\\u", "SIZE_", "=_", "4096_", "#", " ", "can", " ", "expect", " ", "this", " ", "muc", "h", " ", "on", " ", "Lin", "ux", ",", " ", "so", " ", "try", " ", "for", " ", "that_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "from_", "twisted_", "._", "internet_", "._", "abstract_", "import_", "File", "Descriptor_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "Import", "Error_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "File", "Descriptor_", "=_", "object_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "\\u\\u", "name\\u\\u_", "==_", "'\\u", "\\u", "main", "\\u\\u'_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\\u", "test_", "(_", ")_", "\\u\\u\\uDEDENT\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "class_", "Exi", "t", "Main", "Loop_", "(_", "Exception_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Whe", "n", " ", "this", " ", "exception", " ", "is", " ", "raise", "d", " ", "within", " ", "a", " ", "main", " ", "loop", " ", "the", " ", "main", " ", "loop", "\\", "10", ";", " ", " ", " ", " ", "will", " ", "exit", " ", "clean", "ly", ".", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "pass_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "class_", "Main", "Loop_", "(_", "object_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Thi", "s", " ", "is", " ", "the", " ", "standard", " ", "main", " ", "loop", " ", "implementation", " ", "for", " ", "a", " ", "single", " ", "interactive", "\\", "10", ";", " ", " ", " ", " ", "session", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", ":", "param", " ", "widget", ":", " ", "the", " ", "top", "most", " ", "widget", " ", "used", " ", "for", " ", "pain", "ting", " ", "the", " ", "screen", ",", " ", "store", "d", " ", "as", "\\", "10", ";", " ", ":", "attr", ":`", "widget", "`", " ", "and", " ", "may", " ", "be", " ", "modifi", "ed", ".", " ", "Mus", "t", " ", "be", " ", "a", " ", "box", " ", "widget", ".", "\\", "10", ";", " ", " ", " ", " ", ":", "type", " ", "widget", ":", " ", "widget", " ", "instance", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", ":", "param", " ", "palette", ":", " ", "initial", " ", "palette", " ", "for", " ", "screen", "\\", "10", ";", " ", " ", " ", " ", ":", "type", " ", "palette", ":", " ", "iterable", " ", "of", " ", "palette", " ", "entri", "es", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", ":", "param", " ", "screen", ":", " ", "screen", " ", "to", " ", "use", ",", " ", "default", " ", "is", " ", "a", " ", "new", " ", ":", "class", ":`", "raw", "\\u", "display", ".", "Scr", "een", "`", "\\", "10", ";", " ", "instance", ";", " ", "store", "d", " ", "as", " ", ":", "attr", ":`", "screen", "`", "\\", "10", ";", " ", " ", " ", " ", ":", "type", " ", "screen", ":", " ", "display", " ", "module", " ", "screen", " ", "instance", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", ":", "param", " ", "handle", "\\u", "mouse", ":", " ", "``", "Tru", "e", "``", " ", "to", " ", "ask", " ", ":", "attr", ":`", ".", "screen", "`", " ", "to", " ", "process", " ", "mouse", " ", "events", "\\", "10", ";", " ", " ", " ", " ", ":", "type", " ", "handle", "\\u", "mouse", ":", " ", "bool", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", ":", "param", " ", "input", "\\u", "filter", ":", " ", "a", " ", "function", " ", "to", " ", "filter", " ", "input", " ", "bef", "ore", " ", "sendin", "g", " ", "it", " ", "to", "\\", "10", ";", " ", ":", "attr", ":`", ".", "widget", "`", ",", " ", "call", "ed", " ", "from", " ", ":", "meth", ":`", ".", "input", "\\u", "filter", "`", "\\", "10", ";", " ", " ", " ", " ", ":", "type", " ", "input", "\\u", "filter", ":", " ", "calla", "ble", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", ":", "param", " ", "unhandled", "\\u", "input", ":", " ", "a", " ", "function", " ", "call", "ed", " ", "whe", "n", " ", "input", " ", "is", " ", "not", " ", "handle", "d", " ", "by", "\\", "10", ";", " ", " ", " ", " ", " ", " ", ":", "attr", ":`", ".", "widget", "`", ",", " ", "call", "ed", " ", "from", " ", ":", "meth", ":`", ".", "unhandled", "\\u", "input", "`", "\\", "10", ";", " ", " ", " ", " ", ":", "type", " ", "unhandled", "\\u", "input", ":", " ", "calla", "ble", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", ":", "param", " ", "event", "\\u", "loop", ":", " ", "if", " ", ":", "attr", ":`", ".", "screen", "`", " ", "support", "s", " ", "external", " ", "an", " ", "event", " ", "loop", " ", "it", " ", "may", " ", "be", "\\", "10", ";", " ", " ", " ", " ", " ", "give", "n", " ", "here", ",", " ", "default", " ", "is", " ", "a", " ", "new", " ", ":", "class", ":`", "Select", "Event", "Loop", "`", " ", "instance", ";", "\\", "10", ";", " ", " ", " ", " ", " ", "store", "d", " ", "as", " ", ":", "attr", ":`", ".", "event", "\\u", "loop", "`", "\\", "10", ";", " ", " ", " ", " ", ":", "type", " ", "event", "\\u", "loop", ":", " ", "event", " ", "loop", " ", "instance", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", ":", "param", " ", "pop", "\\u", "ups", ":", " ", "`", "Tru", "e", "`", " ", "to", " ", "wrap", " ", ":", "attr", ":`", ".", "widget", "`", " ", "with", " ", "a", " ", ":", "class", ":`", "Pop", "Up", "Target", "`", "\\", "10", ";", " ", " ", "instance", " ", "to", " ", "allow", " ", "any", " ", "widget", " ", "to", " ", "open", " ", "a", " ", "pop", "-", "up", " ", "any", "where", " ", "on", " ", "the", " ", "screen", "\\", "10", ";", " ", " ", " ", " ", ":", "type", " ", "pop", "\\u", "ups", ":", " ", "boolean", "\\", "10", ";", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "..", " ", "attribute", "::", " ", "screen", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "The", " ", "screen", " ", "object", " ", "this", " ", "main", " ", "loop", " ", "use", "s", " ", "for", " ", "screen", " ", "update", "s", " ", "and", " ", "readi", "ng", " ", "input", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "..", " ", "attribute", "::", " ", "event", "\\u", "loop", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "The", " ", "event", " ", "loop", " ", "object", " ", "this", " ", "main", " ", "loop", " ", "use", "s", " ", "for", " ", "wait", "ing", " ", "on", " ", "alarms", " ", "and", " ", "IO", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "widget_", "=_", "property_", "(_", "lambda_", "self_", ":_", "self_", "._", "\\u", "widget_", ",_", "\\u", "set\\u", "widget_", ",_", "doc_", "=_", "\\u\\u\\uNL\\u\\u\\u_", "\"\"\"", "\\", "10", ";", " ", " ", " ", "Proper", "ty", " ", "for", " ", "the", " ", "top", "most", " ", "widget", " ", "used", " ", "to", " ", "draw", " ", "the", " ", "screen", ".", "\\", "10", ";", " ", " ", " ", "Thi", "s", " ", "must", " ", "be", " ", "a", " ", "box", " ", "widget", ".", "\\", "10", ";", " ", " ", " ", "\"\"\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "pop", "\\u", "ups_", "=_", "property_", "(_", "lambda_", "self_", ":_", "self_", "._", "\\u", "pop", "\\u", "ups_", ",_", "\\u", "set\\u", "pop", "\\u", "ups_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "[SEP]_", "class_", "Main", "Loop_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "\\u\\u", "init\\u\\u_", "(_", "self_", ",_", "widget_", ",_", "palette_", "=_", "(_", ")_", ",_", "screen_", "=_", "None_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "handle", "\\u", "mouse_", "=_", "True_", ",_", "input", "\\u", "filter_", "=_", "None_", ",_", "unhandled", "\\u", "input_", "=_", "None_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "event", "\\u", "loop_", "=_", "None_", ",_", "pop", "\\u", "ups_", "=_", "False_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "\\u", "widget_", "=_", "widget_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "handle", "\\u", "mouse_", "=_", "handle", "\\u", "mouse_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "pop", "\\u", "ups_", "=_", "pop", "\\u", "ups_", "#", " ", "trigger", "s", " ", "property", " ", "setti", "ng", " ", "side", "-", "effect_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "not_", "screen_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "from_", "urwid_", "import_", "raw", "\\u", "display_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "screen_", "=_", "raw", "\\u", "display_", "._", "Screen_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "palette_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "screen_", "._", "register", "\\u", "palette_", "(_", "palette_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "screen_", "=_", "screen_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "screen", "\\u", "size_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "\\u", "unhandled", "\\u", "input_", "=_", "unhandled", "\\u", "input_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "\\u", "input", "\\u", "filter_", "=_", "input", "\\u", "filter_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "not_", "hasattr_", "(_", "screen_", ",_", "'", "get", "\\u", "input", "\\u", "descrip", "tors", "'_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "and_", "event", "\\u", "loop_", "is_", "not_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "raise_", "Not", "Impl", "ement", "ed", "Error_", "(_", "\"", "screen", " ", "object", " ", "pass", "ed", " ", "\"_", "\\u\\u\\uNL\\u\\u\\u_", "\"%", "r", " ", "doe", "s", " ", "not", " ", "support", " ", "external", " ", "event", " ", "loop", "s", "\"_", "%_", "(_", "screen_", ",_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "event", "\\u", "loop_", "is_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "event", "\\u", "loop_", "=_", "Select", "Event", "Loop_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "event", "\\u", "loop_", "=_", "event", "\\u", "loop_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "\\u", "input", "\\u", "timeout_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "\\u", "watch", "\\u", "pipes_", "=_", "{_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Main", "Loop_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "\\u", "set\\u", "widget_", "(_", "self_", ",_", "widget_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "\\u", "widget_", "=_", "widget_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "self_", "._", "pop", "\\u", "ups_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "\\u", "top", "most", "\\u", "widget_", "._", "original", "\\u", "widget_", "=_", "self_", "._", "\\u", "widget_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "\\u", "top", "most", "\\u", "widget_", "=_", "self_", "._", "\\u", "widget_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Main", "Loop_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "\\u", "set\\u", "pop", "\\u", "ups_", "(_", "self_", ",_", "pop", "\\u", "ups_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "\\u", "pop", "\\u", "ups_", "=_", "pop", "\\u", "ups_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "pop", "\\u", "ups_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "\\u", "top", "most", "\\u", "widget_", "=_", "Pop", "Up", "Target_", "(_", "self_", "._", "\\u", "widget_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "\\u", "top", "most", "\\u", "widget_", "=_", "self_", "._", "\\u", "widget_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Main", "Loop_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "set\\u", "alarm", "\\u", "in_", "(_", "self_", ",_", "sec_", ",_", "callback_", ",_", "user", "\\u", "data_", "=_", "None_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Schedule", " ", "an", " ", "alarm", " ", "in", " ", "*", "sec", "*", " ", "second", "s", " ", "tha", "t", " ", "will", " ", "call", " ", "*", "callback", "*", " ", "from", " ", "the", "\\", "10", ";", " ", " ", " ", " ", "within", " ", "the", " ", ":", "meth", ":`", "run", "`", " ", "method", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", ":", "param", " ", "sec", ":", " ", "second", "s", " ", "unti", "l", " ", "alarm", "\\", "10", ";", " ", " ", " ", " ", ":", "type", " ", "sec", ":", " ", "float", "\\", "10", ";", " ", " ", " ", " ", ":", "param", " ", "callback", ":", " ", "function", " ", "to", " ", "call", " ", "with", " ", "two", " ", "parameter", "s", ":", " ", "this", " ", "main", " ", "loop", "\\", "10", ";", " ", " ", " ", "object", " ", "and", " ", "*", "user", "\\u", "data", "*", "\\", "10", ";", " ", " ", " ", " ", ":", "type", " ", "callback", ":", " ", "calla", "ble", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "cb_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "callback_", "(_", "self_", ",_", "user", "\\u", "data_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "self_", "._", "event", "\\u", "loop_", "._", "alarm_", "(_", "sec_", ",_", "cb_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Main", "Loop_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "set\\u", "alarm", "\\u", "at_", "(_", "self_", ",_", "tm_", ",_", "callback_", ",_", "user", "\\u", "data_", "=_", "None_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Schedule", " ", "an", " ", "alarm", " ", "at", " ", "*", "tm", "*", " ", "time", " ", "tha", "t", " ", "will", " ", "call", " ", "*", "callback", "*", " ", "from", " ", "the", "\\", "10", ";", " ", " ", " ", " ", "within", " ", "the", " ", ":", "meth", ":`", "run", "`", " ", "function", ".", " ", "Return", "s", " ", "a", " ", "handle", " ", "tha", "t", " ", "may", " ", "be", " ", "pass", "ed", " ", "to", "\\", "10", ";", " ", " ", " ", " ", ":", "meth", ":`", "remove", "\\u", "alarm", "`.", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", ":", "param", " ", "tm", ":", " ", "time", " ", "to", " ", "call", " ", "callback", " ", "e", ".", "g", ".", " ", "``", "time", ".", "time", "()", " ", "+", " ", "5", "``", "\\", "10", ";", " ", " ", " ", " ", ":", "type", " ", "tm", ":", " ", "float", "\\", "10", ";", " ", " ", " ", " ", ":", "param", " ", "callback", ":", " ", "function", " ", "to", " ", "call", " ", "with", " ", "two", " ", "parameter", "s", ":", " ", "this", " ", "main", " ", "loop", "\\", "10", ";", " ", " ", " ", "object", " ", "and", " ", "*", "user", "\\u", "data", "*", "\\", "10", ";", " ", " ", " ", " ", ":", "type", " ", "callback", ":", " ", "calla", "ble", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "cb_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "callback_", "(_", "self_", ",_", "user", "\\u", "data_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "self_", "._", "event", "\\u", "loop_", "._", "alarm_", "(_", "tm_", "-_", "time_", "._", "time_", "(_", ")_", ",_", "cb_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Main", "Loop_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "remove", "\\u", "alarm_", "(_", "self_", ",_", "handle_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Remove", " ", "an", " ", "alarm", ".", " ", "Return", " ", "``", "Tru", "e", "``", " ", "if", " ", "*", "handle", "*", " ", "was", " ", "found", ",", " ", "``", "Fal", "se", "``", "\\", "10", ";", " ", " ", " ", " ", "other", "wis", "e", ".", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "self_", "._", "event", "\\u", "loop_", "._", "remove", "\\u", "alarm_", "(_", "handle_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Main", "Loop_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "watch", "\\u", "pipe_", "(_", "self_", ",_", "callback_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Creat", "e", " ", "a", " ", "pipe", " ", "for", " ", "use", " ", "by", " ", "a", " ", "subproc", "ess", " ", "or", " ", "thread", " ", "to", " ", "trigger", " ", "a", " ", "callback", "\\", "10", ";", " ", " ", " ", " ", "in", " ", "the", " ", "process", "/", "thread", " ", "runn", "ing", " ", "the", " ", "main", " ", "loop", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", ":", "param", " ", "callback", ":", " ", "function", " ", "tak", "ing", " ", "one", " ", "parameter", " ", "to", " ", "call", " ", "from", " ", "within", "\\", "10", ";", " ", " ", " ", "the", " ", "process", "/", "thread", " ", "runn", "ing", " ", "the", " ", "main", " ", "loop", "\\", "10", ";", " ", " ", " ", " ", ":", "type", " ", "callback", ":", " ", "calla", "ble", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "Thi", "s", " ", "method", " ", "return", "s", " ", "a", " ", "file", " ", "descrip", "tor", " ", "attache", "d", " ", "to", " ", "the", " ", "write", " ", "end", " ", "of", " ", "a", "\\", "10", ";", " ", " ", " ", " ", "pipe", ".", " ", "The", " ", "read", " ", "end", " ", "of", " ", "the", " ", "pipe", " ", "is", " ", "adde", "d", " ", "to", " ", "the", " ", "list", " ", "of", " ", "files", "\\", "10", ";", " ", " ", " ", " ", ":", "attr", ":`", "event", "\\u", "loop", "`", " ", "is", " ", "watch", "ing", ".", " ", "Whe", "n", " ", "data", " ", "is", " ", "writt", "en", " ", "to", " ", "the", " ", "pipe", " ", "the", "\\", "10", ";", " ", " ", " ", " ", "callback", " ", "function", " ", "will", " ", "be", " ", "call", "ed", " ", "and", " ", "pass", "ed", " ", "a", " ", "single", " ", "value", " ", "contain", "ing", "\\", "10", ";", " ", " ", " ", " ", "data", " ", "read", " ", "from", " ", "the", " ", "pipe", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "Thi", "s", " ", "method", " ", "may", " ", "be", " ", "used", " ", "any", " ", "time", " ", "you", " ", "want", " ", "to", " ", "update", " ", "widget", "s", " ", "from", "\\", "10", ";", " ", " ", " ", " ", "anot", "her", " ", "thread", " ", "or", " ", "subproc", "ess", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "Data", " ", "may", " ", "be", " ", "writt", "en", " ", "to", " ", "the", " ", "return", "ed", " ", "file", " ", "descrip", "tor", " ", "with", "\\", "10", ";", " ", " ", " ", " ", "``", "os", ".", "write", "(", "fd", ",", " ", "data", ")``.", " ", "Ensur", "e", " ", "tha", "t", " ", "data", " ", "is", " ", "less", " ", "than", " ", "512", " ", "bytes", " ", "(", "or", " ", "4", "K", "\\", "10", ";", " ", " ", " ", " ", "on", " ", "Lin", "ux", ")", " ", "so", " ", "tha", "t", " ", "the", " ", "callback", " ", "will", " ", "be", " ", "trigger", "ed", " ", "just", " ", "onc", "e", " ", "with", " ", "the", "\\", "10", ";", " ", " ", " ", " ", "complete", " ", "value", " ", "of", " ", "data", " ", "pass", "ed", " ", "in", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "If", " ", "the", " ", "callback", " ", "return", "s", " ", "``", "Fal", "se", "``", " ", "then", " ", "the", " ", "watch", " ", "will", " ", "be", " ", "remove", "d", " ", "from", "\\", "10", ";", " ", " ", " ", " ", ":", "attr", ":`", "event", "\\u", "loop", "`", " ", "and", " ", "the", " ", "read", " ", "end", " ", "of", " ", "the", " ", "pipe", " ", "will", " ", "be", " ", "close", "d", ".", " ", "You", "\\", "10", ";", " ", " ", " ", " ", "are", " ", "responsib", "le", " ", "for", " ", "clos", "ing", " ", "the", " ", "write", " ", "end", " ", "of", " ", "the", " ", "pipe", " ", "with", "\\", "10", ";", " ", " ", " ", " ", "``", "os", ".", "close", "(", "fd", ")``.", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "pipe", "\\u", "rd_", ",_", "pipe", "\\u", "wr_", "=_", "os_", "._", "pipe_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "fcntl_", "._", "fcntl_", "(_", "pipe", "\\u", "rd_", ",_", "fcntl_", "._", "F", "\\u", "SET", "FL", "_", ",_", "os_", "._", "O", "\\u", "NON", "BLOCK_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "watch", "\\u", "handle_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "cb_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "data_", "=_", "os_", "._", "read_", "(_", "pipe", "\\u", "rd_", ",_", "PIPE", "\\u", "BUFF", "ER", "\\u", "READ", "\\u", "SIZE_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "rval_", "=_", "callback_", "(_", "data_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "rval_", "is_", "False_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "event", "\\u", "loop_", "._", "remove", "\\u", "watch", "\\u", "file_", "(_", "watch", "\\u", "handle_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "os_", "._", "close_", "(_", "pipe", "\\u", "rd_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "watch", "\\u", "handle_", "=_", "self_", "._", "event", "\\u", "loop_", "._", "watch", "\\u", "file_", "(_", "pipe", "\\u", "rd_", ",_", "cb_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "\\u", "watch", "\\u", "pipes_", "[_", "pipe", "\\u", "wr_", "]_", "=_", "(_", "watch", "\\u", "handle_", ",_", "pipe", "\\u", "rd_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "pipe", "\\u", "wr_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Main", "Loop_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "remove", "\\u", "watch", "\\u", "pipe_", "(_", "self_", ",_", "write", "\\u", "fd_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Clos", "e", " ", "the", " ", "read", " ", "end", " ", "of", " ", "the", " ", "pipe", " ", "and", " ", "remove", " ", "the", " ", "watch", " ", "created", " ", "by", "\\", "10", ";", " ", " ", " ", " ", ":", "meth", ":`", "watch", "\\u", "pipe", "`.", " ", "You", " ", "are", " ", "responsib", "le", " ", "for", " ", "clos", "ing", " ", "the", " ", "write", " ", "end", " ", "of", "\\", "10", ";", " ", " ", " ", " ", "the", " ", "pipe", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "Return", "s", " ", "``", "Tru", "e", "``", " ", "if", " ", "the", " ", "watch", " ", "pipe", " ", "exist", "s", ",", " ", "``", "Fal", "se", "``", " ", "other", "wis", "e", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "watch", "\\u", "handle_", ",_", "pipe", "\\u", "rd_", "=_", "self_", "._", "\\u", "watch", "\\u", "pipes_", "._", "pop_", "(_", "write", "\\u", "fd_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "Key", "Error_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "not_", "self_", "._", "event", "\\u", "loop_", "._", "remove", "\\u", "watch", "\\u", "file_", "(_", "watch", "\\u", "handle_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "os_", "._", "close_", "(_", "pipe", "\\u", "rd_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Main", "Loop_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "watch", "\\u", "file_", "(_", "self_", ",_", "fd_", ",_", "callback_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Call", " ", "*", "callback", "*", " ", "whe", "n", " ", "*", "fd", "*", " ", "has", " ", "some", " ", "data", " ", "to", " ", "read", ".", " ", "No", " ", "parameter", "s", " ", "are", "\\", "10", ";", " ", " ", " ", " ", "pass", "ed", " ", "to", " ", "callback", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "Return", "s", " ", "a", " ", "handle", " ", "tha", "t", " ", "may", " ", "be", " ", "pass", "ed", " ", "to", " ", ":", "meth", ":`", "remove", "\\u", "watch", "\\u", "file", "`.", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "self_", "._", "event", "\\u", "loop_", "._", "watch", "\\u", "file_", "(_", "fd_", ",_", "callback_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Main", "Loop_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "remove", "\\u", "watch", "\\u", "file_", "(_", "self_", ",_", "handle_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Remove", " ", "a", " ", "watch", " ", "file", ".", " ", "Return", "s", " ", "``", "Tru", "e", "``", " ", "if", " ", "the", " ", "watch", " ", "file", "\\", "10", ";", " ", " ", " ", " ", "exist", "s", ",", " ", "``", "Fal", "se", "``", " ", "other", "wis", "e", ".", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "self_", "._", "event", "\\u", "loop_", "._", "remove", "\\u", "watch", "\\u", "file_", "(_", "handle_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Main", "Loop_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "run_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Start", " ", "the", " ", "main", " ", "loop", " ", "handling", " ", "input", " ", "events", " ", "and", " ", "updat", "ing", " ", "the", " ", "screen", ".", " ", "The", "\\", "10", ";", " ", " ", " ", " ", "loop", " ", "will", " ", "continue", " ", "unti", "l", " ", "an", " ", ":", "exc", ":`", "Exi", "t", "Main", "Loop", "`", " ", "exception", " ", "is", " ", "raise", "d", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "Thi", "s", " ", "method", " ", "will", " ", "use", " ", ":", "attr", ":`", "screen", "`", "'", "s", " ", "run", "\\u", "wrapp", "er", "()", " ", "method", " ", "if", "\\", "10", ";", " ", " ", " ", " ", ":", "attr", ":`", "screen", "`", "'", "s", " ", "start", "()", " ", "method", " ", "has", " ", "not", " ", "alr", "ead", "y", " ", "bee", "n", " ", "call", "ed", ".", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "self_", "._", "screen_", "._", "started_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "\\u", "run_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "screen_", "._", "run", "\\u", "wrapper_", "(_", "self_", "._", "\\u", "run_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "Exi", "t", "Main", "Loop_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "pass_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Main", "Loop_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "\\u", "test\\u", "run_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", ">>>", " ", "w", " ", "=", " ", "\\u", "refl", "(\"", "widget", "\")", " ", " ", " ", "#", " ", "\\u", "refl", " ", "print", "s", " ", "out", " ", "function", " ", "calls", "\\", "10", ";", " ", " ", " ", " ", ">>>", " ", "w", ".", "render", "\\u", "rval", " ", "=", " ", "\"", "fake", " ", "canv", "as", "\"", " ", " ", "#", " ", "*\\u", "rval", " ", "is", " ", "used", " ", "for", " ", "return", " ", "values", "\\", "10", ";", " ", " ", " ", " ", ">>>", " ", "scr", " ", "=", " ", "\\u", "refl", "(\"", "screen", "\")", "\\", "10", ";", " ", " ", " ", " ", ">>>", " ", "scr", ".", "get", "\\u", "input", "\\u", "descrip", "tors", "\\u", "rval", " ", "=", " ", "[", "4", "2", "]", "\\", "10", ";", " ", " ", " ", " ", ">>>", " ", "scr", ".", "get", "\\u", "cols", "\\u", "rows", "\\u", "rval", " ", "=", " ", "(", "20", ",", " ", "10", ")", "\\", "10", ";", " ", " ", " ", " ", ">>>", " ", "scr", ".", "start", "ed", " ", "=", " ", "Tru", "e", "\\", "10", ";", " ", " ", " ", " ", ">>>", " ", "scr", ".\\u", "ur", "wid", "\\u", "signal", "s", " ", "=", " ", "{}", "\\", "10", ";", " ", " ", " ", " ", ">>>", " ", "ev", "l", " ", "=", " ", "\\u", "refl", "(\"", "event", "\\u", "loop", "\")", "\\", "10", ";", " ", " ", " ", " ", ">>>", " ", "ev", "l", ".", "enter", "\\u", "idle", "\\u", "rval", " ", "=", " ", "1", "\\", "10", ";", " ", " ", " ", " ", ">>>", " ", "ev", "l", ".", "watch", "\\u", "file", "\\u", "rval", " ", "=", " ", "2", "\\", "10", ";", " ", " ", " ", " ", ">>>", " ", "ml", " ", "=", " ", "Main", "Loop", "(", "w", ",", " ", "[]", ",", " ", "scr", ",", " ", "event", "\\u", "loop", "=", "ev", "l", ")", "\\", "10", ";", " ", " ", " ", " ", ">>>", " ", "ml", ".", "run", "()", " ", " ", " ", " ", "#", " ", "docte", "st", ":+", "ELLIPS", "IS", "\\", "10", ";", " ", " ", " ", " ", "screen", ".", "set\\u", "mouse", "\\u", "track", "ing", "()", "\\", "10", ";", " ", " ", " ", " ", "screen", ".", "get", "\\u", "cols", "\\u", "rows", "()", "\\", "10", ";", " ", " ", " ", " ", "widget", ".", "render", "((", "20", ",", " ", "10", "),", " ", "foc", "us", "=", "Tru", "e", ")", "\\", "10", ";", " ", " ", " ", " ", "screen", ".", "draw", "\\u", "screen", "((", "20", ",", " ", "10", "),", " ", "'", "fake", " ", "canv", "as", "')", "\\", "10", ";", " ", " ", " ", " ", "screen", ".", "get", "\\u", "input", "\\u", "descrip", "tors", "()", "\\", "10", ";", " ", " ", " ", " ", "event", "\\u", "loop", ".", "watch", "\\u", "file", "(", "4", "2", ",", " ", "<", "bound", " ", "method", " ", "...", ">)", "\\", "10", ";", " ", " ", " ", " ", "event", "\\u", "loop", ".", "enter", "\\u", "idle", "(", "<", "bound", " ", "method", " ", "...", ">)", "\\", "10", ";", " ", " ", " ", " ", "event", "\\u", "loop", ".", "run", "()", "\\", "10", ";", " ", " ", " ", " ", "event", "\\u", "loop", ".", "remove", "\\u", "enter", "\\u", "idle", "(", "1", ")", "\\", "10", ";", " ", " ", " ", " ", "event", "\\u", "loop", ".", "remove", "\\u", "watch", "\\u", "file", "(", "2", ")", "\\", "10", ";", " ", " ", " ", " ", ">>>", " ", "scr", ".", "start", "ed", " ", "=", " ", "Fal", "se", "\\", "10", ";", " ", " ", " ", " ", ">>>", " ", "ml", ".", "run", "()", " ", " ", " ", " ", "#", " ", "docte", "st", ":+", "ELLIPS", "IS", "\\", "10", ";", " ", " ", " ", " ", "screen", ".", "run", "\\u", "wrapp", "er", "(", "<", "bound", " ", "method", " ", "...", ">)", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Main", "Loop_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "\\u", "run_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "self_", "._", "handle", "\\u", "mouse_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "screen_", "._", "set\\u", "mouse", "\\u", "tracking_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "not_", "hasattr_", "(_", "self_", "._", "screen_", ",_", "'", "get", "\\u", "input", "\\u", "descrip", "tors", "'_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "self_", "._", "\\u", "run", "\\u", "screen", "\\u", "event", "\\u", "loop_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "draw", "\\u", "screen_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "fd", "\\u", "handles_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "reset", "\\u", "input", "\\u", "descriptors_", "(_", "only", "\\u", "remove_", "=_", "False_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "for_", "handle_", "in_", "fd", "\\u", "handles_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "event", "\\u", "loop_", "._", "remove", "\\u", "watch", "\\u", "file_", "(_", "handle_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "only", "\\u", "remove_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "del_", "fd", "\\u", "handles_", "[_", ":_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "fd", "\\u", "handles_", "[_", ":_", "]_", "=_", "[_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "event", "\\u", "loop_", "._", "watch", "\\u", "file_", "(_", "fd_", ",_", "self_", "._", "\\u", "update_", ")_", "\\u\\u\\uNL\\u\\u\\u_", "for_", "fd_", "in_", "self_", "._", "screen_", "._", "get", "\\u", "input", "\\u", "descriptors_", "(_", ")_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "not_", "fd", "\\u", "handles_", "and_", "self_", "._", "\\u", "input", "\\u", "timeout_", "is_", "not_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "event", "\\u", "loop_", "._", "remove", "\\u", "alarm_", "(_", "self_", "._", "\\u", "input", "\\u", "timeout_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "signals_", "._", "connect", "\\u", "signal_", "(_", "self_", "._", "screen_", ",_", "INPUT", "\\u", "DESCRIPT", "ORS", "\\u", "CHANGED", "_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "reset", "\\u", "input", "\\u", "descriptors_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "Name", "Error_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "pass_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "watch", " ", "our", " ", "input", " ", "descriptors_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "reset", "\\u", "input", "\\u", "descriptors_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "idle", "\\u", "handle_", "=_", "self_", "._", "event", "\\u", "loop_", "._", "enter", "\\u", "idle_", "(_", "self_", "._", "entering", "\\u", "idle_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Go", "..", "_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "event", "\\u", "loop_", "._", "run_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "tidy", " ", "up_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "event", "\\u", "loop_", "._", "remove", "\\u", "enter", "\\u", "idle_", "(_", "idle", "\\u", "handle_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "reset", "\\u", "input", "\\u", "descriptors_", "(_", "True_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "signals_", "._", "discon", "nect", "\\u", "signal_", "(_", "self_", "._", "screen_", ",_", "INPUT", "\\u", "DESCRIPT", "ORS", "\\u", "CHANGED", "_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "reset", "\\u", "input", "\\u", "descriptors_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Main", "Loop_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "\\u", "update_", "(_", "self_", ",_", "timeout_", "=_", "False_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", ">>>", " ", "w", " ", "=", " ", "\\u", "refl", "(\"", "widget", "\")", "\\", "10", ";", " ", " ", " ", " ", ">>>", " ", "w", ".", "selectable", "\\u", "rval", " ", "=", " ", "Tru", "e", "\\", "10", ";", " ", " ", " ", " ", ">>>", " ", "w", ".", "mouse", "\\u", "event", "\\u", "rval", " ", "=", " ", "Tru", "e", "\\", "10", ";", " ", " ", " ", " ", ">>>", " ", "scr", " ", "=", " ", "\\u", "refl", "(\"", "screen", "\")", "\\", "10", ";", " ", " ", " ", " ", ">>>", " ", "scr", ".", "get", "\\u", "cols", "\\u", "rows", "\\u", "rval", " ", "=", " ", "(", "15", ",", " ", "5", ")", "\\", "10", ";", " ", " ", " ", " ", ">>>", " ", "scr", ".", "get", "\\u", "input", "\\u", "nonb", "locking", "\\u", "rval", " ", "=", " ", "1", ",", " ", "['", "y", "']", ",", " ", "[", "121", "]", "\\", "10", ";", " ", " ", " ", " ", ">>>", " ", "ev", "l", " ", "=", " ", "\\u", "refl", "(\"", "event", "\\u", "loop", "\")", "\\", "10", ";", " ", " ", " ", " ", ">>>", " ", "ml", " ", "=", " ", "Main", "Loop", "(", "w", ",", " ", "[]", ",", " ", "scr", ",", " ", "event", "\\u", "loop", "=", "ev", "l", ")", "\\", "10", ";", " ", " ", " ", " ", ">>>", " ", "ml", ".\\u", "input", "\\u", "timeo", "ut", " ", "=", " ", "\"", "old", " ", "timeo", "ut", "\"", "\\", "10", ";", " ", " ", " ", " ", ">>>", " ", "ml", ".\\u", "update", "()", " ", " ", " ", " ", "#", " ", "docte", "st", ":+", "ELLIPS", "IS", "\\", "10", ";", " ", " ", " ", " ", "event", "\\u", "loop", ".", "remove", "\\u", "alarm", "('", "old", " ", "timeo", "ut", "')", "\\", "10", ";", " ", " ", " ", " ", "screen", ".", "get", "\\u", "input", "\\u", "nonb", "locking", "()", "\\", "10", ";", " ", " ", " ", " ", "event", "\\u", "loop", ".", "alarm", "(", "1", ",", " ", "<", "function", " ", "...", ">)", "\\", "10", ";", " ", " ", " ", " ", "screen", ".", "get", "\\u", "cols", "\\u", "rows", "()", "\\", "10", ";", " ", " ", " ", " ", "widget", ".", "selectable", "()", "\\", "10", ";", " ", " ", " ", " ", "widget", ".", "keypress", "((", "15", ",", " ", "5", "),", " ", "'", "y", "')", "\\", "10", ";", " ", " ", " ", " ", ">>>", " ", "scr", ".", "get", "\\u", "input", "\\u", "nonb", "locking", "\\u", "rval", " ", "=", " ", "Non", "e", ",", " ", "[(", "\"", "mouse", " ", "press", "\",", " ", "1", ",", " ", "5", ",", " ", "4", ")", "\\", "10", ";", " ", " ", " ", " ", "...", " ", "],", " ", "[]", "\\", "10", ";", " ", " ", " ", " ", ">>>", " ", "ml", ".\\u", "update", "()", "\\", "10", ";", " ", " ", " ", " ", "screen", ".", "get", "\\u", "input", "\\u", "nonb", "locking", "()", "\\", "10", ";", " ", " ", " ", " ", "widget", ".", "mouse", "\\u", "event", "((", "15", ",", " ", "5", "),", " ", "'", "mouse", " ", "press", "',", " ", "1", ",", " ", "5", ",", " ", "4", ",", " ", "foc", "us", "=", "Tru", "e", ")", "\\", "10", ";", " ", " ", " ", " ", ">>>", " ", "scr", ".", "get", "\\u", "input", "\\u", "nonb", "locking", "\\u", "rval", " ", "=", " ", "Non", "e", ",", " ", "[]", ",", " ", "[]", "\\", "10", ";", " ", " ", " ", " ", ">>>", " ", "ml", ".\\u", "update", "()", "\\", "10", ";", " ", " ", " ", " ", "screen", ".", "get", "\\u", "input", "\\u", "nonb", "locking", "()", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "self_", "._", "\\u", "input", "\\u", "timeout_", "is_", "not_", "None_", "and_", "not_", "timeout_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "cancel", " ", "the", " ", "timeo", "ut", ",", " ", "somet", "hing", " ", "else", " ", "trigger", "ed", " ", "the", " ", "update_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "event", "\\u", "loop_", "._", "remove", "\\u", "alarm_", "(_", "self_", "._", "\\u", "input", "\\u", "timeout_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "\\u", "input", "\\u", "timeout_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "max", "\\u", "wait_", ",_", "keys_", ",_", "raw_", "=_", "self_", "._", "screen_", "._", "get", "\\u", "input", "\\u", "nonb", "locking_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "max", "\\u", "wait_", "is_", "not_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "if", " ", "get", "\\u", "input", "\\u", "nonb", "locking", " ", "want", "s", " ", "to", " ", "be", " ", "call", "ed", " ", "back_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "make", " ", "sure", " ", "it", " ", "happ", "ens", " ", "with", " ", "an", " ", "alarm_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "\\u", "input", "\\u", "timeout_", "=_", "self_", "._", "event", "\\u", "loop_", "._", "alarm_", "(_", "max", "\\u", "wait_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "lambda_", ":_", "self_", "._", "\\u", "update_", "(_", "timeout_", "=_", "True_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "keys_", "=_", "self_", "._", "input", "\\u", "filter_", "(_", "keys_", ",_", "raw_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "keys_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "process", "\\u", "input_", "(_", "keys_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "'", "window", " ", "resiz", "e", "'_", "in_", "keys_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "screen", "\\u", "size_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Main", "Loop_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "\\u", "run", "\\u", "screen", "\\u", "event", "\\u", "loop_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Thi", "s", " ", "method", " ", "is", " ", "used", " ", "whe", "n", " ", "the", " ", "screen", " ", "doe", "s", " ", "not", " ", "support", " ", "usi", "ng", "\\", "10", ";", " ", " ", " ", " ", "external", " ", "event", " ", "loop", "s", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "The", " ", "alarms", " ", "store", "d", " ", "in", " ", "the", " ", "Select", "Event", "Loop", " ", "in", " ", ":", "attr", ":`", "event", "\\u", "loop", "`", "\\", "10", ";", " ", " ", " ", " ", "are", " ", "modifi", "ed", " ", "by", " ", "this", " ", "method", ".", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "next", "\\u", "alarm_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "while_", "True_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "draw", "\\u", "screen_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "not_", "next", "\\u", "alarm_", "and_", "self_", "._", "event", "\\u", "loop_", "._", "\\u", "alarms_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "next", "\\u", "alarm_", "=_", "heapq_", "._", "heapp", "op_", "(_", "self_", "._", "event", "\\u", "loop_", "._", "\\u", "alarms_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "keys_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "while_", "not_", "keys_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "next", "\\u", "alarm_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "sec_", "=_", "max_", "(_", "0_", ",_", "next", "\\u", "alarm_", "[_", "0_", "]_", "-_", "time_", "._", "time_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "screen_", "._", "set\\u", "input", "\\u", "timeouts", "_", "(_", "sec_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "self_", "._", "screen_", "._", "set\\u", "input", "\\u", "timeouts", "_", "(_", "None_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "keys_", ",_", "raw_", "=_", "self_", "._", "screen_", "._", "get", "\\u", "input_", "(_", "True_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "not_", "keys_", "and_", "next", "\\u", "alarm_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "sec_", "=_", "next", "\\u", "alarm_", "[_", "0_", "]_", "-_", "time_", "._", "time_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "sec_", "<=_", "0_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "break_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "keys_", "=_", "self_", "._", "input", "\\u", "filter_", "(_", "keys_", ",_", "raw_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "keys_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "process", "\\u", "input_", "(_", "keys_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "while_", "next", "\\u", "alarm_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "sec_", "=_", "next", "\\u", "alarm_", "[_", "0_", "]_", "-_", "time_", "._", "time_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "sec_", ">_", "0_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "break_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "tm_", ",_", "callback_", "=_", "next", "\\u", "alarm_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "callback_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "self_", "._", "event", "\\u", "loop_", "._", "\\u", "alarms_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "next", "\\u", "alarm_", "=_", "heapq_", "._", "heapp", "op_", "(_", "self_", "._", "event", "\\u", "loop_", "._", "\\u", "alarms_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "next", "\\u", "alarm_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "'", "window", " ", "resiz", "e", "'_", "in_", "keys_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "screen", "\\u", "size_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Main", "Loop_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "\\u", "test\\u", "run", "\\u", "screen", "\\u", "event", "\\u", "loop_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", ">>>", " ", "w", " ", "=", " ", "\\u", "refl", "(\"", "widget", "\")", "\\", "10", ";", " ", " ", " ", " ", ">>>", " ", "scr", " ", "=", " ", "\\u", "refl", "(\"", "screen", "\")", "\\", "10", ";", " ", " ", " ", " ", ">>>", " ", "scr", ".", "get", "\\u", "cols", "\\u", "rows", "\\u", "rval", " ", "=", " ", "(", "10", ",", " ", "5", ")", "\\", "10", ";", " ", " ", " ", " ", ">>>", " ", "scr", ".", "get", "\\u", "input", "\\u", "rval", " ", "=", " ", "[]", ",", " ", "[]", "\\", "10", ";", " ", " ", " ", " ", ">>>", " ", "ml", " ", "=", " ", "Main", "Loop", "(", "w", ",", " ", "screen", "=", "scr", ")", "\\", "10", ";", " ", " ", " ", " ", ">>>", " ", "def", " ", "stop", "\\u", "now", "(", "loop", ",", " ", "data", "):", "\\", "10", ";", " ", " ", " ", " ", "...", " ", "raise", " ", "Exi", "t", "Main", "Loop", "()", "\\", "10", ";", " ", " ", " ", " ", ">>>", " ", "handle", " ", "=", " ", "ml", ".", "set\\u", "alarm", "\\u", "in", "(", "0", ",", " ", "stop", "\\u", "now", ")", "\\", "10", ";", " ", " ", " ", " ", ">>>", " ", "try", ":", "\\", "10", ";", " ", " ", " ", " ", "...", " ", "ml", ".\\u", "run", "\\u", "screen", "\\u", "event", "\\u", "loop", "()", "\\", "10", ";", " ", " ", " ", " ", "...", " ", "except", " ", "Exi", "t", "Main", "Loop", ":", "\\", "10", ";", " ", " ", " ", " ", "...", " ", "pass", "\\", "10", ";", " ", " ", " ", " ", "screen", ".", "get", "\\u", "cols", "\\u", "rows", "()", "\\", "10", ";", " ", " ", " ", " ", "widget", ".", "render", "((", "10", ",", " ", "5", "),", " ", "foc", "us", "=", "Tru", "e", ")", "\\", "10", ";", " ", " ", " ", " ", "screen", ".", "draw", "\\u", "screen", "((", "10", ",", " ", "5", "),", " ", "Non", "e", ")", "\\", "10", ";", " ", " ", " ", " ", "screen", ".", "set\\u", "input", "\\u", "timeouts", "(", "0", ")", "\\", "10", ";", " ", " ", " ", " ", "screen", ".", "get", "\\u", "input", "(", "Tru", "e", ")", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Main", "Loop_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "process", "\\u", "input_", "(_", "self_", ",_", "keys_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Thi", "s", " ", "method", " ", "will", " ", "pass", " ", "keyb", "oard", " ", "input", " ", "and", " ", "mouse", " ", "events", " ", "to", " ", ":", "attr", ":`", "widget", "`.", "\\", "10", ";", " ", " ", " ", " ", "Thi", "s", " ", "method", " ", "is", " ", "call", "ed", " ", "automati", "call", "y", " ", "from", " ", "the", " ", ":", "meth", ":`", "run", "`", " ", "method", " ", "whe", "n", "\\", "10", ";", " ", " ", " ", " ", "there", " ", "is", " ", "input", ",", " ", "but", " ", "may", " ", "als", "o", " ", "be", " ", "call", "ed", " ", "to", " ", "simulat", "e", " ", "input", " ", "from", " ", "the", " ", "user", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "*", "keys", "*", " ", "is", " ", "a", " ", "list", " ", "of", " ", "input", " ", "return", "ed", " ", "from", " ", ":", "attr", ":`", "screen", "`", "'", "s", " ", "get", "\\u", "input", "()", "\\", "10", ";", " ", " ", " ", " ", "or", " ", "get", "\\u", "input", "\\u", "nonb", "locking", "()", " ", "method", "s", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "Return", "s", " ", "``", "Tru", "e", "``", " ", "if", " ", "any", " ", "key", " ", "was", " ", "handle", "d", " ", "by", " ", "a", " ", "widget", " ", "or", " ", "the", "\\", "10", ";", " ", " ", " ", " ", ":", "meth", ":`", "unhandled", "\\u", "input", "`", " ", "method", ".", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "not_", "self_", "._", "screen", "\\u", "size_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "screen", "\\u", "size_", "=_", "self_", "._", "screen_", "._", "get", "\\u", "cols", "\\u", "rows_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "somet", "hing", "\\u", "handled_", "=_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "for_", "k_", "in_", "keys_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "k_", "==_", "'", "window", " ", "resiz", "e", "'_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "continue_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "is", "\\u", "mouse", "\\u", "event_", "(_", "k_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "event_", ",_", "button_", ",_", "col_", ",_", "row_", "=_", "k_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "self_", "._", "\\u", "top", "most", "\\u", "widget_", "._", "mouse", "\\u", "event_", "(_", "self_", "._", "screen", "\\u", "size_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "event_", ",_", "button_", ",_", "col_", ",_", "row_", ",_", "focus_", "=_", "True_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "k_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "self_", "._", "\\u", "top", "most", "\\u", "widget_", "._", "selectable", "_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "k_", "=_", "self_", "._", "\\u", "top", "most", "\\u", "widget_", "._", "keypress", "_", "(_", "self_", "._", "screen", "\\u", "size_", ",_", "k_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "k_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "command", "\\u", "map_", "[_", "k_", "]_", "==_", "RED", "RA", "W", "\\u", "SCREEN", "_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "self_", "._", "screen_", "._", "clear_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "somet", "hing", "\\u", "handled_", "=_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "somet", "hing", "\\u", "handled_", "|=_", "bool_", "(_", "self_", "._", "unhandled", "\\u", "input_", "(_", "k_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "somet", "hing", "\\u", "handled_", "=_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "somet", "hing", "\\u", "handled_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Main", "Loop_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "\\u", "test\\u", "process", "\\u", "input_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", ">>>", " ", "w", " ", "=", " ", "\\u", "refl", "(\"", "widget", "\")", "\\", "10", ";", " ", " ", " ", " ", ">>>", " ", "w", ".", "selectable", "\\u", "rval", " ", "=", " ", "Tru", "e", "\\", "10", ";", " ", " ", " ", " ", ">>>", " ", "scr", " ", "=", " ", "\\u", "refl", "(\"", "screen", "\")", "\\", "10", ";", " ", " ", " ", " ", ">>>", " ", "scr", ".", "get", "\\u", "cols", "\\u", "rows", "\\u", "rval", " ", "=", " ", "(", "10", ",", " ", "5", ")", "\\", "10", ";", " ", " ", " ", " ", ">>>", " ", "ml", " ", "=", " ", "Main", "Loop", "(", "w", ",", " ", "[]", ",", " ", "scr", ")", "\\", "10", ";", " ", " ", " ", " ", ">>>", " ", "ml", ".", "process", "\\u", "input", "([", "'", "enter", "',", " ", "('", "mouse", " ", "drag", "',", " ", "1", ",", " ", "14", ",", " ", "20", ")])", "\\", "10", ";", " ", " ", " ", " ", "screen", ".", "get", "\\u", "cols", "\\u", "rows", "()", "\\", "10", ";", " ", " ", " ", " ", "widget", ".", "selectable", "()", "\\", "10", ";", " ", " ", " ", " ", "widget", ".", "keypress", "((", "10", ",", " ", "5", "),", " ", "'", "enter", "')", "\\", "10", ";", " ", " ", " ", " ", "widget", ".", "mouse", "\\u", "event", "((", "10", ",", " ", "5", "),", " ", "'", "mouse", " ", "drag", "',", " ", "1", ",", " ", "14", ",", " ", "20", ",", " ", "foc", "us", "=", "Tru", "e", ")", "\\", "10", ";", " ", " ", " ", " ", "Tru", "e", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Main", "Loop_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "input", "\\u", "filter_", "(_", "self_", ",_", "keys_", ",_", "raw_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Thi", "s", " ", "function", " ", "is", " ", "pass", "ed", " ", "each", " ", "all", " ", "the", " ", "input", " ", "events", " ", "and", " ", "raw", " ", "keystr", "oke", "\\", "10", ";", " ", " ", " ", " ", "values", ".", " ", "The", "se", " ", "values", " ", "are", " ", "pass", "ed", " ", "to", " ", "the", " ", "*", "input", "\\u", "filter", "*", " ", "function", "\\", "10", ";", " ", " ", " ", " ", "pass", "ed", " ", "to", " ", "the", " ", "construct", "or", ".", " ", "Tha", "t", " ", "function", " ", "must", " ", "return", " ", "a", " ", "list", " ", "of", " ", "keys", " ", "to", "\\", "10", ";", " ", " ", " ", " ", "be", " ", "pass", "ed", " ", "to", " ", "the", " ", "widget", "s", " ", "to", " ", "handle", ".", " ", "If", " ", "no", " ", "*", "input", "\\u", "filter", "*", " ", "was", "\\", "10", ";", " ", " ", " ", " ", "defin", "ed", " ", "this", " ", "implementation", " ", "will", " ", "return", " ", "all", " ", "the", " ", "input", " ", "events", ".", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "self_", "._", "\\u", "input", "\\u", "filter_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "self_", "._", "\\u", "input", "\\u", "filter_", "(_", "keys_", ",_", "raw_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "keys_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Main", "Loop_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "unhandled", "\\u", "input_", "(_", "self_", ",_", "input_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Thi", "s", " ", "function", " ", "is", " ", "call", "ed", " ", "with", " ", "any", " ", "input", " ", "tha", "t", " ", "was", " ", "not", " ", "handle", "d", " ", "by", " ", "the", "\\", "10", ";", " ", " ", " ", " ", "widget", "s", ",", " ", "and", " ", "calls", " ", "the", " ", "*", "unhandled", "\\u", "input", "*", " ", "function", " ", "pass", "ed", " ", "to", " ", "the", "\\", "10", ";", " ", " ", " ", " ", "construct", "or", ".", " ", "If", " ", "no", " ", "*", "unhandled", "\\u", "input", "*", " ", "was", " ", "defin", "ed", " ", "then", " ", "the", " ", "input", "\\", "10", ";", " ", " ", " ", " ", "will", " ", "be", " ", "ignore", "d", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "*", "input", "*", " ", "is", " ", "the", " ", "keyb", "oard", " ", "or", " ", "mouse", " ", "input", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "The", " ", "*", "unhandled", "\\u", "input", "*", " ", "function", " ", "shou", "ld", " ", "return", " ", "``", "Tru", "e", "``", " ", "if", " ", "it", " ", "handle", "d", "\\", "10", ";", " ", " ", " ", " ", "the", " ", "input", ".", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "self_", "._", "\\u", "unhandled", "\\u", "input_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "self_", "._", "\\u", "unhandled", "\\u", "input_", "(_", "input_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Main", "Loop_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "entering", "\\u", "idle_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Thi", "s", " ", "method", " ", "is", " ", "call", "ed", " ", "whe", "neve", "r", " ", "the", " ", "event", " ", "loop", " ", "is", " ", "abo", "ut", " ", "to", " ", "enter", " ", "the", "\\", "10", ";", " ", " ", " ", " ", "idle", " ", "state", ".", " ", ":", "meth", ":`", "draw", "\\u", "screen", "`", " ", "is", " ", "call", "ed", " ", "here", " ", "to", " ", "update", " ", "the", "\\", "10", ";", " ", " ", " ", " ", "screen", " ", "whe", "n", " ", "anyt", "hing", " ", "has", " ", "change", "d", ".", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "self_", "._", "screen_", "._", "started_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "draw", "\\u", "screen_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Main", "Loop_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "draw", "\\u", "screen_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Render", " ", "the", " ", "widget", "s", " ", "and", " ", "pain", "t", " ", "the", " ", "screen", ".", " ", "Thi", "s", " ", "method", " ", "is", " ", "call", "ed", "\\", "10", ";", " ", " ", " ", " ", "automati", "call", "y", " ", "from", " ", ":", "meth", ":`", "entering", "\\u", "idle", "`.", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "If", " ", "you", " ", "modif", "y", " ", "the", " ", "widget", "s", " ", "displaye", "d", " ", "outsi", "de", " ", "of", " ", "handling", " ", "input", " ", "or", "\\", "10", ";", " ", " ", " ", " ", "respond", "ing", " ", "to", " ", "an", " ", "alarm", " ", "you", " ", "will", " ", "need", " ", "to", " ", "call", " ", "this", " ", "method", " ", "your", "self", "\\", "10", ";", " ", " ", " ", " ", "to", " ", "repa", "int", " ", "the", " ", "screen", ".", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "not_", "self_", "._", "screen", "\\u", "size_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "screen", "\\u", "size_", "=_", "self_", "._", "screen_", "._", "get", "\\u", "cols", "\\u", "rows_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "canvas_", "=_", "self_", "._", "\\u", "top", "most", "\\u", "widget_", "._", "render_", "(_", "self_", "._", "screen", "\\u", "size_", ",_", "focus_", "=_", "True_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "screen_", "._", "draw", "\\u", "screen_", "(_", "self_", "._", "screen", "\\u", "size_", ",_", "canvas_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "class_", "Select", "Event", "Loop_", "(_", "object_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Event", " ", "loop", " ", "based", " ", "on", " ", ":", "func", ":`", "select", ".", "select", "`", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "[SEP]_", "class_", "Select", "Event", "Loop_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "\\u\\u", "init\\u\\u_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "\\u", "alarms_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "\\u", "watch", "\\u", "files_", "=_", "{_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "\\u", "idle", "\\u", "handle_", "=_", "0_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "\\u", "idle", "\\u", "callbacks_", "=_", "{_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Select", "Event", "Loop_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "alarm_", "(_", "self_", ",_", "seconds_", ",_", "callback_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Call", " ", "callback", "()", " ", "give", "n", " ", "time", " ", "from", " ", "from", " ", "now", ".", " ", " ", "No", " ", "parameter", "s", " ", "are", "\\", "10", ";", " ", " ", " ", " ", "pass", "ed", " ", "to", " ", "callback", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "Return", "s", " ", "a", " ", "handle", " ", "tha", "t", " ", "may", " ", "be", " ", "pass", "ed", " ", "to", " ", "remove", "\\u", "alarm", "()", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "second", "s", " ", "--", " ", "float", "ing", " ", "point", " ", "time", " ", "to", " ", "wait", " ", "bef", "ore", " ", "calling", " ", "callback", "\\", "10", ";", " ", " ", " ", " ", "callback", " ", "--", " ", "function", " ", "to", " ", "call", " ", "from", " ", "event", " ", "loop", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "tm_", "=_", "time_", "._", "time_", "(_", ")_", "+_", "seconds_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "heapq_", "._", "heapp", "ush_", "(_", "self_", "._", "\\u", "alarms_", ",_", "(_", "tm_", ",_", "callback_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "(_", "tm_", ",_", "callback_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Select", "Event", "Loop_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "remove", "\\u", "alarm_", "(_", "self_", ",_", "handle_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Remove", " ", "an", " ", "alarm", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "Return", "s", " ", "Tru", "e", " ", "if", " ", "the", " ", "alarm", " ", "exist", "s", ",", " ", "Fal", "se", " ", "other", "wis", "e", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "\\u", "alarms_", "._", "remove_", "(_", "handle_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "heapq_", "._", "heap", "ify_", "(_", "self_", "._", "\\u", "alarms_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "Value", "Error_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Select", "Event", "Loop_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "watch", "\\u", "file_", "(_", "self_", ",_", "fd_", ",_", "callback_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Call", " ", "callback", "()", " ", "whe", "n", " ", "fd", " ", "has", " ", "some", " ", "data", " ", "to", " ", "read", ".", " ", " ", "No", " ", "parameter", "s", "\\", "10", ";", " ", " ", " ", " ", "are", " ", "pass", "ed", " ", "to", " ", "callback", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "Return", "s", " ", "a", " ", "handle", " ", "tha", "t", " ", "may", " ", "be", " ", "pass", "ed", " ", "to", " ", "remove", "\\u", "watch", "\\u", "file", "()", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "fd", " ", "--", " ", "file", " ", "descrip", "tor", " ", "to", " ", "watch", " ", "for", " ", "input", "\\", "10", ";", " ", " ", " ", " ", "callback", " ", "--", " ", "function", " ", "to", " ", "call", " ", "whe", "n", " ", "input", " ", "is", " ", "avail", "able", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "\\u", "watch", "\\u", "files_", "[_", "fd_", "]_", "=_", "callback_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "fd_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Select", "Event", "Loop_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "remove", "\\u", "watch", "\\u", "file_", "(_", "self_", ",_", "handle_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Remove", " ", "an", " ", "input", " ", "file", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "Return", "s", " ", "Tru", "e", " ", "if", " ", "the", " ", "input", " ", "file", " ", "exist", "s", ",", " ", "Fal", "se", " ", "other", "wis", "e", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "handle_", "in_", "self_", "._", "\\u", "watch", "\\u", "files_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "del_", "self_", "._", "\\u", "watch", "\\u", "files_", "[_", "handle_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Select", "Event", "Loop_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "enter", "\\u", "idle_", "(_", "self_", ",_", "callback_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Add", " ", "a", " ", "callback", " ", "for", " ", "entering", " ", "idle", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "Return", "s", " ", "a", " ", "handle", " ", "tha", "t", " ", "may", " ", "be", " ", "pass", "ed", " ", "to", " ", "remove", "\\u", "idle", "()", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "\\u", "idle", "\\u", "handle_", "+=_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "\\u", "idle", "\\u", "callbacks_", "[_", "self_", "._", "\\u", "idle", "\\u", "handle_", "]_", "=_", "callback_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "self_", "._", "\\u", "idle", "\\u", "handle_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Select", "Event", "Loop_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "remove", "\\u", "enter", "\\u", "idle_", "(_", "self_", ",_", "handle_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Remove", " ", "an", " ", "idle", " ", "callback", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "Return", "s", " ", "Tru", "e", " ", "if", " ", "the", " ", "handle", " ", "was", " ", "remove", "d", ".", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "del_", "self_", "._", "\\u", "idle", "\\u", "callbacks_", "[_", "handle_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "Key", "Error_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Select", "Event", "Loop_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "\\u", "entering", "\\u", "idle_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Call", " ", "all", " ", "the", " ", "register", "ed", " ", "idle", " ", "callback", "s", ".", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "callback_", "in_", "self_", "._", "\\u", "idle", "\\u", "callbacks_", "._", "values_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "callback_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Select", "Event", "Loop_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "run_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Start", " ", "the", " ", "event", " ", "loop", ".", " ", " ", "Exi", "t", " ", "the", " ", "loop", " ", "whe", "n", " ", "any", " ", "callback", " ", "raise", "s", "\\", "10", ";", " ", " ", " ", " ", "an", " ", "exception", ".", " ", " ", "If", " ", "Exi", "t", "Main", "Loop", " ", "is", " ", "raise", "d", ",", " ", "exit", " ", "clean", "ly", ".", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "\\u", "did", "\\u", "something_", "=_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "while_", "True_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "self_", "._", "\\u", "loop_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "select_", "._", "error_", ",_", "e_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "if_", "e_", "._", "args_", "[_", "0_", "]_", "!=_", "4_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "not", " ", "just", " ", "somet", "hing", " ", "we", " ", "need", " ", "to", " ", "retry_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "raise_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "Exi", "t", "Main", "Loop_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "pass_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Select", "Event", "Loop_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "\\u", "loop_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "A", " ", "single", " ", "iterati", "on", " ", "of", " ", "the", " ", "event", " ", "loop", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "fds_", "=_", "self_", "._", "\\u", "watch", "\\u", "files_", "._", "keys_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "self_", "._", "\\u", "alarms_", "or_", "self_", "._", "\\u", "did", "\\u", "something_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "self_", "._", "\\u", "alarms_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "tm_", "=_", "self_", "._", "\\u", "alarms_", "[_", "0_", "]_", "[_", "0_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "timeout_", "=_", "max_", "(_", "0_", ",_", "tm_", "-_", "time_", "._", "time_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "self_", "._", "\\u", "did", "\\u", "something_", "and_", "(_", "not_", "self_", "._", "\\u", "alarms_", "or_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "self_", "._", "\\u", "alarms_", "and_", "timeout_", ">_", "0_", ")_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "timeout_", "=_", "0_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "tm_", "=_", "'", "idle", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "ready_", ",_", "w_", ",_", "err_", "=_", "select_", "._", "select_", "(_", "fds_", ",_", "[_", "]_", ",_", "fds_", ",_", "timeout_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "tm_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "ready_", ",_", "w_", ",_", "err_", "=_", "select_", "._", "select_", "(_", "fds_", ",_", "[_", "]_", ",_", "fds_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "not_", "ready_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "tm_", "==_", "'", "idle", "'_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "\\u", "entering", "\\u", "idle_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "\\u", "did", "\\u", "something_", "=_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "tm_", "is_", "not_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "must", " ", "have", " ", "bee", "n", " ", "a", " ", "timeout_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "tm_", ",_", "alarm", "\\u", "callback_", "=_", "self_", "._", "\\u", "alarms_", "._", "pop_", "(_", "0_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "alarm", "\\u", "callback_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "\\u", "did", "\\u", "something_", "=_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "for_", "fd_", "in_", "ready_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "\\u", "watch", "\\u", "files_", "[_", "fd_", "]_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "\\u", "did", "\\u", "something_", "=_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "class_", "GL", "ib", "Event", "Loop_", "(_", "object_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Event", " ", "loop", " ", "based", " ", "on", " ", "GL", "ib", ".", "Main", "Loop", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "[SEP]_", "class_", "GL", "ib", "Event", "Loop_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "\\u\\u", "init\\u\\u_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "from_", "gi_", "._", "repository_", "import_", "GL", "ib_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "GL", "ib_", "=_", "GL", "ib_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "\\u", "alarms_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "\\u", "watch", "\\u", "files_", "=_", "{_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "\\u", "idle", "\\u", "handle_", "=_", "0_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "\\u", "glib", "\\u", "idle", "\\u", "enabled_", "=_", "False_", "#", " ", "have", " ", "we", " ", "call", "ed", " ", "glib", ".", "idle", "\\u", "add", "?", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "\\u", "idle", "\\u", "callbacks_", "=_", "{_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "\\u", "loop_", "=_", "GL", "ib_", "._", "Main", "Loop_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "\\u", "exc", "\\u", "info_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "\\u", "enable", "\\u", "glib", "\\u", "idle_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "GL", "ib", "Event", "Loop_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "alarm_", "(_", "self_", ",_", "seconds_", ",_", "callback_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Call", " ", "callback", "()", " ", "give", "n", " ", "time", " ", "from", " ", "from", " ", "now", ".", " ", " ", "No", " ", "parameter", "s", " ", "are", "\\", "10", ";", " ", " ", " ", " ", "pass", "ed", " ", "to", " ", "callback", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "Return", "s", " ", "a", " ", "handle", " ", "tha", "t", " ", "may", " ", "be", " ", "pass", "ed", " ", "to", " ", "remove", "\\u", "alarm", "()", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "second", "s", " ", "--", " ", "float", "ing", " ", "point", " ", "time", " ", "to", " ", "wait", " ", "bef", "ore", " ", "calling", " ", "callback", "\\", "10", ";", " ", " ", " ", " ", "callback", " ", "--", " ", "function", " ", "to", " ", "call", " ", "from", " ", "event", " ", "loop", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "@_", "self_", "._", "handle", "\\u", "exit_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "ret", "\\u", "false_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "callback_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "\\u", "enable", "\\u", "glib", "\\u", "idle_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "fd_", "=_", "self_", "._", "GL", "ib_", "._", "timeo", "ut", "\\u", "add_", "(_", "int_", "(_", "seconds_", "*_", "1000_", ")_", ",_", "ret", "\\u", "false_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "\\u", "alarms_", "._", "append_", "(_", "fd_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "(_", "fd_", ",_", "callback_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "GL", "ib", "Event", "Loop_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "remove", "\\u", "alarm_", "(_", "self_", ",_", "handle_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Remove", " ", "an", " ", "alarm", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "Return", "s", " ", "Tru", "e", " ", "if", " ", "the", " ", "alarm", " ", "exist", "s", ",", " ", "Fal", "se", " ", "other", "wis", "e", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "\\u", "alarms_", "._", "remove_", "(_", "handle_", "[_", "0_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "GL", "ib_", "._", "source", "\\u", "remove_", "(_", "handle_", "[_", "0_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "Value", "Error_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "GL", "ib", "Event", "Loop_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "watch", "\\u", "file_", "(_", "self_", ",_", "fd_", ",_", "callback_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Call", " ", "callback", "()", " ", "whe", "n", " ", "fd", " ", "has", " ", "some", " ", "data", " ", "to", " ", "read", ".", " ", " ", "No", " ", "parameter", "s", "\\", "10", ";", " ", " ", " ", " ", "are", " ", "pass", "ed", " ", "to", " ", "callback", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "Return", "s", " ", "a", " ", "handle", " ", "tha", "t", " ", "may", " ", "be", " ", "pass", "ed", " ", "to", " ", "remove", "\\u", "watch", "\\u", "file", "()", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "fd", " ", "--", " ", "file", " ", "descrip", "tor", " ", "to", " ", "watch", " ", "for", " ", "input", "\\", "10", ";", " ", " ", " ", " ", "callback", " ", "--", " ", "function", " ", "to", " ", "call", " ", "whe", "n", " ", "input", " ", "is", " ", "avail", "able", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "@_", "self_", "._", "handle", "\\u", "exit_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "io", "\\u", "callback_", "(_", "source_", ",_", "cb", "\\u", "condition_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "callback_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "\\u", "enable", "\\u", "glib", "\\u", "idle_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "\\u", "watch", "\\u", "files_", "[_", "fd_", "]_", "=_", "self_", "._", "GL", "ib_", "._", "io", "\\u", "add", "\\u", "watch_", "(_", "fd_", ",_", "self_", "._", "GL", "ib_", "._", "IO", "\\u", "IN_", ",_", "io", "\\u", "callback_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "fd_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "GL", "ib", "Event", "Loop_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "remove", "\\u", "watch", "\\u", "file_", "(_", "self_", ",_", "handle_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Remove", " ", "an", " ", "input", " ", "file", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "Return", "s", " ", "Tru", "e", " ", "if", " ", "the", " ", "input", " ", "file", " ", "exist", "s", ",", " ", "Fal", "se", " ", "other", "wis", "e", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "handle_", "in_", "self_", "._", "\\u", "watch", "\\u", "files_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "GL", "ib_", "._", "source", "\\u", "remove_", "(_", "self_", "._", "\\u", "watch", "\\u", "files_", "[_", "handle_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "del_", "self_", "._", "\\u", "watch", "\\u", "files_", "[_", "handle_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "GL", "ib", "Event", "Loop_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "enter", "\\u", "idle_", "(_", "self_", ",_", "callback_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Add", " ", "a", " ", "callback", " ", "for", " ", "entering", " ", "idle", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "Return", "s", " ", "a", " ", "handle", " ", "tha", "t", " ", "may", " ", "be", " ", "pass", "ed", " ", "to", " ", "remove", "\\u", "enter", "\\u", "idle", "()", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "\\u", "idle", "\\u", "handle_", "+=_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "\\u", "idle", "\\u", "callbacks_", "[_", "self_", "._", "\\u", "idle", "\\u", "handle_", "]_", "=_", "callback_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "self_", "._", "\\u", "idle", "\\u", "handle_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "GL", "ib", "Event", "Loop_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "\\u", "enable", "\\u", "glib", "\\u", "idle_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "self_", "._", "\\u", "glib", "\\u", "idle", "\\u", "enabled_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "GL", "ib_", "._", "idle", "\\u", "add_", "(_", "self_", "._", "\\u", "glib", "\\u", "idle", "\\u", "callback_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "\\u", "glib", "\\u", "idle", "\\u", "enabled_", "=_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "GL", "ib", "Event", "Loop_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "\\u", "glib", "\\u", "idle", "\\u", "callback_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "for_", "callback_", "in_", "self_", "._", "\\u", "idle", "\\u", "callbacks_", "._", "values_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "callback_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "\\u", "glib", "\\u", "idle", "\\u", "enabled_", "=_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "False_", "#", " ", "ask", " ", "glib", " ", "not", " ", "to", " ", "call", " ", "again", " ", "(", "or", " ", "we", " ", "wou", "ld", " ", "be", " ", "called_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "GL", "ib", "Event", "Loop_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "remove", "\\u", "enter", "\\u", "idle_", "(_", "self_", ",_", "handle_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Remove", " ", "an", " ", "idle", " ", "callback", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "Return", "s", " ", "Tru", "e", " ", "if", " ", "the", " ", "handle", " ", "was", " ", "remove", "d", ".", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "del_", "self_", "._", "\\u", "idle", "\\u", "callbacks_", "[_", "handle_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "Key", "Error_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "GL", "ib", "Event", "Loop_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "run_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Start", " ", "the", " ", "event", " ", "loop", ".", " ", " ", "Exi", "t", " ", "the", " ", "loop", " ", "whe", "n", " ", "any", " ", "callback", " ", "raise", "s", "\\", "10", ";", " ", " ", " ", " ", "an", " ", "exception", ".", " ", " ", "If", " ", "Exi", "t", "Main", "Loop", " ", "is", " ", "raise", "d", ",", " ", "exit", " ", "clean", "ly", ".", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "\\u", "loop_", "._", "run_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "finally_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "self_", "._", "\\u", "loop_", "._", "is", "\\u", "running_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "\\u", "loop_", "._", "quit_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "self_", "._", "\\u", "exc", "\\u", "info_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "An", " ", "exception", " ", "caus", "ed", " ", "us", " ", "to", " ", "exit", ",", " ", "raise", " ", "it", " ", "now_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "exc", "\\u", "info_", "=_", "self_", "._", "\\u", "exc", "\\u", "info_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "\\u", "exc", "\\u", "info_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "raise_", "exc", "\\u", "info_", "[_", "0_", "]_", ",_", "exc", "\\u", "info_", "[_", "1_", "]_", ",_", "exc", "\\u", "info_", "[_", "2_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "GL", "ib", "Event", "Loop_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "handle", "\\u", "exit_", "(_", "self_", ",_", "f_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Decorat", "or", " ", "tha", "t", " ", "clean", "ly", " ", "exits", " ", "the", " ", ":", "class", ":`", "GL", "ib", "Event", "Loop", "`", " ", "if", "\\", "10", ";", " ", " ", " ", " ", ":", "exc", ":`", "Exi", "t", "Main", "Loop", "`", " ", "is", " ", "throw", "n", " ", "insi", "de", " ", "of", " ", "the", " ", "wrapp", "ed", " ", "function", ".", " ", "Stor", "e", " ", "the", "\\", "10", ";", " ", " ", " ", " ", "exception", " ", "info", " ", "if", " ", "some", " ", "other", " ", "exception", " ", "occur", "s", ",", " ", "it", " ", "will", " ", "be", " ", "reraise", "d", " ", "after", "\\", "10", ";", " ", " ", " ", " ", "the", " ", "loop", " ", "quit", "s", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "*", "f", "*", " ", "--", " ", "function", " ", "to", " ", "be", " ", "wrapp", "ed", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "wrapper_", "(_", "*_", "args_", ",_", "**_", "kargs_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "f_", "(_", "*_", "args_", ",_", "**_", "kargs_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "Exi", "t", "Main", "Loop_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "\\u", "loop_", "._", "quit_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "import_", "sys_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "\\u", "exc", "\\u", "info_", "=_", "sys_", "._", "exc", "\\u", "info_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "self_", "._", "\\u", "loop_", "._", "is", "\\u", "running_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "self_", "._", "\\u", "loop_", "._", "quit_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "wrapper_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "class_", "Tor", "nad", "o", "Event", "Loop_", "(_", "object_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", " ", "Thi", "s", " ", "is", " ", "an", " ", "Ur", "wid", "-", "specific", " ", "event", " ", "loop", " ", "to", " ", "plug", " ", "int", "o", " ", "its", " ", "Main", "Loop", ".", "\\", "10", ";", " ", " ", " ", " ", "It", " ", "acts", " ", "as", " ", "an", " ", "adapt", "or", " ", "for", " ", "Tor", "nad", "o", "'", "s", " ", "IO", "Loop", " ", "whi", "ch", " ", "doe", "s", " ", "all", "\\", "10", ";", " ", " ", " ", " ", "heav", "y", " ", "lift", "ing", " ", "except", " ", "idle", "-", "callback", "s", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "Noti", "ce", ",", " ", "sinc", "e", " ", "Tor", "nad", "o", " ", "has", " ", "no", " ", "concept", " ", "of", " ", "idle", " ", "callback", "s", " ", "we", "\\", "10", ";", " ", " ", " ", " ", "monkey", " ", "patch", " ", "io", "loop", ".\\u", "impl", ".", "poll", "()", " ", "function", " ", "to", " ", "be", " ", "able", " ", "to", " ", "detect", "\\", "10", ";", " ", " ", " ", " ", "potenti", "al", " ", "idle", " ", "period", "s", ".", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u", "io", "loop", "\\u", "registry_", "=_", "Wea", "k", "Key", "Dictionary_", "(_", ")_", "#", " ", "{", "<", "io", "loop", ">", " ", ":", " ", "{", "<", "handle", ">", " ", ":", " ", "<", "idle", "\\u", "func", ">}", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u", "max", "\\u", "idle", "\\u", "handle_", "=_", "0_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "class_", "Poll", "Proxy_", "(_", "object_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", " ", "A", " ", "simple", " ", "proxy", " ", "for", " ", "a", " ", "Pyth", "on", "'", "s", " ", "poll", " ", "object", " ", "tha", "t", " ", "wrap", "s", " ", "the", " ", ".", "poll", "()", " ", "method", "\\", "10", ";", " ", " ", " ", " ", "in", " ", "order", " ", "to", " ", "detect", " ", "idle", " ", "period", "s", " ", "and", " ", "call", " ", "Ur", "wid", " ", "callback", "s", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "\\u\\u", "init\\u\\u_", "(_", "self_", ",_", "poll", "\\u", "obj_", ",_", "idle", "\\u", "map_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "\\u\\u", "poll", "\\u", "obj_", "=_", "poll", "\\u", "obj_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "\\u\\u", "idle", "\\u", "map_", "=_", "idle", "\\u", "map_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "\\u", "idle", "\\u", "done_", "=_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "\\u", "prev", "\\u", "timeout_", "=_", "0_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "\\u\\u", "getattr\\u\\u_", "(_", "self_", ",_", "name_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "getattr_", "(_", "self_", "._", "\\u\\u", "poll", "\\u", "obj_", ",_", "name_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "poll_", "(_", "self_", ",_", "timeout_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "timeout_", ">_", "self_", "._", "\\u", "prev", "\\u", "timeout_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "if", " ", "timeo", "ut", " ", "increase", "d", " ", "we", " ", "assume", " ", "a", " ", "timer", " ", "event", " ", "was", " ", "handled_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "\\u", "idle", "\\u", "done_", "=_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "\\u", "prev", "\\u", "timeout_", "=_", "timeout_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "start_", "=_", "time_", "._", "time_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "any", " ", "IO", " ", "pend", "ing", " ", "wins_", "\\u\\u\\uNL\\u\\u\\u_", "events_", "=_", "self_", "._", "\\u\\u", "poll", "\\u", "obj_", "._", "poll_", "(_", "0_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "events_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "\\u", "idle", "\\u", "done_", "=_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "events_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "our", " ", "chan", "ce", " ", "to", " ", "enter", " ", "idle_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "not_", "self_", "._", "\\u", "idle", "\\u", "done_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "for_", "callback_", "in_", "self_", "._", "\\u\\u", "idle", "\\u", "map_", "._", "values_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "callback_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "\\u", "idle", "\\u", "done_", "=_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "then", " ", "complete", " ", "the", " ", "actual", " ", "request", " ", "(", "adjust", "ing", " ", "timeo", "ut", ")_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "timeout_", "=_", "max_", "(_", "0_", ",_", "min_", "(_", "timeout_", ",_", "timeout_", "+_", "start_", "-_", "time_", "._", "time_", "(_", ")_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "events_", "=_", "self_", "._", "\\u\\u", "poll", "\\u", "obj_", "._", "poll_", "(_", "timeout_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "events_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "\\u", "idle", "\\u", "done_", "=_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "events_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "[SEP]_", "class_", "Tor", "nad", "o", "Event", "Loop_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "@_", "classmethod_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "\\u", "patch", "\\u", "poll", "\\u", "impl_", "(_", "cls_", ",_", "ioloop_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", " ", "Wra", "ps", " ", "original", " ", "poll", " ", "object", " ", "in", " ", "the", " ", "IO", "Loop", "'", "s", " ", "poll", " ", "object", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "ioloop_", "in_", "cls_", "._", "\\u", "io", "loop", "\\u", "registry_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "#", " ", "we", " ", "alr", "ead", "y", " ", "patche", "d", " ", "this", " ", "instance_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "cls_", "._", "\\u", "io", "loop", "\\u", "registry_", "[_", "ioloop_", "]_", "=_", "idle", "\\u", "map_", "=_", "{_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "ioloop_", "._", "\\u", "impl_", "=_", "cls_", "._", "Poll", "Proxy_", "(_", "ioloop_", "._", "\\u", "impl_", ",_", "idle", "\\u", "map_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Tor", "nad", "o", "Event", "Loop_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "\\u\\u", "init\\u\\u_", "(_", "self_", ",_", "ioloop_", "=_", "None_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "not_", "ioloop_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "from_", "tornado_", "._", "ioloop_", "import_", "IO", "Loop_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "ioloop_", "=_", "IO", "Loop_", "._", "instance_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "\\u", "ioloop_", "=_", "ioloop_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "\\u", "patch", "\\u", "poll", "\\u", "impl_", "(_", "ioloop_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "\\u", "pend", "ing", "\\u", "alarms_", "=_", "{_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "\\u", "watch", "\\u", "handles_", "=_", "{_", "}_", "#", " ", "{", "<", "watch", "\\u", "handle", ">", " ", ":", " ", "<", "file", "\\u", "descrip", "tor", ">}", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "\\u", "max", "\\u", "watch", "\\u", "handle_", "=_", "0_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "\\u", "exception_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Tor", "nad", "o", "Event", "Loop_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "alarm_", "(_", "self_", ",_", "secs_", ",_", "callback_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "ioloop_", "=_", "self_", "._", "\\u", "ioloop_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "wrapped_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "del_", "self_", "._", "\\u", "pend", "ing", "\\u", "alarms_", "[_", "handle_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "Key", "Error_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "pass_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "handle", "\\u", "exit_", "(_", "callback_", ")_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "handle_", "=_", "ioloop_", "._", "add", "\\u", "timeout_", "(_", "ioloop_", "._", "time_", "(_", ")_", "+_", "secs_", ",_", "wrapped_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "\\u", "pend", "ing", "\\u", "alarms_", "[_", "handle_", "]_", "=_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "handle_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Tor", "nad", "o", "Event", "Loop_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "remove", "\\u", "alarm_", "(_", "self_", ",_", "handle_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "\\u", "ioloop_", "._", "remove", "\\u", "timeout_", "(_", "handle_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "del_", "self_", "._", "\\u", "pend", "ing", "\\u", "alarms_", "[_", "handle_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "Key", "Error_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Tor", "nad", "o", "Event", "Loop_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "watch", "\\u", "file_", "(_", "self_", ",_", "fd_", ",_", "callback_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "from_", "tornado_", "._", "ioloop_", "import_", "IO", "Loop_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "handler_", "=_", "lambda_", "fd_", ",_", "events_", ":_", "self_", "._", "handle", "\\u", "exit_", "(_", "callback_", ")_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "\\u", "ioloop_", "._", "add", "\\u", "handler_", "(_", "fd_", ",_", "handler_", ",_", "IO", "Loop_", "._", "READ_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "\\u", "max", "\\u", "watch", "\\u", "handle_", "+=_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "handle_", "=_", "self_", "._", "\\u", "max", "\\u", "watch", "\\u", "handle_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "\\u", "watch", "\\u", "handles_", "[_", "handle_", "]_", "=_", "fd_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "handle_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Tor", "nad", "o", "Event", "Loop_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "remove", "\\u", "watch", "\\u", "file_", "(_", "self_", ",_", "handle_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "fd_", "=_", "self_", "._", "\\u", "watch", "\\u", "handles_", "._", "pop_", "(_", "handle_", ",_", "None_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "fd_", "is_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "\\u", "ioloop_", "._", "remove", "\\u", "handler_", "(_", "fd_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Tor", "nad", "o", "Event", "Loop_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "enter", "\\u", "idle_", "(_", "self_", ",_", "callback_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "\\u", "max", "\\u", "idle", "\\u", "handle_", "+=_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "handle_", "=_", "self_", "._", "\\u", "max", "\\u", "idle", "\\u", "handle_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "idle", "\\u", "map_", "=_", "self_", "._", "\\u", "io", "loop", "\\u", "registry_", "[_", "self_", "._", "\\u", "ioloop_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "idle", "\\u", "map_", "[_", "handle_", "]_", "=_", "callback_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "handle_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Tor", "nad", "o", "Event", "Loop_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "remove", "\\u", "enter", "\\u", "idle_", "(_", "self_", ",_", "handle_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "idle", "\\u", "map_", "=_", "self_", "._", "\\u", "io", "loop", "\\u", "registry_", "[_", "self_", "._", "\\u", "ioloop_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "cb_", "=_", "idle", "\\u", "map_", "._", "pop_", "(_", "handle_", ",_", "None_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "cb_", "is_", "not_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Tor", "nad", "o", "Event", "Loop_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "handle", "\\u", "exit_", "(_", "self_", ",_", "func_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "@_", "wraps_", "(_", "func_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "wrapper_", "(_", "*_", "args_", ",_", "**_", "kw_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "func_", "(_", "*_", "args_", ",_", "**_", "kw_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "Exi", "t", "Main", "Loop_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "\\u", "ioloop_", "._", "stop_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "Exception_", "as_", "exc_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "\\u", "exception_", "=_", "exc_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "\\u", "ioloop_", "._", "stop_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "wrapper_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Tor", "nad", "o", "Event", "Loop_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "run_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "\\u", "ioloop_", "._", "start_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "self_", "._", "\\u", "exception_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "exc_", ",_", "self_", "._", "\\u", "exception_", "=_", "self_", "._", "\\u", "exception_", ",_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "raise_", "exc_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "class_", "Twi", "sted", "Inp", "ut", "Descriptor_", "(_", "File", "Descriptor_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "[SEP]_", "class_", "Twi", "sted", "Inp", "ut", "Descriptor_", "(_", "File", "Descriptor_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "def_", "\\u\\u", "init\\u\\u_", "(_", "self_", ",_", "reactor_", ",_", "fd_", ",_", "cb_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "\\u", "fileno_", "=_", "fd_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "cb_", "=_", "cb_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "File", "Descriptor_", "._", "\\u\\u", "init\\u\\u_", "(_", "self_", ",_", "reactor_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Twi", "sted", "Inp", "ut", "Descriptor_", "(_", "File", "Descriptor_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "fileno_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "self_", "._", "\\u", "fileno_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Twi", "sted", "Inp", "ut", "Descriptor_", "(_", "File", "Descriptor_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "do", "Read_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "self_", "._", "cb_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "class_", "Twi", "sted", "Event", "Loop_", "(_", "object_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Event", " ", "loop", " ", "based", " ", "on", " ", "Twi", "sted", "\\u", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u", "idle", "\\u", "emulation", "\\u", "delay_", "=_", "1.0_", "/_", "256_", "#", " ", "a", " ", "short", " ", "time", " ", "(", "in", " ", "second", "s", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "[SEP]_", "class_", "Twi", "sted", "Event", "Loop_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "\\u\\u", "init\\u\\u_", "(_", "self_", ",_", "reactor_", "=_", "None_", ",_", "manage", "\\u", "reactor_", "=_", "True_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", ":", "param", " ", "react", "or", ":", " ", "react", "or", " ", "to", " ", "use", "\\", "10", ";", " ", " ", " ", " ", ":", "type", " ", "react", "or", ":", " ", ":", "class", ":`", "twist", "ed", ".", "interne", "t", ".", "react", "or", "`.", "\\", "10", ";", " ", " ", " ", " ", ":", "param", ":", " ", "manage", "\\u", "react", "or", ":", " ", "`", "Tru", "e", "`", " ", "if", " ", "you", " ", "want", " ", "this", " ", "event", " ", "loop", " ", "to", " ", "run", "\\", "10", ";", " ", " ", " ", " ", " ", " ", "and", " ", "stop", " ", "the", " ", "react", "or", ".", "\\", "10", ";", " ", " ", " ", " ", ":", "type", " ", "manage", "\\u", "react", "or", ":", " ", "boolean", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "..", " ", "WARN", "ING", "::", "\\", "10", ";", " ", " ", " ", "Twi", "sted", "'", "s", " ", "react", "or", " ", "doe", "sn", "'", "t", " ", "like", " ", "to", " ", "be", " ", "stopp", "ed", " ", "and", " ", "run", " ", "again", ".", " ", " ", "If", " ", "you", "\\", "10", ";", " ", " ", " ", "need", " ", "to", " ", "stop", " ", "and", " ", "run", " ", "your", " ", ":", "class", ":`", "Main", "Loop", "`", ",", " ", "consider", " ", "setti", "ng", "\\", "10", ";", " ", " ", " ", "``", "manage", "\\u", "react", "or", "=", "Fal", "se", "``", " ", "and", " ", "take", " ", "care", " ", "of", " ", "runn", "ing", "/", "stopping", " ", "the", " ", "react", "or", "\\", "10", ";", " ", " ", " ", "at", " ", "the", " ", "beginn", "ing", "/", "ending", " ", "of", " ", "your", " ", "program", " ", "your", "self", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "..", " ", "\\u", "Twi", "sted", ":", " ", "http", "://", "twist", "edm", "atrix", ".", "com", "/", "trac", "/", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "reactor_", "is_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "import_", "twisted_", "._", "internet_", "._", "reactor_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "reactor_", "=_", "twisted_", "._", "internet_", "._", "reactor_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "reactor_", "=_", "reactor_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "\\u", "alarms_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "\\u", "watch", "\\u", "files_", "=_", "{_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "\\u", "idle", "\\u", "handle_", "=_", "0_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "\\u", "twist", "ed", "\\u", "idle", "\\u", "enabled_", "=_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "\\u", "idle", "\\u", "callbacks_", "=_", "{_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "\\u", "exc", "\\u", "info_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "manage", "\\u", "reactor_", "=_", "manage", "\\u", "reactor_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "\\u", "enable", "\\u", "twist", "ed", "\\u", "idle_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Twi", "sted", "Event", "Loop_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "alarm_", "(_", "self_", ",_", "seconds_", ",_", "callback_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Call", " ", "callback", "()", " ", "give", "n", " ", "time", " ", "from", " ", "from", " ", "now", ".", " ", " ", "No", " ", "parameter", "s", " ", "are", "\\", "10", ";", " ", " ", " ", " ", "pass", "ed", " ", "to", " ", "callback", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "Return", "s", " ", "a", " ", "handle", " ", "tha", "t", " ", "may", " ", "be", " ", "pass", "ed", " ", "to", " ", "remove", "\\u", "alarm", "()", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "second", "s", " ", "--", " ", "float", "ing", " ", "point", " ", "time", " ", "to", " ", "wait", " ", "bef", "ore", " ", "calling", " ", "callback", "\\", "10", ";", " ", " ", " ", " ", "callback", " ", "--", " ", "function", " ", "to", " ", "call", " ", "from", " ", "event", " ", "loop", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "handle_", "=_", "self_", "._", "reactor_", "._", "call", "Later_", "(_", "seconds_", ",_", "self_", "._", "handle", "\\u", "exit_", "(_", "callback_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "handle_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Twi", "sted", "Event", "Loop_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "remove", "\\u", "alarm_", "(_", "self_", ",_", "handle_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Remove", " ", "an", " ", "alarm", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "Return", "s", " ", "Tru", "e", " ", "if", " ", "the", " ", "alarm", " ", "exist", "s", ",", " ", "Fal", "se", " ", "other", "wis", "e", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "twisted_", "._", "internet_", "._", "error_", "import_", "Al", "read", "y", "Cancel", "led_", ",_", "Al", "read", "y", "Call", "ed_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "handle_", "._", "cancel_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "Al", "read", "y", "Cancel", "led_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "Al", "read", "y", "Call", "ed_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Twi", "sted", "Event", "Loop_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "watch", "\\u", "file_", "(_", "self_", ",_", "fd_", ",_", "callback_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Call", " ", "callback", "()", " ", "whe", "n", " ", "fd", " ", "has", " ", "some", " ", "data", " ", "to", " ", "read", ".", " ", " ", "No", " ", "parameter", "s", "\\", "10", ";", " ", " ", " ", " ", "are", " ", "pass", "ed", " ", "to", " ", "callback", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "Return", "s", " ", "a", " ", "handle", " ", "tha", "t", " ", "may", " ", "be", " ", "pass", "ed", " ", "to", " ", "remove", "\\u", "watch", "\\u", "file", "()", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "fd", " ", "--", " ", "file", " ", "descrip", "tor", " ", "to", " ", "watch", " ", "for", " ", "input", "\\", "10", ";", " ", " ", " ", " ", "callback", " ", "--", " ", "function", " ", "to", " ", "call", " ", "whe", "n", " ", "input", " ", "is", " ", "avail", "able", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "ind_", "=_", "Twi", "sted", "Inp", "ut", "Descriptor_", "(_", "self_", "._", "reactor_", ",_", "fd_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "handle", "\\u", "exit_", "(_", "callback_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "\\u", "watch", "\\u", "files_", "[_", "fd_", "]_", "=_", "ind_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "reactor_", "._", "add", "Reader_", "(_", "ind_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "fd_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Twi", "sted", "Event", "Loop_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "remove", "\\u", "watch", "\\u", "file_", "(_", "self_", ",_", "handle_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Remove", " ", "an", " ", "input", " ", "file", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "Return", "s", " ", "Tru", "e", " ", "if", " ", "the", " ", "input", " ", "file", " ", "exist", "s", ",", " ", "Fal", "se", " ", "other", "wis", "e", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "handle_", "in_", "self_", "._", "\\u", "watch", "\\u", "files_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "reactor_", "._", "remove", "Reader_", "(_", "self_", "._", "\\u", "watch", "\\u", "files_", "[_", "handle_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "del_", "self_", "._", "\\u", "watch", "\\u", "files_", "[_", "handle_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Twi", "sted", "Event", "Loop_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "enter", "\\u", "idle_", "(_", "self_", ",_", "callback_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Add", " ", "a", " ", "callback", " ", "for", " ", "entering", " ", "idle", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "Return", "s", " ", "a", " ", "handle", " ", "tha", "t", " ", "may", " ", "be", " ", "pass", "ed", " ", "to", " ", "remove", "\\u", "enter", "\\u", "idle", "()", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "\\u", "idle", "\\u", "handle_", "+=_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "\\u", "idle", "\\u", "callbacks_", "[_", "self_", "._", "\\u", "idle", "\\u", "handle_", "]_", "=_", "callback_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "self_", "._", "\\u", "idle", "\\u", "handle_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Twi", "sted", "Event", "Loop_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "\\u", "enable", "\\u", "twist", "ed", "\\u", "idle_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Twi", "sted", "'", "s", " ", "react", "ors", " ", "don", "'", "t", " ", "have", " ", "an", " ", "idle", " ", "or", " ", "enter", "-", "idle", " ", "callback", "\\", "10", ";", " ", " ", " ", " ", "so", " ", "the", " ", "best", " ", "we", " ", "can", " ", "do", " ", "for", " ", "now", " ", "is", " ", "to", " ", "set", " ", "a", " ", "timer", " ", "event", " ", "in", " ", "a", " ", "very", "\\", "10", ";", " ", " ", " ", " ", "short", " ", "time", " ", "to", " ", "approximate", " ", "an", " ", "enter", "-", "idle", " ", "callback", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "..", " ", "WARN", "ING", "::", "\\", "10", ";", " ", " ", " ", "Thi", "s", " ", "will", " ", "perform", " ", "wor", "se", " ", "than", " ", "the", " ", "other", " ", "event", " ", "loop", "s", " ", "unti", "l", " ", "we", " ", "can", " ", "find", " ", "a", "\\", "10", ";", " ", " ", " ", "fix", " ", "or", " ", "workar", "ound", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "self_", "._", "\\u", "twist", "ed", "\\u", "idle", "\\u", "enabled_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "reactor_", "._", "call", "Later_", "(_", "self_", "._", "\\u", "idle", "\\u", "emulation", "\\u", "delay_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "handle", "\\u", "exit_", "(_", "self_", "._", "\\u", "twist", "ed", "\\u", "idle", "\\u", "callback_", ",_", "enable", "\\u", "idle_", "=_", "False_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "\\u", "twist", "ed", "\\u", "idle", "\\u", "enabled_", "=_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Twi", "sted", "Event", "Loop_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "\\u", "twist", "ed", "\\u", "idle", "\\u", "callback_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "for_", "callback_", "in_", "self_", "._", "\\u", "idle", "\\u", "callbacks_", "._", "values_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "callback_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "\\u", "twist", "ed", "\\u", "idle", "\\u", "enabled_", "=_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Twi", "sted", "Event", "Loop_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "remove", "\\u", "enter", "\\u", "idle_", "(_", "self_", ",_", "handle_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Remove", " ", "an", " ", "idle", " ", "callback", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "Return", "s", " ", "Tru", "e", " ", "if", " ", "the", " ", "handle", " ", "was", " ", "remove", "d", ".", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "del_", "self_", "._", "\\u", "idle", "\\u", "callbacks_", "[_", "handle_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "Key", "Error_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Twi", "sted", "Event", "Loop_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "run_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Start", " ", "the", " ", "event", " ", "loop", ".", " ", " ", "Exi", "t", " ", "the", " ", "loop", " ", "whe", "n", " ", "any", " ", "callback", " ", "raise", "s", "\\", "10", ";", " ", " ", " ", " ", "an", " ", "exception", ".", " ", " ", "If", " ", "Exi", "t", "Main", "Loop", " ", "is", " ", "raise", "d", ",", " ", "exit", " ", "clean", "ly", ".", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "not_", "self_", "._", "manage", "\\u", "reactor_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "reactor_", "._", "run_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "self_", "._", "\\u", "exc", "\\u", "info_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "An", " ", "exception", " ", "caus", "ed", " ", "us", " ", "to", " ", "exit", ",", " ", "raise", " ", "it", " ", "now_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "exc", "\\u", "info_", "=_", "self_", "._", "\\u", "exc", "\\u", "info_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "\\u", "exc", "\\u", "info_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "raise_", "exc", "\\u", "info_", "[_", "0_", "]_", ",_", "exc", "\\u", "info_", "[_", "1_", "]_", ",_", "exc", "\\u", "info_", "[_", "2_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Twi", "sted", "Event", "Loop_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "handle", "\\u", "exit_", "(_", "self_", ",_", "f_", ",_", "enable", "\\u", "idle_", "=_", "True_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Decorat", "or", " ", "tha", "t", " ", "clean", "ly", " ", "exits", " ", "the", " ", ":", "class", ":`", "Twi", "sted", "Event", "Loop", "`", " ", "if", "\\", "10", ";", " ", " ", " ", " ", ":", "class", ":`", "Exi", "t", "Main", "Loop", "`", " ", "is", " ", "throw", "n", " ", "insi", "de", " ", "of", " ", "the", " ", "wrapp", "ed", " ", "function", ".", " ", "Stor", "e", " ", "the", "\\", "10", ";", " ", " ", " ", " ", "exception", " ", "info", " ", "if", " ", "some", " ", "other", " ", "exception", " ", "occur", "s", ",", " ", "it", " ", "will", " ", "be", " ", "reraise", "d", " ", "after", "\\", "10", ";", " ", " ", " ", " ", "the", " ", "loop", " ", "quit", "s", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "*", "f", "*", " ", "--", " ", "function", " ", "to", " ", "be", " ", "wrapp", "ed", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "wrapper_", "(_", "*_", "args_", ",_", "**_", "kargs_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "rval_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "rval_", "=_", "f_", "(_", "*_", "args_", ",_", "**_", "kargs_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "Exi", "t", "Main", "Loop_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "self_", "._", "manage", "\\u", "reactor_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "self_", "._", "reactor_", "._", "stop_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "import_", "sys_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "print_", "sys_", "._", "exc", "\\u", "info_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "\\u", "exc", "\\u", "info_", "=_", "sys_", "._", "exc", "\\u", "info_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "self_", "._", "manage", "\\u", "reactor_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "self_", "._", "reactor_", "._", "crash_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "enable", "\\u", "idle_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "\\u", "enable", "\\u", "twist", "ed", "\\u", "idle_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "rval_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "wrapper_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "\\u", "refl", "_", "(_", "name_", ",_", "rval_", "=_", "None_", ",_", "exit_", "=_", "False_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Thi", "s", " ", "function", " ", "is", " ", "used", " ", "to", " ", "test", " ", "the", " ", "main", " ", "loop", " ", "classe", "s", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", ">>>", " ", "scr", " ", "=", " ", "\\u", "refl", "(\"", "screen", "\")", "\\", "10", ";", " ", " ", " ", " ", ">>>", " ", "scr", ".", "function", "(\"", "argu", "ment", "\")", "\\", "10", ";", " ", " ", " ", " ", "screen", ".", "function", "('", "argu", "ment", "')", "\\", "10", ";", " ", " ", " ", " ", ">>>", " ", "scr", ".", "call", "me", "(", "whe", "n", "=\"", "now", "\")", "\\", "10", ";", " ", " ", " ", " ", "screen", ".", "call", "me", "(", "whe", "n", "='", "now", "')", "\\", "10", ";", " ", " ", " ", " ", ">>>", " ", "scr", ".", "want", "\\u", "somet", "hing", "\\u", "rval", " ", "=", " ", "4", "2", "\\", "10", ";", " ", " ", " ", " ", ">>>", " ", "x", " ", "=", " ", "scr", ".", "want", "\\u", "somet", "hing", "()", "\\", "10", ";", " ", " ", " ", " ", "screen", ".", "want", "\\u", "somet", "hing", "()", "\\", "10", ";", " ", " ", " ", " ", ">>>", " ", "x", "\\", "10", ";", " ", " ", " ", " ", "4", "2", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "class_", "Reflect", "_", "(_", "object_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "def_", "\\u\\u", "init\\u\\u_", "(_", "self_", ",_", "name_", ",_", "rval_", "=_", "None_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "\\u", "name_", "=_", "name_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "\\u", "rval_", "=_", "rval_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "\\u\\u", "call\\u\\u_", "(_", "self_", ",_", "*_", "argl", "_", ",_", "**_", "argd_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "args_", "=_", "\",", " ", "\"_", "._", "join_", "(_", "[_", "repr_", "(_", "a_", ")_", "for_", "a_", "in_", "argl", "_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "args_", "and_", "argd_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "args_", "=_", "args_", "+_", "\",", " ", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "args_", "=_", "args_", "+_", "\",", " ", "\"_", "._", "join_", "(_", "[_", "k_", "+_", "\"=\"_", "+_", "repr_", "(_", "v_", ")_", "for_", "k_", ",_", "v_", "in_", "argd_", "._", "items_", "(_", ")_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "print_", "self_", "._", "\\u", "name_", "+_", "\"(\"_", "+_", "args_", "+_", "\")\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "exit_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "raise_", "Exi", "t", "Main", "Loop_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "self_", "._", "\\u", "rval_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "\\u\\u", "getattr\\u\\u_", "(_", "self_", ",_", "attr_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "attr_", "._", "endswith_", "(_", "\"\\u", "rval", "\"_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "raise_", "Attribute", "Error_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", "print", " ", "self", ".\\u", "name", "+\"", ".\"", "+", "attr_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "hasattr_", "(_", "self_", ",_", "attr_", "+_", "\"\\u", "rval", "\"_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "Reflect", "_", "(_", "self_", "._", "\\u", "name_", "+_", "\".\"_", "+_", "attr_", ",_", "getattr_", "(_", "self_", ",_", "attr_", "+_", "\"\\u", "rval", "\"_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "Reflect", "_", "(_", "self_", "._", "\\u", "name_", "+_", "\".\"_", "+_", "attr_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "Reflect", "_", "(_", "name_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "\\u", "test_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "import_", "doctest_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "doctest_", "._", "testmod_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_" ]
[ 4, 4, 4, 4, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,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 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 ]
Unused import
openeventdata/petrarch2/petrarch2/PETRtree.py
[ { "content": "\n\nfrom __future__ import print_function\nfrom __future__ import unicode_literals\n\n\nimport PETRglobals\nimport PETRreader\nimport time\nimport utilities\nimport types\n\n# -- from inspect import getouterframes, currentframe # -- # used to track the levels of recursion\n\n\n\n# PETRtree.py\n# Author: Clayton Norris\n# Caerus Associates/ University of Chicago\n#\n#\n# Purpose:\n# Called from petrarch.py, this contains the main logic\n# of the Petrarch software. Sentences are stored into\n# Sentence class objects, which contain a tree of Phrase\n# class objects. The phrases then do analyses of their role\n# in the sentence and the event information of the overall sentence\n# is calculated and returned within the get_events() method\n#\n#\n# Revision history:\n# July 2015 - Created\n# August 2015 - First release\n# April 2016 - Bugs causing crashes in very low frequency cases corrected \n\n# pas 16.04.22: print() statements commented-out with '# --' were used in the debugging and can probably be removed\n\n\n\n\n\n\n\n\n\n\n\n", "metadata": "root", "header": "['module', '___EOS___']", "index": 0 }, { "content": "class Phrase:\n \"\"\"\n This is a general class for all Phrase instances, which make up the nodes in the syntactic tree.\n The three subtypes are below.\n \n \"\"\"\n \n \n \n\n \n\n\n\n\n\n\n\n\n\n\n", "metadata": "root.Phrase", "header": "['module', '___EOS___']", "index": 37 }, { "content": " def __init__(self, label, date,sentence):\n \"\"\"\n Initialization for Phrase classes. \n \n \n Parameters\n -----------\n \n label: list\n Label for the phrase type, date\n \n Returns\n -------\n An instantiated Phrase object\n\n \"\"\"\n self.label = label if not label == \"MD\" else \"VB\"\n self.children = []\n self.phrasetype = label[0]\n self.annotation = \"\"\n self.text = \"\"\n self.parent = None\n self.meaning = \"\"\n self.verbclass = \"\"\n self.date = date\n self.index = -1\n self.head = None\n self.head_phrase = None\n self.color = False\n self.sentence = sentence", "metadata": "root.Phrase.__init__", "header": "['class', 'Phrase', ':', '___EOS___']", "index": 44 }, { "content": " def get_meaning(self):\n \"\"\"\n Method for returning the meaning of the subtree rooted by this phrase,\n is overwritten by all subclasses, so this works primarily for\n S and S-Bar phrases.\n \n \n \n Parameters\n -----------\n self: Phrase object that called the method\n \n \n Returns\n -------\n \n events: list\n Combined meanings of the phrases children\n \"\"\"\n \n if self.label in \"SBAR\":\n lower = map(lambda b: b.get_meaning(), filter(lambda a: a.label in \"SBARVP\",self.children))\n events = []\n for item in lower:\n events += item\n if events:\n self.meaning = events\n return events\n \n return self.meaning", "metadata": "root.Phrase.get_meaning", "header": "['class', 'Phrase', ':', '___EOS___']", "index": 76 }, { "content": " def get_text(self):\n if self.color:\n return \"\"\n text = self.text\n for child in self.children:\n if isinstance(child,NounPhrase):\n text += \" \" + child.get_text()[0]\n else:\n text += \" \" + child.get_text()\n \n return text", "metadata": "root.Phrase.get_text", "header": "['class', 'Phrase', ':', '___EOS___']", "index": 107 }, { "content": " def resolve_codes(self,codes):\n \"\"\"\n Method that divides a list of mixed codes into actor and agent codes\n \n Parameters\n -----------\n codes: list\n Mixed list of codes\n \n Returns\n -------\n actorcodes: list\n List of actor codes\n \n agentcodes: list\n List of actor codes\n \n \"\"\"\n# -- print('Prc-entry',len(getouterframes(currentframe(1))),codes) # --\n if not codes:\n return [],[]\n \n actorcodes = []\n agentcodes = []\n for code in codes:\n if not code:\n continue\n \"\"\"if isinstance(code,tuple):\n actorcodes.append(code)\n else:\n agentcodes.append(code)\"\"\"\n if code.startswith(\"~\"):\n agentcodes.append(code)\n else:\n actorcodes.append(code)\n return actorcodes,agentcodes", "metadata": "root.Phrase.resolve_codes", "header": "['class', 'Phrase', ':', '___EOS___']", "index": 119 }, { "content": " def mix_codes(self,agents,actors):\n \"\"\"\n Combine the actor codes and agent codes addressing duplicates\n and removing the general \"~PPL\" if there's a better option.\n \n Parameters\n -----------\n agents, actors : Lists of their respective codes\n \n \n Returns\n -------\n codes: list\n [Agent codes] x [Actor codes]\n \n \"\"\"\n \n \n# -- print('mc-entry',actors,agents)\n codes = set()\n mix = lambda a, b : a + b if not b in a else a\n actors = actors if actors else ['~']\n for ag in agents:\n if ag == '~PPL' and len(agents) > 1:\n continue\n# actors = map( lambda a : mix( a[0], ag[1:]), actors)\n actors = map( lambda a : mix( a, ag[1:]), actors)\n \n# -- print('mc-1',actors)\n return filter(lambda a : a not in ['','~','~~',None],actors)\n \n \n \n # 16.04.25 hmmm, this is either a construct of utterly phenomenal subtlety or else we never hit this code...\n codes = set()\n print('WTF-1')\n for act in (actors if actors else ['~']):\n for ag in (agents if agents else ['~']) :\n if ag == \"~PPL\" and len(agents) > 1:\n continue\n code = act\n if not ag[1:] in act:\n code += ag[1:]\n if not code in ['~','~~',\"\"]:\n codes.add(code)\n return list(codes)", "metadata": "root.Phrase.mix_codes", "header": "['class', 'Phrase', ':', '___EOS___']", "index": 158 }, { "content": " def return_head(self):\n return self.head,self.head_phrase", "metadata": "root.Phrase.return_head", "header": "['class', 'Phrase', ':', '___EOS___']", "index": 207 }, { "content": " def get_head(self):\n \"\"\"\n Method for finding the head of a phrase. The head of a phrase is the rightmost\n word-level constituent such that the path from root to head consists only of similarly-labeled\n phrases.\n \n Parameters\n -----------\n self: Phrase object that called the method\n \n Returns\n -------\n possibilities[-1]: tuple (string,NounPhrase)\n (The text of the head of the phrase, the NounPhrase object whose rightmost child is the\n head).\n \n \n \"\"\"\n self.get_head = self.return_head\n try:\n if self.label == 'S':\n self.head, self.head_phrase = map(lambda b: b.get_head(),filter(lambda a : a.label == 'VP', self.children))[0]\n return (self.head,self.head_phrase)\n elif self.label == 'ADVP':\n return self.children[0].text,self\n if (not self.label[1] == 'P'):\n return (self.text,self.parent)\n \n head_children = filter(lambda child : child.label.startswith(self.label[0]) and not child.label[1] == 'P', self.children)\n if head_children:\n possibilities = filter(None, map(lambda a: a.get_head(),head_children))\n else:\n other_children= filter(lambda child : child.label.startswith(self.label[0]), self.children)\n possibilities = filter(None, map(lambda a: a.get_head(),other_children))\n \n self.head_phrase = possibilities[-1][1]\n self.head = possibilities[-1][0] # return the last, English usually compounds words to the front\n return possibilities[-1]\n \n except:\n return (None,None)", "metadata": "root.Phrase.get_head", "header": "['class', 'Phrase', ':', '___EOS___']", "index": 212 }, { "content": " def print_to_stdout(self,indent):\n print(indent, self.label,self.text,self.get_meaning())\n for child in self.children:\n child.print_to_stdout(indent + \"\\t\")", "metadata": "root.Phrase.print_to_stdout", "header": "['class', 'Phrase', ':', '___EOS___']", "index": 255 }, { "content": "class NounPhrase(Phrase):\n \"\"\"\n Class specific to noun phrases. \n \n Methods: get_meaning() - specific version of the super's method\n check_date() - find the date-specific version of an actor\n \n \"\"\"\n \n \n\n\n\n\n\n\n\n", "metadata": "root.NounPhrase", "header": "['module', '___EOS___']", "index": 262 }, { "content": " def __init__(self, label, date, sentence):\n Phrase.__init__(self, label, date, sentence )", "metadata": "root.NounPhrase.__init__", "header": "['class', 'NounPhrase', '(', 'Phrase', ')', ':', '___EOS___']", "index": 270 }, { "content": " def return_meaning(self):\n return self.meaning", "metadata": "root.NounPhrase.return_meaning", "header": "['class', 'NounPhrase', '(', 'Phrase', ')', ':', '___EOS___']", "index": 274 }, { "content": " def get_text(self):\n \"\"\"\n Noun-specific get text method\n \"\"\"\n PPcodes = []\n text = \"\"\n for child in self.children:\n if isinstance(child,PrepPhrase):\n m = self.resolve_codes(child.get_meaning())\n if m[0]:\n PPcodes += child.get_meaning()\n else:\n text += \" \" + child.get_text()\n if isinstance(child,NounPhrase):\n value = child.get_text()\n text += value[0]\n PPcodes += value[1]\n if child.label[:2] in [\"JJ\",\"NN\",\"DT\"]:\n text += \" \"+child.text\n return text,PPcodes", "metadata": "root.NounPhrase.get_text", "header": "['class', 'NounPhrase', '(', 'Phrase', ')', ':', '___EOS___']", "index": 278 }, { "content": " def check_date(self, match):\n \"\"\"\n Method for resolving date restrictions on actor codes. \n \n Parameters\n -----------\n match: list\n Dates and codes from the dictionary\n \n Returns\n -------\n code: string\n The code corresponding to how the actor should be coded given the date\n \"\"\"\n \n code = None\n try:\n \n for j in match:\n dates = j[1]\n date = []\n code = \"\"\n for d in dates:\n if d[0] in '<>':\n date.append(d[0]+str(PETRreader.dstr_to_ordate(d[1:])))\n else:\n date.append(str(PETRreader.dstr_to_ordate(d)))\n curdate= self.date\n if not date:\n code = j[0]\n elif len(date) == 1:\n if date[0][0] == '<':\n if curdate < int(date[0][1:]):\n code = j[0]\n else:\n if curdate >= int(date[0][1:]):\n code = j[0]\n else:\n if curdate < int(date[1]):\n if curdate >= int(date[0]):\n code = j[0]\n \n if code:\n return code\n except Exception as e:\n #print(e)\n return code \n\n return code", "metadata": "root.NounPhrase.check_date", "header": "['class', 'NounPhrase', '(', 'Phrase', ')', ':', '___EOS___']", "index": 299 }, { "content": " def get_meaning(self):\n\n def recurse(path, words, length,so_far= \"\"):\n \n# -- print('NPgm-rec-lev:',len(getouterframes(currentframe(1)))) # --\n \n if words and words[0] in path:\n match = recurse(path[words[0]],words[1:],length + 1 , so_far + \" \" + words[0])\n if match:\n return match\n if '#' in path:\n if isinstance(path[\"#\"],list):\n code = self.check_date(path['#'])\n if not code is None:\n \"\"\"print('NPgm-rec-1:',code) # --\n print('NPgm-rec-1.1:',path['#'][-1])\"\"\"\n return [code] , so_far, length, [path['#'][-1]] # 16.04.25 this branch always resolves to an actor; path['#'][-1] is the root string\n else:\n# -- print('NPgm-rec-2:',path['#'])\n return [path['#']], so_far, length # 16.04.25 this branch always resolves to an agent\n return False\n\n text_children = []\n PPcodes = []\n VPcodes = []\n NPcodes = []\n codes = []\n roots = []\n # -- print('NPgm-0:',self.get_text()) # --\n \n matched_txt = []\n \n for child in self.children:\n if isinstance(child,NounPhrase):\n value = child.get_text()\n text_children += value[0].split()\n NPcodes += value[1]\n elif child.label[:2] in [\"JJ\",\"DT\",\"NN\"]:\n text_children += child.get_text().split()\n \n elif child.label == \"PP\":\n m = self.resolve_codes(child.get_meaning())\n# -- print('gm-1:',m) # --\n if m[0]:\n PPcodes += child.get_meaning()\n else:\n text_children += child.get_text().split()\n \n elif child.label == \"VP\":\n m = child.get_meaning()\n if m and isinstance(m[0][1],basestring):\n m = self.resolve_codes(m[0][1])\n if m[0]:\n VPcodes += child.get_theme()\n else:\n pass\n # We could add the subtree here, but there shouldn't be any codes with VP components\n elif child.label == \"PRP\":\n # Find antecedent\n not_found = True\n level = self.parent\n reflexive = child.text.endswith(\"SELF\") or child.text.endswith(\"SELVES\")\n local = True\n while not_found and level.parent:\n if level.label.startswith(\"NP\") and reflexive: #Intensive, ignore\n break\n if local and level.label in [\"S\",\"SBAR\"]:\n local = False\n level=level.parent\n continue\n \n if (not local) or (reflexive and local):\n for child in level.parent.children:\n if isinstance(child,NounPhrase): \n if not child.get_meaning() == \"~\" : # Do we just want to pick the first?\n not_found = False\n codes += child.get_meaning()\n break\n\n level = level.parent\n \n \n # check whether there are codes in the noun Phrase\n index = 0\n while index < len(text_children):\n match = recurse(PETRglobals.ActorDict,text_children[index:],0) # checking for actors\n if match:\n# -- print('NPgm-m-1:',match)\n codes += match[0]\n roots += match[3]\n index += match[2]\n matched_txt += [match[1]]\n# -- print('NPgm-1:',matched_txt)\n continue\n\n match = recurse(PETRglobals.AgentDict,text_children[index:],0) # checking for agents\n if match:\n# -- print('NPgm-2.0:',roots)\n codes += match[0]\n roots += [['~']]\n index += match[2]\n matched_txt += [match[1]]\n \"\"\"print('NPgm-2:',matched_txt) # --\n print('NPgm-2.1:',roots)\"\"\"\n continue\n index += 1\n \n \"\"\"print('NPgm-m-lev:',len(getouterframes(currentframe(1)))) # -- \n print('NPgm-m-codes:',codes)\n print('NPgm-m-roots:',roots)\"\"\"\n # combine the actor/agent codes\n actorcodes,agentcodes = self.resolve_codes(codes)\n PPactor, PPagent = self.resolve_codes(PPcodes)\n NPactor, NPagent = self.resolve_codes(NPcodes)\n VPactor, VPagent = self.resolve_codes(VPcodes)\n if not actorcodes:\n actorcodes += NPactor # don't really need += here, right? pas 16.04.26\n if not actorcodes:\n actorcodes += PPactor\n if not actorcodes:\n actorcodes += VPactor # Do we want to pull meanings from verb phrases? Could be risky\n \n if not agentcodes:\n agentcodes += NPagent\n if not agentcodes:\n agentcodes += PPagent\n if not agentcodes:\n agentcodes += VPagent\n\n \"\"\"if len(actorcodes) > 0:\n print('NPgm-m-actorcodes:',actorcodes)\n print('NPgm-m-roots :',roots)\"\"\"\n \n self.meaning = self.mix_codes(agentcodes,actorcodes)\n self.get_meaning = self.return_meaning\n \"\"\"print('NPgm-3:',self.meaning)\n print('NPgm-4:',matched_txt)\"\"\"\n if matched_txt:\n self.sentence.metadata['nouns'] += [(matched_txt,self.meaning, roots[:len(matched_txt)])] \n# self.sentence.print_nouns('NPgm-5:') # --\n return self.meaning", "metadata": "root.NounPhrase.get_meaning", "header": "['class', 'NounPhrase', '(', 'Phrase', ')', ':', '___EOS___']", "index": 350 }, { "content": " def convert_existential(self):\n # Reshuffle the tree to get existential \"There are\" phrases into a more basic form\n parent = self.parent\n sister = parent.children[1]\n neice = sister.children[1]\n subject = neice.children[0]\n predicate = neice.children[1]\n \n \n parent.children[0] = subject\n subject.parent = parent\n \n sister.children[1] = predicate\n predicate.parent = sister\n \n self.parent = None\n\n\n #parent.print_to_stdout(\"\")\n return subject", "metadata": "root.NounPhrase.convert_existential", "header": "['class', 'NounPhrase', '(', 'Phrase', ')', ':', '___EOS___']", "index": 494 }, { "content": "class PrepPhrase(Phrase):\n\n\n", "metadata": "root.PrepPhrase", "header": "['module', '___EOS___']", "index": 516 }, { "content": " def __init__(self, label, date, sentence):\n Phrase.__init__(self, label, date, sentence)\n self.meaning = \"\"\n self.prep = \"\"\n self.head = \"\"", "metadata": "root.PrepPhrase.__init__", "header": "['class', 'PrepPhrase', '(', 'Phrase', ')', ':', '___EOS___']", "index": 518 }, { "content": " def get_meaning(self):\n \"\"\"\n Return the meaning of the non-preposition constituent, and store the\n preposition.\n \n Note: pas 16.04.22\n Add this len() > 0 check to get around a very rare (about 0.001% of LN sentences) cases where a (PP (PRP structure\n caused an infinite recursion between NounPhrase.get_meaning() and PrepPhrase.get_meaning() in circumstances where\n self.children[1].get_text() gave an empty string. This solves the problem but I'm not completely confident this is \n the right place to trap it: in the process of debugging I noticed that there were cases where this recursion \n seemed to go a lot deeper than necessary, continuing with the same string, on some non-empty strings, though it \n did not crash. \n \"\"\"\n# -- print('PPgm-entry') # --\n self.prep = self.children[0].text\n if len(self.children) > 1 and not self.children[1].color: \n if isinstance(self.children[1],NounPhrase) and len(self.children[1].get_text()[0]) > 0: # see note above\n# -- print('PPgm-503',self.children[1].get_text()) # --\n self.meaning = self.children[1].get_meaning() \n else:\n self.meaning = \"\"\n# self.meaning = self.children[1].get_meaning() if isinstance(self.children[1],NounPhrase) else \"\" # code prior to the correction\n# -- print('PPgm-2',self.meaning) # --\n self.head = self.children[1].get_head()[0]\n \n return self.meaning", "metadata": "root.PrepPhrase.get_meaning", "header": "['class', 'PrepPhrase', '(', 'Phrase', ')', ':', '___EOS___']", "index": 524 }, { "content": " def get_prep(self):\n \n return self.children[0].text", "metadata": "root.PrepPhrase.get_prep", "header": "['class', 'PrepPhrase', '(', 'Phrase', ')', ':', '___EOS___']", "index": 551 }, { "content": "class VerbPhrase(Phrase):\n \"\"\"\n Subclass specific to Verb Phrases\n \n Methods\n -------\n __init__: Initialization and Instatiation\n \n is_valid: Corrects a known stanford error regarding miscoded noun phrases\n \n get_theme: Returns the coded target of the VP\n \n get_meaning: Returns event coding described by the verb phrase\n \n get_lower: Finds meanings of children\n \n get_upper: Finds grammatical subject\n \n get_code: Finds base verb code and calls match_pattern\n \n match_pattern: Matches the tree to a pattern in the Verb Dictionary\n \n get_S: Finds the closest S-level phrase above the verb\n \n match_transform: Matches an event code against transformation patterns in the dictionary\n \n \"\"\"\n\n \n \n \n \n \n\n \n \n\n\n\n \n\n\n\n\n\n\n\n \n\n\n\n \n", "metadata": "root.VerbPhrase", "header": "['module', '___EOS___']", "index": 556 }, { "content": " def __init__(self,label,date,sentence):\n Phrase.__init__(self,label,date,sentence)\n self.meaning = \"\" # \"meaning\" for the verb, i.e. the events coded by the vp\n self.upper = \"\" # contains the meaning of the noun phrase in the specifier position for the vp or its parents\n self.lower = \"\" # contains the meaning of the subtree c-commanded by the verb\n self.passive = False\n self.code = 0\n self.valid = self.is_valid()\n self.S = None", "metadata": "root.VerbPhrase.__init__", "header": "['class', 'VerbPhrase', '(', 'Phrase', ')', ':', '___EOS___']", "index": 584 }, { "content": " def is_valid(self):\n \"\"\"\n This method is largely to overcome frequently made Stanford errors, where phrases like \"exiled dissidents\" were\n marked as verb phrases, and treating them as such would yield weird parses.\n \n Once such a phrase is identified because of its weird distribution, it is converted to \n a NounPhrase object\n \n \"\"\"\n try:\n if self.children[0].label == \"VBN\":\n helping = [\"HAVE\",\"HAD\",\"HAVING\",\"HAS\"]\n if ((not (self.parent.get_head()[0] in helping or self.parent.children[0].text in helping)) and\n len(filter(lambda a: isinstance(a,VerbPhrase),self.parent.children)) <= 1 and\n not self.check_passive()):\n \n self.valid = False\n \n np_replacement = NounPhrase(\"NP\",self.date,self.sentence)\n np_replacement.children = self.children\n np_replacement.parent = self.parent\n np_replacement.index = self.index\n \n self.parent.children.remove(self)\n self.parent.children.insert(self.index,np_replacement)\n del(self)\n self = np_replacement\n return False\n self.valid = True\n except IndexError as e:\n self.valid = True\n return True", "metadata": "root.VerbPhrase.is_valid", "header": "['class', 'VerbPhrase', '(', 'Phrase', ')', ':', '___EOS___']", "index": 594 }, { "content": " def get_theme(self):\n \"\"\"\n This is used by the NounPhrase.get_meaning() method to determine relevant\n information in the VerbPhrase.\n \"\"\"\n m = self.get_meaning()\n if isinstance(m[0],basestring):\n return [m[0]]\n if m[0][1] == 'passive':\n return m[0][0]\n return [m[0][1]]", "metadata": "root.VerbPhrase.get_theme", "header": "['class', 'VerbPhrase', '(', 'Phrase', ')', ':', '___EOS___']", "index": 627 }, { "content": " def return_meaning(self):\n return self.meaning", "metadata": "root.VerbPhrase.return_meaning", "header": "['class', 'VerbPhrase', '(', 'Phrase', ')', ':', '___EOS___']", "index": 639 }, { "content": " def get_meaning(self):\n \"\"\"\n This determines the event coding of the subtree rooted in this verb phrase.\n \n Four methods are key in this process: get_upper(), get_lower(), get_code() \n and match_transform().\n \n First, get_meaning() gets the verb code from get_code()\n \n Then, it checks passivity. If the verb is passive, then it looks within \n verb phrases headed by [by, from, in] for the source, and for an explicit target\n in verb phrases headed by [at,against,into,towards]. If no target is found,\n this space is filled with 'passive', a flag used later to assign a target\n if it is in the grammatical subject position. \n \n If the verb is not passive, then the process goes:\n \n 1) call get_upper() and get_lower() to check for a grammatical subject \n and find the coding of the subtree and children, respectively.\n \n 2) If get_lower returned a list of events, combine those events with\n the upper and code, add to event list.\n \n 3) Otherwise, combine upper, lower, and code and add to event list\n \n 4) Check to see if there are S-level children, if so, combine with\n upper and code, add to list. \n \n 5) call match_transform() on all events in the list\n \n \n Parameters\n ----------\n self: VerbPhrase object that called the method\n \n Returns\n -------\n events: list\n List of events coded by the subtree rooted in this phrase.\n \n \"\"\"\n time1 = time.time()\n self.get_meaning = self.return_meaning\n \n c, passive,meta = self.get_code()\n s_options = filter(lambda a: a.label in \"SBAR\",self.children)\n\n def resolve_events(event):\n \"\"\"\n Helper method to combine events, accounting for \n missing sources, and targets, passives, multiple-\n target passives, and codeless verbs.\n \n Parameters\n ----------\n event: tuple\n (source, target, code) of lower event\n \n Returns\n -------\n returns: [tuple]\n list of resolved event tuples\n \"\"\"\n returns = []\n first,second,third = [up,\"\",\"\"]\n if not (up or c) :\n return [event]\n if not isinstance(event,tuple):\n second = event\n third = c\n if passive:\n for item in first:\n e2 = ([second],item,passive)\n self.sentence.metadata[id(e2)] = [event,meta,7]\n returns.append(e2)\n elif event[1] == 'passive':\n first = event[0]\n third = utilities.combine_code(c,event[2])\n if up:\n returns = []\n for source in up:\n e = (first,source,third)\n self.sentence.metadata[id(e)] = [event,up,1]\n returns.append(e)\n return returns\n second = 'passive'\n elif not event[0] in ['',[],[\"\"],[\"~\"],[\"~~\"]]:\n second = event\n third = c\n else:\n second = event[1]\n third = utilities.combine_code(c,event[2])\n e = (first,second,third)\n self.sentence.metadata[id(e)] = [event,c,meta ,2]\n return returns + [e]\n\n events = []\n up = self.get_upper()\n if self.check_passive() or (passive and not c):\n # Check for source in preps\n source_options = []\n target_options = up\n for child in self.children:\n if isinstance(child,PrepPhrase):\n if child.get_prep() in [\"BY\",\"FROM\",\"IN\"]:\n source_options += child.get_meaning()\n meta.append((child.prep, child.get_meaning()))\n elif child.get_prep() in [\"AT\",\"AGAINST\",\"INTO\",\"TOWARDS\"]:\n target_options += child.get_meaning()\n meta.append((child.prep, child.get_meaning()))\n if not target_options:\n target_options = [\"passive\"]\n if source_options or c:\n \n for i in target_options:\n e = (source_options, i ,c if self.check_passive() else passive)\n events.append(e)\n self.sentence.metadata[id(e)] = [None,e,meta,3]\n self.meaning = events\n return events\n \n up = \"\" if up in ['',[],[\"\"],[\"~\"],[\"~~\"]] else up\n low,neg = self.get_lower()\n if not low:\n low = \"\"\n if neg:\n c = 0\n \n if isinstance(low,list):\n for event in low:\n events += resolve_events(event)\n elif not s_options:\n if up or c:\n e = (up,low,c)\n self.sentence.metadata[id(e)] = [None,e,4]\n events.append(e)\n elif low:\n events.append(low)\n\n lower = map(lambda a: a.get_meaning(),s_options)\n sents = []\n\n for item in lower:\n sents += item\n \n if sents and not events: # Only if nothing else has been found do we look at lower NP's?\n # This decreases our coding frequency, but removes many false positives\n for event in sents:\n if isinstance(event,tuple) and (event[1] or event[2]):\n for ev in resolve_events(event):\n if isinstance(ev[1],list):\n for item in ev[1]:\n local = (ev[0],item,ev[2])\n self.sentence.metadata[id(local)] = [ev,item,5]\n events.append(local)\n else:\n events += resolve_events(event)\n maps = []\n for i in events:\n evs = self.match_transform(i)\n if isinstance(evs,tuple):\n for j in evs[0]:\n maps.append(j)\n self.sentence.metadata[id(j)] = [i,evs[1],6]\n else:\n maps += evs\n self.meaning = maps\n return maps", "metadata": "root.VerbPhrase.get_meaning", "header": "['class', 'VerbPhrase', '(', 'Phrase', ')', ':', '___EOS___']", "index": 642 }, { "content": " def return_upper(self):\n return self.upper", "metadata": "root.VerbPhrase.return_upper", "header": "['class', 'VerbPhrase', '(', 'Phrase', ')', ':', '___EOS___']", "index": 812 }, { "content": " def return_passive(self):\n return self.passive", "metadata": "root.VerbPhrase.return_passive", "header": "['class', 'VerbPhrase', '(', 'Phrase', ')', ':', '___EOS___']", "index": 815 }, { "content": " def check_passive(self):\n \"\"\"\n Check if the verb is passive under these conditions:\n 1) Verb is -ed form, which is notated by stanford as VBD or VBN\n 2) Verb has a form of \"be\" as its next highest verb \n \n Parameters\n ----------\n self: VerbPhrase object calling the method\n \n Returns\n -------\n self.passive: boolean\n Whether or not it is passive\n \"\"\"\n# -- print('cp-entry')\n self.check_passive = self.return_passive\n if True:\n if self.children[0].label in [\"VBD\",\"VBN\"]:\n level= self.parent\n if level.label == \"NP\":\n self.passive = True\n return True\n for i in range(2):\n if level and isinstance(level,VerbPhrase):\n if level.children[0].text in [\"AM\",\"IS\",\"ARE\",\"WAS\",\"WERE\",\"BE\",\"BEEN\",\"BEING\"]:\n self.passive = True\n return True\n level = level.parent\n if not level:\n break\n \n else:\n print(\"Error in passive check\")\n self.passive = False\n return False", "metadata": "root.VerbPhrase.check_passive", "header": "['class', 'VerbPhrase', '(', 'Phrase', ')', ':', '___EOS___']", "index": 818 }, { "content": " def return_S(self):\n# -- print('rS-entry')\n return self.S", "metadata": "root.VerbPhrase.return_S", "header": "['class', 'VerbPhrase', '(', 'Phrase', ')', ':', '___EOS___']", "index": 856 }, { "content": " def get_S(self):\n \"\"\"\n Navigate up the tree following a VP path to find the closest s-level phrase. \n There is the extra condition that if the S-level phrase is a \"TO\"-phrase \n without a second subject specified, just so that \"A wants to help B\" will\n navigate all the way up to \"A wants\" rather than stopping at \"to\"\n \n Parameters\n -----------\n self: VerbPhrase object that called the method\n \n Returns\n -------\n level: VerbPhrase object\n Lowest non-TO S-level phrase object above the verb\n \"\"\"\n# -- print('gS-entry')\n self.get_S = self.return_S\n not_found = True\n level = self\n while not_found and not level.parent is None:\n if isinstance(level.parent, VerbPhrase):\n level = level.parent\n elif level.parent.label == \"S\":\n if level.children[0].label == \"TO\" and level.index == 0:\n level = level.parent\n continue\n self.S = level.parent\n return level.parent\n else:\n return level\n return None", "metadata": "root.VerbPhrase.get_S", "header": "['class', 'VerbPhrase', '(', 'Phrase', ')', ':', '___EOS___']", "index": 860 }, { "content": " def get_upper(self):\n \"\"\"\n Finds the meaning of the specifier (NP sibling) of the VP. \n \n Parameters\n -----------\n self: VerbPhrase object that called the method\n \n Returns\n -------\n self.upper: List \n Actor codes of spec-VP\n \"\"\"\n self.get_upper = self.return_upper\n for child in self.parent.children:\n if isinstance(child, NounPhrase) and not child.get_meaning() == [\"~\"]:\n self.upper = child.get_meaning()\n \n return self.upper\n return []", "metadata": "root.VerbPhrase.get_upper", "header": "['class', 'VerbPhrase', '(', 'Phrase', ')', ':', '___EOS___']", "index": 895 }, { "content": " def return_lower(self):\n return self.lower", "metadata": "root.VerbPhrase.return_lower", "header": "['class', 'VerbPhrase', '(', 'Phrase', ')', ':', '___EOS___']", "index": 918 }, { "content": " def get_lower(self):\n \"\"\"\n Find the meaning of the children of the VP, and whether or not there is a \"not\" in the VP.\n \n If the VP has VP children, look only at these.\n \n Otherwise, this function pretty much is identical to the NounPhrase.get_meaning() \n method, except that it doesn't look at word-level children, because it shouldn't\n have any. \n \n Parameters\n -----------\n self: VerbPhrase object that called the method\n \n Returns\n -------\n self.lower: list\n Actor codes or Event codes, depending on situation\n \n negated: boolean\n Whether a \"not\" is present\n \n \"\"\"\n \n self.get_lower = self.return_lower\n \n lower = []\n v_options = filter(lambda a: (isinstance(a,VerbPhrase) and a.is_valid()),self.children)\n \n lower = map(lambda a: a.get_meaning(),v_options)\n\n events = []\n \n if len(self.children) > 1:\n negated = (lower and self.children[1].text) == \"NOT\" \n else:\n negated = False\n \n for item in lower:\n \n if negated:\n adjusted = []\n for event in item:\n if isinstance(event,tuple):\n adjusted.append((event[0],event[1],event[2] - 0xFFFF))\n else:\n adjusted.append(event)\n item = adjusted\n events += item\n \n if events:\n self.lower = events\n return events,negated\n \n NPcodes = []\n PPcodes = []\n VPcodes = []\n \n for child in self.children:\n if isinstance(child, NounPhrase):\n NPcodes += child.get_meaning()\n elif isinstance(child, PrepPhrase):\n PPcodes += (child.get_meaning())\n elif False and child.label in \"SBAR\":\n for ch in (child.children[-1].children if child.label == \"SBAR\" else child.children):\n if isinstance(ch, NounPhrase):\n Scodes += ch.get_meaning()\n elif isinstance(ch, PrepPhrase):\n Scodes += ch.get_meaning()\n elif isinstance(ch, VerbPhrase):\n Scodes += ch.get_meaning()[1]\n \n actorcodes,agentcodes = ([],[])\n NPactor, NPagent = self.resolve_codes(NPcodes)\n PPactor, PPagent = self.resolve_codes(PPcodes)\n VPactor, VPagent = self.resolve_codes(VPcodes)\n \n actorcodes += NPactor\n if not actorcodes:\n actorcodes += PPactor\n if not actorcodes:\n actorcodes += VPactor\n \n agentcodes += NPagent\n if not agentcodes:\n agentcodes += PPagent\n if not agentcodes:\n agentcodes += VPagent\n \n self.lower = self.mix_codes(agentcodes,actorcodes)\n return self.lower,negated", "metadata": "root.VerbPhrase.get_lower", "header": "['class', 'VerbPhrase', '(', 'Phrase', ')', ':', '___EOS___']", "index": 921 }, { "content": " def return_code(self):\n return self.code", "metadata": "root.VerbPhrase.return_code", "header": "['class', 'VerbPhrase', '(', 'Phrase', ')', ':', '___EOS___']", "index": 1013 }, { "content": " def get_code(self):\n \"\"\"\n Match the codes from the Verb Dictionary.\n \n Step 1. Check for compound verb matches\n \n Step 2. Check for pattern matches via match_pattern() method\n \n \n Parameters\n -----------\n self: VerbPhrase object that called the method\n \n Returns\n -------\n code: int\n Code described by this verb, best read in hex\n \"\"\"\n \n self.get_code = self.return_code\n meta = []\n dict = PETRglobals.VerbDict['verbs']\n if 'AND' in map(lambda a: a.text, self.children):\n return 0,0,['and']\n patterns = PETRglobals.VerbDict['phrases']\n verb = \"TO\" if self.children[0].label == \"TO\" else self.get_head()[0]\n meta.append(verb)\n meaning = \"\"\n path = dict\n passive = False\n if verb in dict:\n code = 0\n path = dict[verb]\n if ['#'] == path.keys():\n path = path['#']\n if True or path.keys() == ['#']: # Pre-compounds are weird\n try:\n code = path['#']['code']\n meaning = path['#']['meaning']\n \n self.verbclass = meaning if not meaning == \"\" else verb\n if not code == '':\n active, passive = utilities.convert_code(code)\n self.code = active\n except:\n self.code = (0,0,[])\n else:\n # Post - compounds\n for child in self.children:\n if child.label in [\"PRT\",\"ADVP\"]:\n if child.children[0].text in path:\n meta.append(child.children[0].text)\n path = path[child.children[0].text]\n if \"#\" in path:\n try:\n code = path['#']['#']['code']\n meaning = path['#']['#']['meaning']\n self.verbclass = meaning if not meaning == \"\" else verb\n if not code == '':\n active, passive = utilities.convert_code(code)\n self.code = active\n except:\n pass\n \n# -- print('++1')\n match = self.match_pattern()\n# -- print('++2')\n if match:\n# -- print('++4',match)\n# -- print('++3',match['line'])\n meta.append(match['line'])\n# -- print(match)\n active, passive = utilities.convert_code(match['code'])\n self.code = active\n if passive and not active:\n self.check_passive = lambda : True\n self.code = passive\n return self.code, passive,meta", "metadata": "root.VerbPhrase.get_code", "header": "['class', 'VerbPhrase', '(', 'Phrase', ')', ':', '___EOS___']", "index": 1016 }, { "content": " def match_transform(self,e):\n \"\"\"\n Check to see if the event e follows one of the verb transformation patterns\n specified at the bottom of the Verb Dictionary file.\n \n If the transformation is present, adjust the event accordingly. \n If no transformation is present, check if the event is of the form:\n \n a ( b . Q ) P , where Q is not a top-level verb. \n \n and then convert this to ( a b P+Q )\n \n Otherwise, return the event as-is.\n \n Parameters\n -----------\n e: tuple\n Event to be transformed\n \n Returns\n -------\n t: list of tuples\n List of modified events, since multiple events can come from one single event\n \"\"\"\n \n \n def recurse(pdict,event,a2v = {}, v2a = {}):\n path = pdict\n if isinstance(pdict,list):\n line = pdict[1]\n path = pdict[0]\n verb = utilities.convert_code(path[2])[0] if not path[2] == \"Q\" else v2a[\"Q\"]\n if isinstance(v2a[path[1]],tuple):\n results = []\n for item in v2a[path[1]]:\n results.append((list(v2a[path[0]]),item,verb))\n return results, line\n return [(list(v2a[path[0]]),v2a[path[1]],verb)], line\n \n if isinstance(event,tuple):\n actor = None if not event[0] else tuple(event[0])\n masks = filter(lambda a :a in pdict, [event[2],event[2] - event[2] % 0x10,\n event[2] - event[2] % 0x100,event[2] - event[2] % 0x1000])\n if masks:\n path = pdict[masks[0]]\n elif -1 in pdict:\n v2a[\"Q\"] = event[2]\n path = pdict[-1]\n else:\n return False\n else:\n actor = event\n if actor in a2v:\n actor = a2v[actor]\n if not actor:\n actor = \"_\"\n if actor in path:\n return recurse(path[actor],event[1],a2v,v2a)\n elif not actor == '_':\n for var in sorted(path.keys())[::-1]:\n if var in v2a:\n continue\n if not var == '.':\n v2a[var] = actor\n a2v[actor] = var\n return recurse(path[var],event[1],a2v,v2a)\n return False\n \n \n try :\n t = recurse(PETRglobals.VerbDict['transformations'],e)\n if t:\n return t\n else:\n \n if e[0] and e[2] and isinstance(e[1],tuple) and e[1][0] and not e[1][2] / (16 ** 3):\n if isinstance(e[1][0],list):\n results = []\n for item in e[1][0]:\n event =(e[0],item,utilities.combine_code(e[1][2],e[2]))\n results.append(event)\n return results\n event =(e[0],e[1][0],utilities.combine_code(e[2],e[1][2]))\n return [event]\n\n\n except Exception as ex:\n pass #print(ex)\n return [e]", "metadata": "root.VerbPhrase.match_transform", "header": "['class', 'VerbPhrase', '(', 'Phrase', ')', ':', '___EOS___']", "index": 1097 }, { "content": " def match_pattern(self):\n \"\"\" \n Match the tree against patterns specified in the dictionary. For a more illustrated explanation\n of how this process works, see the Petrarch2.pdf file in the documentation. \n \n \n Parameters\n -----------\n self: VerbPhrase object that called the method\n \n Returns\n -------\n False if no match, dict of match if present.\n \n \"\"\"\n meaning = self.verbclass\n code = self.code\n\n def match_phrase(path,phrase):\n # Having matched the head of the phrase, this matches the full noun phrase, if specified\n# -- print('mph-entry')\n if not phrase:\n# -- print('mph-False')\n return False\n for item in filter(lambda b: b.text in path,phrase.children):\n subpath = path[item.text]\n# -- print('mph-rr-1')\n match = reroute(subpath,lambda a: match_phrase(a,item.head_phrase))\n if match:\n item.color = True\n return match\n# -- print('mph-reroute') \n return reroute(path,lambda a: match_phrase(a,phrase.head_phrase))\n \n def match_noun(path,phrase = self if not self.check_passive() else self.get_S(),preplimit = 0):\n # Matches a noun or head of noun phrase\n# -- print('mn-entry')\n noun_phrases = []\n if not phrase:\n return False\n if preplimit:\n for sib in phrase.children:\n if isinstance(sib,PrepPhrase) and len(sib.children) > 1 and sib.get_prep() in [\"BY\",\"FROM\"] :\n noun_phrases.append(sib.children[1])\n else:\n for child in phrase.children:\n if child.label in (\"NP\",\"ADVP\"):\n noun_phrases.append(child)\n if isinstance(phrase,NounPhrase):\n noun_phrases.append(phrase)\n \n for item in noun_phrases:\n head,headphrase = item.get_head()\n \n if head and head in path:\n subpath = path[head]\n \n # First check within the NP for PP's\n skip = lambda a: False\n match = reroute(subpath, skip , skip , lambda a: match_prep(a,item), skip ,0)\n if match:\n headphrase.children[-1].color = True\n return match\n\n # Then check the other siblings\n match = reroute(subpath,(lambda a : match_phrase(a,item.head_phrase))\n if isinstance(item,NounPhrase) else None ) # pas 16.04.21: Trapped None by having reroute return False\n if match:\n headphrase.children[-1].color = True\n return match\n if '^' in path:\n phrase.color = True\n# -- print('mn-reroute1')\n return reroute(path['^'], lambda a: match_phrase(a,phrase.head_phrase))\n# -- print('mn-reroute2')\n return reroute(path,lambda a: match_phrase(a,phrase.head_phrase))\n\n def match_prep(path,phrase=self):\n # Matches preposition\n# -- print('mp-entry')\n for item in filter(lambda b: isinstance(b,PrepPhrase),phrase.children):\n prep = item.children[0].text\n if prep in path:\n subpath = path[prep]\n# -- print('mp-reroute1') \n match = reroute(subpath,\n lambda a : match_noun(a,item.children[1])if len(item.children) > 1 else False,\n match_prep)\n if match:\n# -- print('mp-False')\n return match\n# -- print('mp-reroute2') \n return reroute(path, o2 = match_prep)\n\n def reroute(subpath, o1 = match_noun, o2 = match_noun, o3 = match_prep, o4 = match_noun, exit = 1):\n# -- print('rr-entry:') # ,subpath\n if not o1: # match_noun() can call reroute() with o1 == None; guessing returning False is the appropriate response pas 16.04.21\n return False\n if '-' in subpath:\n match = o1(subpath['-'])\n if match:\n# -- print('rr-- match')\n return match\n \n if ',' in subpath:\n# -- print('rr-,')\n match = o2(subpath[','])\n if match:\n return match\n \n if '|' in subpath:\n# -- print('rr-|')\n match = o3(subpath['|'])\n if match:\n return match\n \n if '*' in subpath:\n# -- print('rr-*')\n match = o4(subpath['*'])\n if match:\n return match\n \n if '#' in subpath and exit:\n# -- print('rr-#')\n return subpath['#']\n \n# -- print('rr-False')\n return False\n \n # Match pattern\n if meaning in PETRglobals.VerbDict['phrases']:\n path = PETRglobals.VerbDict['phrases'][meaning]\n if self.check_passive():\n return match_noun(path,self,1)\n else:\n return match_noun(path,self.get_S())\n return False", "metadata": "root.VerbPhrase.match_pattern", "header": "['class', 'VerbPhrase', '(', 'Phrase', ')', ':', '___EOS___']", "index": 1188 }, { "content": "class Sentence:\n \"\"\"\n Holds the information of a sentence and its tree.\n \n Methods\n -------\n \n __init__ : Initialization and instantiation\n \n str_to_tree: Reads CoreNLP parse into memory\n \n get_events: Extracts events from sentence tree\n \n print_tree: Prints tree to a LaTeX file\n \n \n \n \n Metadata\n --------\n \n The sentence will return with a \"metadata\" dict. This has two parts.\n \n - sent.metadata['nouns'] will be a list of pairs of the form\n \n ( [Words that were coded], [Codes produced])\n \n Each list in the tuple usually only has one element, but sometimes multiple can occur\n \n - The other elements of sent.metadata have the key as the event, and\n the value as a list of lists. Each element of the value list contains\n some information about verbs that combined to form that event. The first\n element usually contains the primary verb and pattern that was matched on, and the latter\n elements are helping verbs that were combined with it.\n \n \n For example, the metadata for the sentence \n \n BOKO HARAM HAS LAUNCHED MANY SIMILAR ATTACKS DURING ITS SIX-YEAR CAMPAIGN FOR A STRICT ISLAMIC STATE IN NORTHEASTERN NIGERIA .\n \n \n Looks like:\n \n {\n (u'NGAREB', u'NGAMUS', u'190'): [[u'LAUNCHED', '- * ATTACKS [190]'],\n [u'HAS']],\n \n u'nouns': [([u'BOKO HARAM'], [u'NGAREB']),\n ([u'NIGERIA'], [u'NGA']),\n ([u'ISLAMIC'], [u'NGAMUS'])]}\n }\n \n \n \"\"\"\n \n \n\n\n\n\n \n \n \n\n\n\n '''def print_to_file(self,root,file = \"\"):\n\n \"\"\"Prints a LaTeX representation of the tree to a file, calls the recursive method\n print_tree() on the tree to print all of it\n \"\"\"\n print(\"\"\" \n \\\\resizebox{\\\\textwidth}{250pt}{%\n \\\\begin{tikzpicture}\n \\\\Tree\"\"\", file=file, end=\" \")\n\n self.print_tree(root, \"\", file)\n print(\"\\\\end{tikzpicture}}\\n\\n\", file=file)\n print(\"EVENTS: \",self.get_events(), file = file)\n print(\"\\\\\\\\\\nTEXT: \", self.txt, file=file)\n print(\"\\\\newpage\",file=file)'''\n \n ", "metadata": "root.Sentence", "header": "['module', '___EOS___']", "index": 1328 }, { "content": " def __init__(self, parse, text, date):\n self.treestr = parse.replace(')', ' )')\n self.parse = parse\n self.agent = \"\"\n self.ID = -1\n self.actor = \"\"\n self.date = date\n self.longlat = (-1,-1)\n self.verbs = []\n self.txt = \"\"\n self.tree = self.str_to_tree(parse.strip())\n self.verb_analysis = {}\n self.events = []\n self.metadata = {'nouns': [] }", "metadata": "root.Sentence.__init__", "header": "['class', 'Sentence', ':', '___EOS___']", "index": 1382 }, { "content": " def str_to_tree(self,str):\n \"\"\"\n Take the Stanford CoreNLP parse and convert it to an object/pointer tree.\n \n Parameters\n -----------\n str: string \n Pre-processed CoreNLP parse, needs to be formated by utilities.format_parsed_str\n before being passed.\n \n Returns\n -------\n root: Phrase object\n Top level of the tree that represents the sentence\n \"\"\"\n segs = str.split()\n root = Phrase(segs[0][1:],self.date, self )\n level_stack = [root]\n existentials = []\n \n for element in segs[1:]:\n if element.startswith(\"(\"):\n lab = element[1:]\n if lab == \"NP\":\n new = NounPhrase(lab, self.date, self)\n elif lab == \"VP\":\n new = VerbPhrase(lab,self.date, self)\n self.verbs.append(new)\n elif lab == \"PP\":\n new = PrepPhrase(lab, self.date, self)\n else:\n new = Phrase(lab, self.date, self)\n if lab == \"EX\":\n existentials.append(new)\n \n new.parent = level_stack[-1]\n new.index = len(level_stack[-1].children)\n level_stack[-1].children.append(new)\n level_stack.append(new)\n elif element.endswith(\")\"):\n try:\n level_stack.pop()\n except:\n break\n else:\n level_stack[-1].text = element\n self.txt += \" \" +element\n \n for element in existentials:\n try:\n element.parent.convert_existential()\n except:\n pass\n return root", "metadata": "root.Sentence.str_to_tree", "header": "['class', 'Sentence', ':', '___EOS___']", "index": 1398 }, { "content": " def print_nouns(self,label): # -- \n \"\"\" Debugging print \"\"\"\n print(label)\n for la in self.metadata['nouns']:\n print(' ',la)", "metadata": "root.Sentence.print_nouns", "header": "['class', 'Sentence', ':', '___EOS___']", "index": 1454 }, { "content": " def get_metadata(self, entry):\n \n metadict = self.metadata\n next = entry\n store = \"\"\n meta_total = []\n while id(next) in metadict:\n store = metadict[id(next)]\n meta_total.append(store)\n next = store[0]\n #if not meta_total:\n # print(entry,self.txt)\n # exit()\n return map(lambda a: a[-2] if len(a) > 1 else a[0], meta_total[::-1])", "metadata": "root.Sentence.get_metadata", "header": "['class', 'Sentence', ':', '___EOS___']", "index": 1461 }, { "content": " def return_events(self):\n return self.events", "metadata": "root.Sentence.return_events", "header": "['class', 'Sentence', ':', '___EOS___']", "index": 1477 }, { "content": " def get_events(self,require_dyad = 1):\n \"\"\"\n Take the coding of the highest verb phrase and return that, given:\n 1) Target and source are both present\n 2) Code is non-zero\n 3) Target isn't another event\n \n Parameters\n -----------\n self: Sentence object calling the method\n \n Returns\n -------\n valid: list\n List of coded events that satisfy the above conditions, of form\n (source, target, code) where the code has been converted from an int\n back into CAMEO\n \n \"\"\"\n \n events = map(lambda a : a.get_meaning(), filter(lambda b: b.label in \"SVP\" , self.tree.children))\n meta = {'nouns' : self.metadata['nouns'] }\n \"\"\"print('GF1',events) # -- \n# -- print('GF2',meta) # -- \n self.print_nouns('GF2') # -- \"\"\" \n valid = []\n try:\n for sent in events:\n for event in sent:\n if event[1] == 'passive':\n event = (event[0],None,event[2])\n if isinstance(event,tuple) and isinstance(event[1],basestring) :\n \n code = utilities.convert_code(event[2],0)\n print('checking event', event, hex(event[2]))\n if event[0] and event[1] and code :\n for source in event[0]:\n valid.append((source.replace('~','---'),event[1].replace('~','---'),code))\n meta[(source.replace('~','---'),event[1].replace('~','---'),code)] = self.get_metadata(event)\n \n elif (not require_dyad) and event[0] and code and not event[1]:\n for source in event[0]:\n valid.append((source.replace('~','---'),\"---\",code))\n \n elif (not require_dyad) and event[1] and code and not event[0]:\n valid.append((\"---\",event[1].replace('~','---'),code))\n \n \n # If there are multiple actors in a cooperation scenario, code their cooperation as well\n if len(event[0]) > 1 and (not event[1]) and code and code[:2] in [\"03\",\"04\",\"05\",\"06\"]:\n for source in event[0]:\n for target in event[0]:\n if not source == target:\n valid.append((source.replace('~','---'),target.replace('~','---'),code))\n \n self.events = list(set(valid))\n self.get_events = self.return_events\n# -- print('GF3',valid,'\\nGF4',meta) # -- \n return valid , meta\n except Exception as e:\n print(\"Error in parsing:\",e)\n return None, None", "metadata": "root.Sentence.get_events", "header": "['class', 'Sentence', ':', '___EOS___']", "index": 1481 }, { "content": " def print_to_file(self,root,file = \"\"):\n \"\"\"\n Simplified version of the above for GF\n \"\"\"\n print(\"EVENTS: \",self.get_events(), file = file)\n txtstrg = self.txt.encode('ascii', 'ignore').decode('ascii') # <16.03.29> For now, just zap the unicode\n print(\"TEXT: \", txtstrg, file=file)", "metadata": "root.Sentence.print_to_file", "header": "['class', 'Sentence', ':', '___EOS___']", "index": 1561 }, { "content": " def print_tree(self, root, indent=\"\", f=\"\"):\n \"\"\"\n This prints a LaTeX formatted document of the tree. Calls on each of the children as well.\n \"\"\"\n print(\"[.\"+root.label.replace(\"$\",\"\"),(\"{\\\\bf \"+root.text+\"}\" if not root.text == \"\" else \"\") ,file = f,end = \" \")\n if root.label in [\"NP\"]:\n m = root.get_meaning()\n k = \"\"\n for i in m:\n k += \"+\" + i\n print(\"[.{\" + k + \"}\", file=f, end=\" \")\n elif root.label in [\"VP\"]:\n m = root.get_meaning()\n print(\"[.{\\it \"+utilities.code_to_string(m)+\"}\",file = f,end = \" \")\n \n for child in root.children:\n self.print_tree(child,indent+\"\\t\",f)\n if root.label in [\"NP\",\"VP\"]:\n print(\" ] ]\",file = f,end=\" \\n\")\n else:\n print(\" ]\", file=f, end=\" \")", "metadata": "root.Sentence.print_tree", "header": "['class', 'Sentence', ':', '___EOS___']", "index": 1569 } ]
[ { "span": "import types", "start_line": 10, "start_column": 0, "end_line": 10, "end_column": 12 } ]
[]
1
false
[ "[CLS]_", "Un", "used_", "import_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "from_", "\\u\\u", "future\\u\\u_", "import_", "print", "\\u", "function_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "\\u\\u", "future\\u\\u_", "import_", "unicode", "\\u", "literals_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "import_", "PE", "TR", "globals_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "PE", "TR", "reader_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "time_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "utilities_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "types_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "--", " ", "from", " ", "inspect", " ", "import", " ", "geto", "uter", "frames", ",", " ", "current", "frame", " ", " ", "#", " ", "--", " ", "#", " ", "used", " ", "to", " ", "track", " ", "the", " ", "level", "s", " ", "of", " ", "recursion", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", " ", " ", "PE", "TR", "tree", ".", "py_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", " ", " ", "Author", ":", " ", "Cla", "yto", "n", " ", "Nor", "ris_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", " ", " ", "Ca", "eru", "s", " ", "Associate", "s", "/", " ", "Univers", "it", "y", " ", "of", " ", "Chi", "cag", "o_", "\\u\\u\\uNL\\u\\u\\u_", "#", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", " ", " ", "Pur", "pose", ":_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", " ", " ", "Call", "ed", " ", "from", " ", "pet", "rar", "ch", ".", "py", ",", " ", "this", " ", "contain", "s", " ", "the", " ", "main", " ", "logic_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", " ", " ", "of", " ", "the", " ", "Pet", "rar", "ch", " ", "software", ".", " ", "Sentence", "s", " ", "are", " ", "store", "d", " ", "into_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", " ", " ", "Sentence", " ", "class", " ", "object", "s", ",", " ", "whi", "ch", " ", "contain", " ", "a", " ", "tree", " ", "of", " ", "Phrase", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", " ", " ", "class", " ", "object", "s", ".", " ", "The", " ", "phrase", "s", " ", "then", " ", "do", " ", "analyses", " ", "of", " ", "thei", "r", " ", "role_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", " ", " ", "in", " ", "the", " ", "sentence", " ", "and", " ", "the", " ", "event", " ", "informati", "on", " ", "of", " ", "the", " ", "over", "all", " ", "sentence_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", " ", " ", "is", " ", "calculated", " ", "and", " ", "return", "ed", " ", "within", " ", "the", " ", "get", "\\u", "events", "()", " ", "method_", "\\u\\u\\uNL\\u\\u\\u_", "#", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", " ", " ", "Revi", "sion", " ", "histo", "ry", ":_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", " ", " ", "Ju", "ly", " ", "201", "5", " ", "-", " ", "Created_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", " ", " ", "August", " ", "201", "5", " ", "-", " ", "Fi", "rst", " ", "release_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", " ", " ", "Apri", "l", " ", "2016", " ", "-", " ", "Bug", "s", " ", "caus", "ing", " ", "crashes", " ", "in", " ", "very", " ", "low", " ", "freque", "nc", "y", " ", "case", "s", " ", "corrected", " _", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "pas", " ", "16.", "04", ".2", "2", ":", " ", "print", "()", " ", "statem", "ents", " ", "commente", "d", "-", "out", " ", "with", " ", "'#", " ", "--", "'", " ", "wer", "e", " ", "used", " ", "in", " ", "the", " ", "debugg", "ing", " ", "and", " ", "can", " ", "probab", "ly", " ", "be", " ", "removed_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "class_", "Phrase", "_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Thi", "s", " ", "is", " ", "a", " ", "genera", "l", " ", "class", " ", "for", " ", "all", " ", "Phrase", " ", "instance", "s", ",", " ", "whi", "ch", " ", "make", " ", "up", " ", "the", " ", "nodes", " ", "in", " ", "the", " ", "synta", "ctic", " ", "tree", ".", "\\", "10", ";", " ", " ", " ", " ", "The", " ", "three", " ", "subtypes", " ", "are", " ", "belo", "w", ".", "\\", "10", ";", " ", " ", " ", " ", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "[SEP]_", "class_", "Phrase", "_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "\\u\\u", "init\\u\\u_", "(_", "self_", ",_", "label_", ",_", "date_", ",_", "sentence_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Initializ", "ation", " ", "for", " ", "Phrase", " ", "classe", "s", ".", " ", "\\", "10", ";", " ", " ", " ", " ", "\\", "10", ";", " ", " ", " ", " ", "\\", "10", ";", " ", " ", " ", " ", "Parameter", "s", "\\", "10", ";", " ", " ", " ", " ", "-----------", "\\", "10", ";", " ", " ", " ", " ", "\\", "10", ";", " ", " ", " ", " ", "label", ":", " ", "list", "\\", "10", ";", " ", " ", " ", " ", "Label", " ", "for", " ", "the", " ", "phrase", " ", "type", ",", " ", "date", "\\", "10", ";", " ", " ", " ", " ", "\\", "10", ";", " ", " ", " ", " ", "Return", "s", "\\", "10", ";", " ", " ", " ", " ", "-------", "\\", "10", ";", " ", " ", " ", " ", "An", " ", "instantiate", "d", " ", "Phrase", " ", "object", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "label_", "=_", "label_", "if_", "not_", "label_", "==_", "\"", "MD", "\"_", "else_", "\"", "VB", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "children_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "phrase", "type_", "=_", "label_", "[_", "0_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "annotation_", "=_", "\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "text_", "=_", "\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "parent_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "meaning", "_", "=_", "\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "verb", "class_", "=_", "\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "date_", "=_", "date_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "index_", "=_", "-_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "head_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "head", "\\u", "phrase_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "color_", "=_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "sentence_", "=_", "sentence_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Phrase", "_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "get", "\\u", "meaning", "_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Meth", "od", " ", "for", " ", "return", "ing", " ", "the", " ", "meaning", " ", "of", " ", "the", " ", "subtree", " ", "root", "ed", " ", "by", " ", "this", " ", "phrase", ",", "\\", "10", ";", " ", " ", " ", " ", "is", " ", "overwrit", "ten", " ", "by", " ", "all", " ", "subclasses", ",", " ", "so", " ", "this", " ", "works", " ", "prima", "ri", "ly", " ", "for", "\\", "10", ";", " ", " ", " ", " ", "S", " ", "and", " ", "S", "-", "Bar", " ", "phrase", "s", ".", "\\", "10", ";", " ", " ", " ", " ", "\\", "10", ";", " ", " ", " ", " ", "\\", "10", ";", " ", " ", " ", " ", "\\", "10", ";", " ", " ", " ", " ", "Parameter", "s", "\\", "10", ";", " ", " ", " ", " ", "-----------", "\\", "10", ";", " ", " ", " ", " ", "self", ":", " ", "Phrase", " ", "object", " ", "tha", "t", " ", "call", "ed", " ", "the", " ", "method", "\\", "10", ";", " ", " ", " ", " ", "\\", "10", ";", " ", " ", " ", " ", "\\", "10", ";", " ", " ", " ", " ", "Return", "s", "\\", "10", ";", " ", " ", " ", " ", "-------", "\\", "10", ";", " ", " ", " ", " ", "\\", "10", ";", " ", " ", " ", " ", "events", ":", " ", "list", "\\", "10", ";", " ", " ", " ", " ", "Combine", "d", " ", "meaning", "s", " ", "of", " ", "the", " ", "phrase", "s", " ", "child", "ren", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "self_", "._", "label_", "in_", "\"", "SB", "AR", "\"_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "lower_", "=_", "map_", "(_", "lambda_", "b_", ":_", "b_", "._", "get", "\\u", "meaning", "_", "(_", ")_", ",_", "filter_", "(_", "lambda_", "a_", ":_", "a_", "._", "label_", "in_", "\"", "SB", "AR", "VP", "\"_", ",_", "self_", "._", "children_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "events_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "item_", "in_", "lower_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "events_", "+=_", "item_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "events_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "meaning", "_", "=_", "events_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "events_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "self_", "._", "meaning", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Phrase", "_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "get", "\\u", "text_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "self_", "._", "color_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "text_", "=_", "self_", "._", "text_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "child_", "in_", "self_", "._", "children_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "isinstance_", "(_", "child_", ",_", "Nou", "n", "Phrase", "_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "text_", "+=_", "\"", " ", "\"_", "+_", "child_", "._", "get", "\\u", "text_", "(_", ")_", "[_", "0_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "text_", "+=_", "\"", " ", "\"_", "+_", "child_", "._", "get", "\\u", "text_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "text_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Phrase", "_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "resolve", "\\u", "codes_", "(_", "self_", ",_", "codes_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Meth", "od", " ", "tha", "t", " ", "divide", "s", " ", "a", " ", "list", " ", "of", " ", "mixed", " ", "codes", " ", "int", "o", " ", "actor", " ", "and", " ", "agent", " ", "codes", "\\", "10", ";", " ", " ", " ", " ", "\\", "10", ";", " ", " ", " ", " ", "Parameter", "s", "\\", "10", ";", " ", " ", " ", " ", "-----------", "\\", "10", ";", " ", " ", " ", " ", "codes", ":", " ", "list", "\\", "10", ";", " ", " ", " ", "Mix", "ed", " ", "list", " ", "of", " ", "codes", "\\", "10", ";", " ", " ", " ", " ", "\\", "10", ";", " ", " ", " ", " ", "Return", "s", "\\", "10", ";", " ", " ", " ", " ", "-------", "\\", "10", ";", " ", " ", " ", " ", "actor", "codes", ":", " ", "list", "\\", "10", ";", " ", " ", "List", " ", "of", " ", "actor", " ", "codes", "\\", "10", ";", " ", " ", "\\", "10", ";", " ", " ", " ", " ", "agent", "codes", ":", " ", "list", "\\", "10", ";", " ", " ", "List", " ", "of", " ", "actor", " ", "codes", "\\", "10", ";", " ", " ", " ", " ", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "--", " ", " ", " ", " ", "print", "('", "Pr", "c", "-", "entry", "',", "len", "(", "geto", "uter", "frames", "(", "current", "frame", "(", "1", ")))", ",", "codes", ")", " ", "#", " ", "--", "_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "not_", "codes_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "[_", "]_", ",_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "actor", "codes_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "agent", "codes_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "code_", "in_", "codes_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "not_", "code_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "continue_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\"\"\"", "if", " ", "isin", "stance", "(", "code", ",", "tuple", "):", "\\", "10", ";", " ", " ", " ", " ", "actor", "codes", ".", "append", "(", "code", ")", "\\", "10", ";", " ", " ", " ", " ", "else", ":", "\\", "10", ";", " ", " ", " ", " ", "agent", "codes", ".", "append", "(", "code", ")\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "code_", "._", "startswith_", "(_", "\"~\"_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "agent", "codes_", "._", "append_", "(_", "code_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "actor", "codes_", "._", "append_", "(_", "code_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "actor", "codes_", ",_", "agent", "codes_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Phrase", "_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "mix", "\\u", "codes_", "(_", "self_", ",_", "agents_", ",_", "actors_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Combine", " ", "the", " ", "actor", " ", "codes", " ", "and", " ", "agent", " ", "codes", " ", "address", "ing", " ", "duplicat", "es", "\\", "10", ";", " ", " ", " ", " ", "and", " ", "remo", "ving", " ", "the", " ", "genera", "l", " ", "\"", "~", "PP", "L", "\"", " ", "if", " ", "there", "'", "s", " ", "a", " ", "bett", "er", " ", "option", ".", "\\", "10", ";", " ", " ", " ", " ", "\\", "10", ";", " ", " ", " ", " ", "Parameter", "s", "\\", "10", ";", " ", " ", " ", " ", "-----------", "\\", "10", ";", " ", " ", " ", " ", "agent", "s", ",", " ", "actors", " ", ":", " ", "List", "s", " ", "of", " ", "thei", "r", " ", "respec", "tiv", "e", " ", "codes", "\\", "10", ";", " ", " ", " ", " ", "\\", "10", ";", " ", " ", " ", " ", "\\", "10", ";", " ", " ", " ", " ", "Return", "s", "\\", "10", ";", " ", " ", " ", " ", "-------", "\\", "10", ";", " ", " ", " ", " ", "codes", ":", " ", "list", "\\", "10", ";", " ", " ", " ", "[", "Agent", " ", "codes", "]", " ", "x", " ", "[", "Act", "or", " ", "codes", "]", "\\", "10", ";", " ", " ", " ", " ", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "--", " ", " ", " ", " ", "print", "('", "mc", "-", "entry", "',", "actors", ",", "agent", "s", ")_", "\\u\\u\\uNL\\u\\u\\u_", "codes_", "=_", "set_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "mix_", "=_", "lambda_", "a_", ",_", "b_", ":_", "a_", "+_", "b_", "if_", "not_", "b_", "in_", "a_", "else_", "a_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "actors_", "=_", "actors_", "if_", "actors_", "else_", "[_", "'~'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "ag_", "in_", "agents_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "ag_", "==_", "'", "~", "PP", "L", "'_", "and_", "len_", "(_", "agents_", ")_", ">_", "1_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "continue_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", " ", " ", " ", "actors", " ", "=", " ", "map", "(", " ", "lambda", " ", "a", " ", ":", " ", "mix", "(", " ", "a", "[", "0", "],", " ", "ag", "[", "1", ":]", "),", " ", "actors", ")_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "actors_", "=_", "map_", "(_", "lambda_", "a_", ":_", "mix_", "(_", "a_", ",_", "ag_", "[_", "1_", ":_", "]_", ")_", ",_", "actors_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "--", " ", " ", " ", " ", "print", "('", "mc", "-1", "',", "actors", ")_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "filter_", "(_", "lambda_", "a_", ":_", "a_", "not_", "in_", "[_", "''_", ",_", "'~'_", ",_", "'", "~~", "'_", ",_", "None_", "]_", ",_", "actors_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "16.", "04", ".2", "5", " ", "hmm", "m", ",", " ", "this", " ", "is", " ", "eit", "her", " ", "a", " ", "construct", " ", "of", " ", "utt", "erl", "y", " ", "pheno", "men", "al", " ", "subt", "let", "y", " ", "or", " ", "else", " ", "we", " ", "neve", "r", " ", "hit", " ", "this", " ", "code", "..._", "\\u\\u\\uNL\\u\\u\\u_", "codes_", "=_", "set_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "print_", "(_", "'", "WT", "F", "-1", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "act_", "in_", "(_", "actors_", "if_", "actors_", "else_", "[_", "'~'_", "]_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "for_", "ag_", "in_", "(_", "agents_", "if_", "agents_", "else_", "[_", "'~'_", "]_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "ag_", "==_", "\"", "~", "PP", "L", "\"_", "and_", "len_", "(_", "agents_", ")_", ">_", "1_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "continue_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "code_", "=_", "act_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "not_", "ag_", "[_", "1_", ":_", "]_", "in_", "act_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "code_", "+=_", "ag_", "[_", "1_", ":_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "not_", "code_", "in_", "[_", "'~'_", ",_", "'", "~~", "'_", ",_", "\"\"_", "]_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "codes_", "._", "add_", "(_", "code_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "list_", "(_", "codes_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Phrase", "_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "return", "\\u", "head_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "self_", "._", "head_", ",_", "self_", "._", "head", "\\u", "phrase_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Phrase", "_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "get", "\\u", "head_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Meth", "od", " ", "for", " ", "finding", " ", "the", " ", "head", " ", "of", " ", "a", " ", "phrase", ".", " ", "The", " ", "head", " ", "of", " ", "a", " ", "phrase", " ", "is", " ", "the", " ", "right", "most", "\\", "10", ";", " ", " ", " ", " ", "word", "-", "level", " ", "constitu", "ent", " ", "suc", "h", " ", "tha", "t", " ", "the", " ", "path", " ", "from", " ", "root", " ", "to", " ", "head", " ", "consi", "sts", " ", "only", " ", "of", " ", "similar", "ly", "-", "label", "ed", "\\", "10", ";", " ", " ", " ", " ", "phrase", "s", ".", "\\", "10", ";", " ", " ", " ", " ", "\\", "10", ";", " ", " ", " ", " ", "Parameter", "s", "\\", "10", ";", " ", " ", " ", " ", "-----------", "\\", "10", ";", " ", " ", " ", " ", "self", ":", " ", "Phrase", " ", "object", " ", "tha", "t", " ", "call", "ed", " ", "the", " ", "method", "\\", "10", ";", " ", " ", " ", " ", "\\", "10", ";", " ", " ", " ", " ", "Return", "s", "\\", "10", ";", " ", " ", " ", " ", "-------", "\\", "10", ";", " ", " ", " ", " ", "possibilit", "ies", "[-", "1", "]:", " ", "tuple", " ", "(", "string", ",", "Nou", "n", "Phrase", ")", "\\", "10", ";", " ", " ", " ", " ", "(", "The", " ", "text", " ", "of", " ", "the", " ", "head", " ", "of", " ", "the", " ", "phrase", ",", " ", "the", " ", "Nou", "n", "Phrase", " ", "object", " ", "who", "se", " ", "right", "most", " ", "child", " ", "is", " ", "the", "\\", "10", ";", " ", " ", " ", " ", "head", ").", "\\", "10", ";", " ", " ", " ", " ", "\\", "10", ";", " ", " ", " ", " ", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "get", "\\u", "head_", "=_", "self_", "._", "return", "\\u", "head_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "self_", "._", "label_", "==_", "'", "S", "'_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "head_", ",_", "self_", "._", "head", "\\u", "phrase_", "=_", "map_", "(_", "lambda_", "b_", ":_", "b_", "._", "get", "\\u", "head_", "(_", ")_", ",_", "filter_", "(_", "lambda_", "a_", ":_", "a_", "._", "label_", "==_", "'", "VP", "'_", ",_", "self_", "._", "children_", ")_", ")_", "[_", "0_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "(_", "self_", "._", "head_", ",_", "self_", "._", "head", "\\u", "phrase_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "self_", "._", "label_", "==_", "'", "ADV", "P", "'_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "self_", "._", "children_", "[_", "0_", "]_", "._", "text_", ",_", "self_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "(_", "not_", "self_", "._", "label_", "[_", "1_", "]_", "==_", "'", "P", "'_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "(_", "self_", "._", "text_", ",_", "self_", "._", "parent_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "head", "\\u", "children_", "=_", "filter_", "(_", "lambda_", "child_", ":_", "child_", "._", "label_", "._", "startswith_", "(_", "self_", "._", "label_", "[_", "0_", "]_", ")_", "and_", "not_", "child_", "._", "label_", "[_", "1_", "]_", "==_", "'", "P", "'_", ",_", "self_", "._", "children_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "head", "\\u", "children_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "possibilit", "ies_", "=_", "filter_", "(_", "None_", ",_", "map_", "(_", "lambda_", "a_", ":_", "a_", "._", "get", "\\u", "head_", "(_", ")_", ",_", "head", "\\u", "children_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "other", "\\u", "children_", "=_", "filter_", "(_", "lambda_", "child_", ":_", "child_", "._", "label_", "._", "startswith_", "(_", "self_", "._", "label_", "[_", "0_", "]_", ")_", ",_", "self_", "._", "children_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "possibilit", "ies_", "=_", "filter_", "(_", "None_", ",_", "map_", "(_", "lambda_", "a_", ":_", "a_", "._", "get", "\\u", "head_", "(_", ")_", ",_", "other", "\\u", "children_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "head", "\\u", "phrase_", "=_", "possibilit", "ies_", "[_", "-_", "1_", "]_", "[_", "1_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "head_", "=_", "possibilit", "ies_", "[_", "-_", "1_", "]_", "[_", "0_", "]_", "#", " ", "return", " ", "the", " ", "last", ",", " ", "Eng", "lish", " ", "usual", "ly", " ", "compounds", " ", "words", " ", "to", " ", "the", " ", "front_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "possibilit", "ies_", "[_", "-_", "1_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "(_", "None_", ",_", "None_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Phrase", "_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "print", "\\u", "to", "\\u", "stdout_", "(_", "self_", ",_", "indent_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "print_", "(_", "indent_", ",_", "self_", "._", "label_", ",_", "self_", "._", "text_", ",_", "self_", "._", "get", "\\u", "meaning", "_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "child_", "in_", "self_", "._", "children_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "child_", "._", "print", "\\u", "to", "\\u", "stdout_", "(_", "indent_", "+_", "\"\\\\", "t", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "class_", "Nou", "n", "Phrase", "_", "(_", "Phrase", "_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Class", " ", "specific", " ", "to", " ", "noun", " ", "phrase", "s", ".", " ", "\\", "10", ";", " ", " ", " ", " ", "\\", "10", ";", " ", " ", " ", " ", "Meth", "ods", ":", " ", "get", "\\u", "meaning", "()", " ", " ", "-", " ", " ", " ", "specific", " ", "version", " ", "of", " ", "the", " ", "super", "'", "s", " ", "method", "\\", "10", ";", " ", " ", " ", " ", " ", "check", "\\u", "date", "()", " ", " ", " ", "-", " ", " ", " ", "find", " ", "the", " ", "date", "-", "specific", " ", "version", " ", "of", " ", "an", " ", "actor", "\\", "10", ";", " ", " ", " ", " ", " ", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "[SEP]_", "class_", "Nou", "n", "Phrase", "_", "(_", "Phrase", "_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "\\u\\u", "init\\u\\u_", "(_", "self_", ",_", "label_", ",_", "date_", ",_", "sentence_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "Phrase", "_", "._", "\\u\\u", "init\\u\\u_", "(_", "self_", ",_", "label_", ",_", "date_", ",_", "sentence_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Nou", "n", "Phrase", "_", "(_", "Phrase", "_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "return", "\\u", "meaning", "_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "self_", "._", "meaning", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Nou", "n", "Phrase", "_", "(_", "Phrase", "_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "get", "\\u", "text_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Nou", "n", "-", "specific", " ", "get", " ", "text", " ", "method", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "PP", "codes_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "text_", "=_", "\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "child_", "in_", "self_", "._", "children_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "isinstance_", "(_", "child_", ",_", "Prep", "Phrase", "_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "m_", "=_", "self_", "._", "resolve", "\\u", "codes_", "(_", "child_", "._", "get", "\\u", "meaning", "_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "m_", "[_", "0_", "]_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "PP", "codes_", "+=_", "child_", "._", "get", "\\u", "meaning", "_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "text_", "+=_", "\"", " ", "\"_", "+_", "child_", "._", "get", "\\u", "text_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "isinstance_", "(_", "child_", ",_", "Nou", "n", "Phrase", "_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "value_", "=_", "child_", "._", "get", "\\u", "text_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "text_", "+=_", "value_", "[_", "0_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "PP", "codes_", "+=_", "value_", "[_", "1_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "child_", "._", "label_", "[_", ":_", "2_", "]_", "in_", "[_", "\"", "JJ", "\"_", ",_", "\"", "NN", "\"_", ",_", "\"", "DT", "\"_", "]_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "text_", "+=_", "\"", " ", "\"_", "+_", "child_", "._", "text_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "text_", ",_", "PP", "codes_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Nou", "n", "Phrase", "_", "(_", "Phrase", "_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "check", "\\u", "date_", "(_", "self_", ",_", "match_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Meth", "od", " ", "for", " ", "resolv", "ing", " ", "date", " ", "restriction", "s", " ", "on", " ", "actor", " ", "codes", ".", " ", "\\", "10", ";", " ", " ", " ", " ", "\\", "10", ";", " ", " ", " ", " ", "Parameter", "s", "\\", "10", ";", " ", " ", " ", " ", "-----------", "\\", "10", ";", " ", " ", " ", " ", "match", ":", " ", "list", "\\", "10", ";", " ", " ", " ", "Dates", " ", "and", " ", "codes", " ", "from", " ", "the", " ", "dictionar", "y", "\\", "10", ";", " ", " ", " ", " ", "\\", "10", ";", " ", " ", " ", " ", "Return", "s", "\\", "10", ";", " ", " ", " ", " ", "-------", "\\", "10", ";", " ", " ", " ", " ", "code", ":", " ", "string", "\\", "10", ";", " ", " ", " ", " ", " ", " ", "The", " ", "code", " ", "correspond", "ing", " ", "to", " ", "how", " ", "the", " ", "actor", " ", "shou", "ld", " ", "be", " ", "code", "d", " ", "give", "n", " ", "the", " ", "date", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "code_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "for_", "j_", "in_", "match_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "dates_", "=_", "j_", "[_", "1_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "date_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "code_", "=_", "\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "d_", "in_", "dates_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "if_", "d_", "[_", "0_", "]_", "in_", "'<", ">'_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "date_", "._", "append_", "(_", "d_", "[_", "0_", "]_", "+_", "str_", "(_", "PE", "TR", "reader_", "._", "dstr", "\\u", "to", "\\u", "orda", "te_", "(_", "d_", "[_", "1_", ":_", "]_", ")_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "date_", "._", "append_", "(_", "str_", "(_", "PE", "TR", "reader_", "._", "dstr", "\\u", "to", "\\u", "orda", "te_", "(_", "d_", ")_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "cur", "date_", "=_", "self_", "._", "date_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "not_", "date_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "code_", "=_", "j_", "[_", "0_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "len_", "(_", "date_", ")_", "==_", "1_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "if_", "date_", "[_", "0_", "]_", "[_", "0_", "]_", "==_", "'<'_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "if_", "cur", "date_", "<_", "int_", "(_", "date_", "[_", "0_", "]_", "[_", "1_", ":_", "]_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "code_", "=_", "j_", "[_", "0_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "if_", "cur", "date_", ">=_", "int_", "(_", "date_", "[_", "0_", "]_", "[_", "1_", ":_", "]_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "code_", "=_", "j_", "[_", "0_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "if_", "cur", "date_", "<_", "int_", "(_", "date_", "[_", "1_", "]_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "if_", "cur", "date_", ">=_", "int_", "(_", "date_", "[_", "0_", "]_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "code_", "=_", "j_", "[_", "0_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "code_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "return_", "code_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "Exception_", "as_", "e_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", "print", "(", "e", ")_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "code_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "code_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Nou", "n", "Phrase", "_", "(_", "Phrase", "_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "get", "\\u", "meaning", "_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "def_", "recurse_", "(_", "path_", ",_", "words_", ",_", "length_", ",_", "so", "\\u", "far_", "=_", "\"\"_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "--", " ", " ", " ", " ", "print", "('", "NP", "gm", "-", "rec", "-", "lev", ":'", ",", "len", "(", "geto", "uter", "frames", "(", "current", "frame", "(", "1", "))))", " ", " ", "#", " ", "--", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "words_", "and_", "words_", "[_", "0_", "]_", "in_", "path_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "match_", "=_", "recurse_", "(_", "path_", "[_", "words_", "[_", "0_", "]_", "]_", ",_", "words_", "[_", "1_", ":_", "]_", ",_", "length_", "+_", "1_", ",_", "so", "\\u", "far_", "+_", "\"", " ", "\"_", "+_", "words_", "[_", "0_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "match_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "return_", "match_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "'#'_", "in_", "path_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "isinstance_", "(_", "path_", "[_", "\"#\"_", "]_", ",_", "list_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "code_", "=_", "self_", "._", "check", "\\u", "date_", "(_", "path_", "[_", "'#'_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "not_", "code_", "is_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "\"\"\"", "print", "('", "NP", "gm", "-", "rec", "-1", ":'", ",", "code", ")", " ", " ", "#", " ", "--", "\\", "10", ";", " ", " ", "print", "('", "NP", "gm", "-", "rec", "-1", ".1", ":'", ",", "path", "['", "#'", "][", "-1", "])", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "[_", "code_", "]_", ",_", "so", "\\u", "far_", ",_", "length_", ",_", "[_", "path_", "[_", "'#'_", "]_", "[_", "-_", "1_", "]_", "]_", "#", " ", "16.", "04", ".2", "5", " ", "this", " ", "branch", " ", "alw", "ay", "s", " ", "resolve", "s", " ", "to", " ", "an", " ", "actor", ";", " ", "path", "['", "#'", "][", "-1", "]", " ", "is", " ", "the", " ", "root", " ", "string_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "--", " ", " ", "print", "('", "NP", "gm", "-", "rec", "-", "2", ":'", ",", "path", "['", "#'", "])", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "return_", "[_", "path_", "[_", "'#'_", "]_", "]_", ",_", "so", "\\u", "far_", ",_", "length_", "#", " ", "16.", "04", ".2", "5", " ", "this", " ", "branch", " ", "alw", "ay", "s", " ", "resolve", "s", " ", "to", " ", "an", " ", "agent_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "text", "\\u", "children_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "PP", "codes_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "VP", "codes_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "NP", "codes_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "codes_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "roots_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "--", " ", " ", " ", " ", " ", "print", "('", "NP", "gm", "-0", ":'", ",", "self", ".", "get", "\\u", "text", "())", " ", " ", "#", " ", "--", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "matche", "d\\u", "txt_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "for_", "child_", "in_", "self_", "._", "children_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "isinstance_", "(_", "child_", ",_", "Nou", "n", "Phrase", "_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "value_", "=_", "child_", "._", "get", "\\u", "text_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "text", "\\u", "children_", "+=_", "value_", "[_", "0_", "]_", "._", "split_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "NP", "codes_", "+=_", "value_", "[_", "1_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "child_", "._", "label_", "[_", ":_", "2_", "]_", "in_", "[_", "\"", "JJ", "\"_", ",_", "\"", "DT", "\"_", ",_", "\"", "NN", "\"_", "]_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "text", "\\u", "children_", "+=_", "child_", "._", "get", "\\u", "text_", "(_", ")_", "._", "split_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "child_", "._", "label_", "==_", "\"", "PP", "\"_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "m_", "=_", "self_", "._", "resolve", "\\u", "codes_", "(_", "child_", "._", "get", "\\u", "meaning", "_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "--", " ", " ", " ", " ", " ", " ", "print", "('", "gm", "-1", ":'", ",", "m", ")", " ", " ", "#", " ", "--", "_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "m_", "[_", "0_", "]_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "PP", "codes_", "+=_", "child_", "._", "get", "\\u", "meaning", "_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "text", "\\u", "children_", "+=_", "child_", "._", "get", "\\u", "text_", "(_", ")_", "._", "split_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "child_", "._", "label_", "==_", "\"", "VP", "\"_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "m_", "=_", "child_", "._", "get", "\\u", "meaning", "_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "m_", "and_", "isinstance_", "(_", "m_", "[_", "0_", "]_", "[_", "1_", "]_", ",_", "basestring_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "m_", "=_", "self_", "._", "resolve", "\\u", "codes_", "(_", "m_", "[_", "0_", "]_", "[_", "1_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "m_", "[_", "0_", "]_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "VP", "codes_", "+=_", "child_", "._", "get", "\\u", "theme_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "pass_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "We", " ", "coul", "d", " ", "add", " ", "the", " ", "subtree", " ", "here", ",", " ", "but", " ", "there", " ", "shou", "ld", "n", "'", "t", " ", "be", " ", "any", " ", "codes", " ", "with", " ", "VP", " ", "components_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "child_", "._", "label_", "==_", "\"", "PR", "P", "\"_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Fin", "d", " ", "ante", "ced", "ent_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "not", "\\u", "found_", "=_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "level_", "=_", "self_", "._", "parent_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "refl", "exi", "ve_", "=_", "child_", "._", "text_", "._", "endswith_", "(_", "\"", "SELF", "\"_", ")_", "or_", "child_", "._", "text_", "._", "endswith_", "(_", "\"", "SEL", "VE", "S", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "local_", "=_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "while_", "not", "\\u", "found_", "and_", "level_", "._", "parent_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "if_", "level_", "._", "label_", "._", "startswith_", "(_", "\"", "NP", "\"_", ")_", "and_", "refl", "exi", "ve_", ":_", "#", "Inten", "sive", ",", " ", "ignore_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "break_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "local_", "and_", "level_", "._", "label_", "in_", "[_", "\"", "S", "\"_", ",_", "\"", "SB", "AR", "\"_", "]_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "local_", "=_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "level_", "=_", "level_", "._", "parent_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "continue_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "(_", "not_", "local_", ")_", "or_", "(_", "refl", "exi", "ve_", "and_", "local_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "for_", "child_", "in_", "level_", "._", "parent_", "._", "children_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "if_", "isinstance_", "(_", "child_", ",_", "Nou", "n", "Phrase", "_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "if_", "not_", "child_", "._", "get", "\\u", "meaning", "_", "(_", ")_", "==_", "\"~\"_", ":_", "#", " ", "Do", " ", "we", " ", "just", " ", "want", " ", "to", " ", "pick", " ", "the", " ", "first", "?", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "not", "\\u", "found_", "=_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "codes_", "+=_", "child_", "._", "get", "\\u", "meaning", "_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "break_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "level_", "=_", "level_", "._", "parent_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "check", " ", "whe", "ther", " ", "there", " ", "are", " ", "codes", " ", "in", " ", "the", " ", "noun", " ", "Phrase", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "index_", "=_", "0_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "while_", "index_", "<_", "len_", "(_", "text", "\\u", "children_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "match_", "=_", "recurse_", "(_", "PE", "TR", "globals_", "._", "Act", "or", "Dict_", ",_", "text", "\\u", "children_", "[_", "index_", ":_", "]_", ",_", "0_", ")_", "#", " ", "checking", " ", "for", " ", "actors_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "match_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "--", " ", " ", " ", " ", "print", "('", "NP", "gm", "-", "m", "-1", ":'", ",", "match", ")_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "codes_", "+=_", "match_", "[_", "0_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "roots_", "+=_", "match_", "[_", "3_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "index_", "+=_", "match_", "[_", "2_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "matche", "d\\u", "txt_", "+=_", "[_", "match_", "[_", "1_", "]_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "--", " ", " ", " ", " ", "print", "('", "NP", "gm", "-1", ":'", ",", "matche", "d\\u", "txt", ")_", "\\u\\u\\uNL\\u\\u\\u_", "continue_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "match_", "=_", "recurse_", "(_", "PE", "TR", "globals_", "._", "Agent", "Dict_", ",_", "text", "\\u", "children_", "[_", "index_", ":_", "]_", ",_", "0_", ")_", "#", " ", "checking", " ", "for", " ", "agents_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "match_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "--", " ", " ", " ", " ", "print", "('", "NP", "gm", "-", "2.0", ":'", ",", "root", "s", ")_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "codes_", "+=_", "match_", "[_", "0_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "roots_", "+=_", "[_", "[_", "'~'_", "]_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "index_", "+=_", "match_", "[_", "2_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "matche", "d\\u", "txt_", "+=_", "[_", "match_", "[_", "1_", "]_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\"\"\"", "print", "('", "NP", "gm", "-", "2", ":'", ",", "matche", "d\\u", "txt", ")", " ", "#", " ", "--", "\\", "10", ";", " ", " ", " ", " ", "print", "('", "NP", "gm", "-", "2.1", ":'", ",", "root", "s", ")\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "continue_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "index_", "+=_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\"\"\"", "print", "('", "NP", "gm", "-", "m", "-", "lev", ":'", ",", "len", "(", "geto", "uter", "frames", "(", "current", "frame", "(", "1", "))))", " ", " ", " ", "#", " ", "--", " ", " ", " ", " ", "\\", "10", ";", " ", " ", " ", " ", "print", "('", "NP", "gm", "-", "m", "-", "codes", ":'", ",", "codes", ")", "\\", "10", ";", " ", " ", " ", " ", "print", "('", "NP", "gm", "-", "m", "-", "root", "s", ":'", ",", "root", "s", ")\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "combin", "e", " ", "the", " ", "actor", "/", "agent", " ", "codes_", "\\u\\u\\uNL\\u\\u\\u_", "actor", "codes_", ",_", "agent", "codes_", "=_", "self_", "._", "resolve", "\\u", "codes_", "(_", "codes_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "PP", "actor_", ",_", "PP", "agent_", "=_", "self_", "._", "resolve", "\\u", "codes_", "(_", "PP", "codes_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "NP", "actor_", ",_", "NP", "agent_", "=_", "self_", "._", "resolve", "\\u", "codes_", "(_", "NP", "codes_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "VP", "actor_", ",_", "VP", "agent_", "=_", "self_", "._", "resolve", "\\u", "codes_", "(_", "VP", "codes_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "not_", "actor", "codes_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "actor", "codes_", "+=_", "NP", "actor_", "#", " ", "don", "'", "t", " ", "reall", "y", " ", "need", " ", "+=", " ", "here", ",", " ", "right", "?", " ", "pas", " ", "16.", "04", ".2", "6_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "not_", "actor", "codes_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "actor", "codes_", "+=_", "PP", "actor_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "not_", "actor", "codes_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "actor", "codes_", "+=_", "VP", "actor_", "#", " ", "Do", " ", "we", " ", "want", " ", "to", " ", "pull", " ", "meaning", "s", " ", "from", " ", "verb", " ", "phrase", "s", "?", " ", "Cou", "ld", " ", "be", " ", "risk", "y_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "not_", "agent", "codes_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "agent", "codes_", "+=_", "NP", "agent_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "not_", "agent", "codes_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "agent", "codes_", "+=_", "PP", "agent_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "not_", "agent", "codes_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "agent", "codes_", "+=_", "VP", "agent_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\"\"\"", "if", " ", "len", "(", "actor", "codes", ")", " ", ">", " ", "0", ":", "\\", "10", ";", " ", " ", " ", " ", "print", "('", "NP", "gm", "-", "m", "-", "actor", "codes", ":'", ",", "actor", "codes", ")", "\\", "10", ";", " ", " ", " ", " ", "print", "('", "NP", "gm", "-", "m", "-", "root", "s", " ", ":'", ",", "root", "s", ")\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "meaning", "_", "=_", "self_", "._", "mix", "\\u", "codes_", "(_", "agent", "codes_", ",_", "actor", "codes_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "get", "\\u", "meaning", "_", "=_", "self_", "._", "return", "\\u", "meaning", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\"\"\"", "print", "('", "NP", "gm", "-", "3", ":'", ",", "self", ".", "meaning", ")", "\\", "10", ";", " ", " ", " ", " ", "print", "('", "NP", "gm", "-", "4", ":'", ",", "matche", "d\\u", "txt", ")\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "matche", "d\\u", "txt_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "sentence_", "._", "metadata_", "[_", "'", "noun", "s", "'_", "]_", "+=_", "[_", "(_", "matche", "d\\u", "txt_", ",_", "self_", "._", "meaning", "_", ",_", "roots_", "[_", ":_", "len_", "(_", "matche", "d\\u", "txt_", ")_", "]_", ")_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", " ", " ", " ", "self", ".", "sentence", ".", "print", "\\u", "noun", "s", "('", "NP", "gm", "-", "5", ":'", ")", " ", "#", " ", "--", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "self_", "._", "meaning", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Nou", "n", "Phrase", "_", "(_", "Phrase", "_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "convert", "\\u", "existen", "tial", "_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Res", "huff", "le", " ", "the", " ", "tree", " ", "to", " ", "get", " ", "existen", "tial", " ", "\"", "There", " ", "are", "\"", " ", "phrase", "s", " ", "int", "o", " ", "a", " ", "more", " ", "basic", " ", "form_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "parent_", "=_", "self_", "._", "parent_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "siste", "r_", "=_", "parent_", "._", "children_", "[_", "1_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "nei", "ce_", "=_", "siste", "r_", "._", "children_", "[_", "1_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "subject_", "=_", "nei", "ce_", "._", "children_", "[_", "0_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "predicate_", "=_", "nei", "ce_", "._", "children_", "[_", "1_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "parent_", "._", "children_", "[_", "0_", "]_", "=_", "subject_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "subject_", "._", "parent_", "=_", "parent_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "siste", "r_", "._", "children_", "[_", "1_", "]_", "=_", "predicate_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "predicate_", "._", "parent_", "=_", "siste", "r_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "parent_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", "parent", ".", "print", "\\u", "to", "\\u", "stdout", "(\"", "\")", "_", "\\u\\u\\uNL\\u\\u\\u_", "return_", "subject_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "class_", "Prep", "Phrase", "_", "(_", "Phrase", "_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "[SEP]_", "class_", "Prep", "Phrase", "_", "(_", "Phrase", "_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "def_", "\\u\\u", "init\\u\\u_", "(_", "self_", ",_", "label_", ",_", "date_", ",_", "sentence_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "Phrase", "_", "._", "\\u\\u", "init\\u\\u_", "(_", "self_", ",_", "label_", ",_", "date_", ",_", "sentence_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "meaning", "_", "=_", "\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "prep_", "=_", "\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "head_", "=_", "\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Prep", "Phrase", "_", "(_", "Phrase", "_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "get", "\\u", "meaning", "_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Return", " ", "the", " ", "meaning", " ", "of", " ", "the", " ", "non", "-", "prepo", "sition", " ", "constitu", "ent", ",", " ", "and", " ", "store", " ", "the", "\\", "10", ";", " ", " ", " ", " ", "prepo", "sition", ".", "\\", "10", ";", " ", " ", " ", " ", "\\", "10", ";", " ", " ", " ", " ", "Not", "e", ":", " ", "pas", " ", "16.", "04", ".2", "2", "\\", "10", ";", " ", " ", " ", " ", "Add", " ", "this", " ", "len", "()", " ", ">", " ", "0", " ", "check", " ", "to", " ", "get", " ", "aro", "und", " ", "a", " ", "very", " ", "rare", " ", "(", "abo", "ut", " ", "0.001", "%", " ", "of", " ", "LN", " ", "sentence", "s", ")", " ", "case", "s", " ", "where", " ", "a", " ", "(", "PP", " ", "(", "PR", "P", " ", "structure", "\\", "10", ";", " ", " ", " ", " ", "caus", "ed", " ", "an", " ", "infini", "te", " ", "recursion", " ", "bet", "ween", " ", "Nou", "n", "Phrase", ".", "get", "\\u", "meaning", "()", " ", "and", " ", "Prep", "Phrase", ".", "get", "\\u", "meaning", "()", " ", "in", " ", "circum", "stance", "s", " ", "where", "\\", "10", ";", " ", " ", " ", " ", "self", ".", "child", "ren", "[", "1", "].", "get", "\\u", "text", "()", " ", "ga", "ve", " ", "an", " ", "empty", " ", "string", ".", " ", "Thi", "s", " ", "solve", "s", " ", "the", " ", "problem", " ", "but", " ", "I", "'", "m", " ", "not", " ", "complete", "ly", " ", "confi", "dent", " ", "this", " ", "is", " ", "\\", "10", ";", " ", " ", " ", " ", "the", " ", "right", " ", "place", " ", "to", " ", "trap", " ", "it", ":", " ", "in", " ", "the", " ", "process", " ", "of", " ", "debugg", "ing", " ", "I", " ", "notice", "d", " ", "tha", "t", " ", "there", " ", "wer", "e", " ", "case", "s", " ", "where", " ", "this", " ", "recursion", " ", "\\", "10", ";", " ", " ", " ", " ", "see", "med", " ", "to", " ", "go", " ", "a", " ", "lot", " ", "deep", "er", " ", "than", " ", "necessar", "y", ",", " ", "continui", "ng", " ", "with", " ", "the", " ", "same", " ", "string", ",", " ", "on", " ", "some", " ", "non", "-", "empty", " ", "string", "s", ",", " ", "tho", "ugh", " ", "it", " ", "\\", "10", ";", " ", " ", " ", " ", "did", " ", "not", " ", "crash", ".", " ", " ", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "--", " ", " ", " ", " ", "print", "('", "PP", "gm", "-", "entry", "')", " ", " ", "#", " ", "--", "_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "prep_", "=_", "self_", "._", "children_", "[_", "0_", "]_", "._", "text_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "len_", "(_", "self_", "._", "children_", ")_", ">_", "1_", "and_", "not_", "self_", "._", "children_", "[_", "1_", "]_", "._", "color_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "isinstance_", "(_", "self_", "._", "children_", "[_", "1_", "]_", ",_", "Nou", "n", "Phrase", "_", ")_", "and_", "len_", "(_", "self_", "._", "children_", "[_", "1_", "]_", "._", "get", "\\u", "text_", "(_", ")_", "[_", "0_", "]_", ")_", ">_", "0_", ":_", "#", " ", "see", " ", "note", " ", "above_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "--", " ", " ", " ", " ", "print", "('", "PP", "gm", "-", "503", "',", "self", ".", "child", "ren", "[", "1", "].", "get", "\\u", "text", "())", " ", " ", "#", " ", "--", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "meaning", "_", "=_", "self_", "._", "children_", "[_", "1_", "]_", "._", "get", "\\u", "meaning", "_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "meaning", "_", "=_", "\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", " ", " ", " ", "self", ".", "meaning", " ", "=", " ", "self", ".", "child", "ren", "[", "1", "].", "get", "\\u", "meaning", "()", " ", "if", " ", "isin", "stance", "(", "self", ".", "child", "ren", "[", "1", "],", "Nou", "n", "Phrase", ")", " ", "else", " ", "\"\"", " ", " ", "#", " ", "code", " ", "prior", " ", "to", " ", "the", " ", "correction_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "--", " ", " ", " ", " ", "print", "('", "PP", "gm", "-", "2", "',", "self", ".", "meaning", ")", " ", " ", "#", " ", "--", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "head_", "=_", "self_", "._", "children_", "[_", "1_", "]_", "._", "get", "\\u", "head_", "(_", ")_", "[_", "0_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "self_", "._", "meaning", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Prep", "Phrase", "_", "(_", "Phrase", "_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "get", "\\u", "prep_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "self_", "._", "children_", "[_", "0_", "]_", "._", "text_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "class_", "Verb", "Phrase", "_", "(_", "Phrase", "_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Subc", "lass", " ", "specific", " ", "to", " ", "Verb", " ", "Phrase", "s", "\\", "10", ";", " ", " ", " ", " ", "\\", "10", ";", " ", " ", " ", " ", "Meth", "ods", "\\", "10", ";", " ", " ", " ", " ", "-------", "\\", "10", ";", " ", " ", " ", " ", "\\u\\u", "init", "\\u\\u:", " ", "Initializ", "ation", " ", "and", " ", "Insta", "tiat", "ion", "\\", "10", ";", " ", " ", " ", " ", "\\", "10", ";", " ", " ", " ", " ", "is", "\\u", "valid", ":", " ", "Correct", "s", " ", "a", " ", "know", "n", " ", "stan", "for", "d", " ", "error", " ", "regarding", " ", "misc", "ode", "d", " ", "noun", " ", "phrase", "s", "\\", "10", ";", " ", " ", " ", " ", "\\", "10", ";", " ", " ", " ", " ", "get", "\\u", "them", "e", ":", " ", "Return", "s", " ", "the", " ", "code", "d", " ", "target", " ", "of", " ", "the", " ", "VP", "\\", "10", ";", " ", " ", " ", " ", "\\", "10", ";", " ", " ", " ", " ", "get", "\\u", "meaning", ":", " ", "Return", "s", " ", "event", " ", "codi", "ng", " ", "descri", "bed", " ", "by", " ", "the", " ", "verb", " ", "phrase", "\\", "10", ";", " ", " ", " ", " ", "\\", "10", ";", " ", " ", " ", " ", "get", "\\u", "lower", ":", " ", "Fin", "ds", " ", "meaning", "s", " ", "of", " ", "child", "ren", "\\", "10", ";", " ", " ", " ", " ", "\\", "10", ";", " ", " ", " ", " ", "get", "\\u", "upper", ":", " ", "Fin", "ds", " ", "gram", "matical", " ", "subject", "\\", "10", ";", " ", " ", " ", " ", "\\", "10", ";", " ", " ", " ", " ", "get", "\\u", "code", ":", " ", "Fin", "ds", " ", "base", " ", "verb", " ", "code", " ", "and", " ", "calls", " ", "match", "\\u", "pattern", "\\", "10", ";", " ", " ", " ", " ", "\\", "10", ";", " ", " ", " ", " ", "match", "\\u", "pattern", ":", " ", "Match", "es", " ", "the", " ", "tree", " ", "to", " ", "a", " ", "pattern", " ", "in", " ", "the", " ", "Verb", " ", "Dict", "ionar", "y", "\\", "10", ";", " ", " ", " ", " ", "\\", "10", ";", " ", " ", " ", " ", "get", "\\u", "S", ":", " ", "Fin", "ds", " ", "the", " ", "closest", " ", "S", "-", "level", " ", "phrase", " ", "above", " ", "the", " ", "verb", "\\", "10", ";", " ", " ", " ", " ", "\\", "10", ";", " ", " ", " ", " ", "match", "\\u", "transform", ":", " ", "Match", "es", " ", "an", " ", "event", " ", "code", " ", "against", " ", "transformation", " ", "pattern", "s", " ", "in", " ", "the", " ", "dictionar", "y", "\\", "10", ";", " ", " ", " ", " ", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "[SEP]_", "class_", "Verb", "Phrase", "_", "(_", "Phrase", "_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "\\u\\u", "init\\u\\u_", "(_", "self_", ",_", "label_", ",_", "date_", ",_", "sentence_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "Phrase", "_", "._", "\\u\\u", "init\\u\\u_", "(_", "self_", ",_", "label_", ",_", "date_", ",_", "sentence_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "meaning", "_", "=_", "\"\"_", "#", " ", "\"", "meaning", "\"", " ", "for", " ", "the", " ", "verb", ",", " ", "i", ".", "e", ".", " ", "the", " ", "events", " ", "code", "d", " ", "by", " ", "the", " ", "vp_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "upper_", "=_", "\"\"_", "#", " ", "contain", "s", " ", "the", " ", "meaning", " ", "of", " ", "the", " ", "noun", " ", "phrase", " ", "in", " ", "the", " ", "specifier", " ", "position", " ", "for", " ", "the", " ", "vp", " ", "or", " ", "its", " ", "parents_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "lower_", "=_", "\"\"_", "#", " ", "contain", "s", " ", "the", " ", "meaning", " ", "of", " ", "the", " ", "subtree", " ", "c", "-", "commande", "d", " ", "by", " ", "the", " ", "verb_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "passive", "_", "=_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "code_", "=_", "0_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "valid_", "=_", "self_", "._", "is", "\\u", "valid_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "S_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Verb", "Phrase", "_", "(_", "Phrase", "_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "is", "\\u", "valid_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Thi", "s", " ", "method", " ", "is", " ", "large", "ly", " ", "to", " ", "over", "come", " ", "frequent", "ly", " ", "made", " ", "Stan", "for", "d", " ", "error", "s", ",", " ", "where", " ", "phrase", "s", " ", "like", " ", "\"", "exi", "led", " ", "diss", "ident", "s", "\"", " ", "wer", "e", "\\", "10", ";", " ", " ", " ", " ", "marked", " ", "as", " ", "verb", " ", "phrase", "s", ",", " ", "and", " ", "treat", "ing", " ", "them", " ", "as", " ", "suc", "h", " ", "wou", "ld", " ", "yield", " ", "weird", " ", "parse", "s", ".", "\\", "10", ";", " ", " ", " ", " ", "\\", "10", ";", " ", " ", " ", " ", "On", "ce", " ", "suc", "h", " ", "a", " ", "phrase", " ", "is", " ", "identifi", "ed", " ", "bec", "aus", "e", " ", "of", " ", "its", " ", "weird", " ", "distribu", "tion", ",", " ", "it", " ", "is", " ", "convert", "ed", " ", "to", " ", "\\", "10", ";", " ", " ", " ", " ", "a", " ", "Nou", "n", "Phrase", " ", "object", "\\", "10", ";", " ", " ", " ", " ", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "self_", "._", "children_", "[_", "0_", "]_", "._", "label_", "==_", "\"", "VB", "N", "\"_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "help", "ing_", "=_", "[_", "\"", "HA", "VE", "\"_", ",_", "\"", "HA", "D", "\"_", ",_", "\"", "HA", "VING", "\"_", ",_", "\"", "HAS", "\"_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "(_", "(_", "not_", "(_", "self_", "._", "parent_", "._", "get", "\\u", "head_", "(_", ")_", "[_", "0_", "]_", "in_", "help", "ing_", "or_", "self_", "._", "parent_", "._", "children_", "[_", "0_", "]_", "._", "text_", "in_", "help", "ing_", ")_", ")_", "and_", "\\u\\u\\uNL\\u\\u\\u_", "len_", "(_", "filter_", "(_", "lambda_", "a_", ":_", "isinstance_", "(_", "a_", ",_", "Verb", "Phrase", "_", ")_", ",_", "self_", "._", "parent_", "._", "children_", ")_", ")_", "<=_", "1_", "and_", "\\u\\u\\uNL\\u\\u\\u_", "not_", "self_", "._", "check", "\\u", "passive", "_", "(_", ")_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "self_", "._", "valid_", "=_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "np", "\\u", "replacement_", "=_", "Nou", "n", "Phrase", "_", "(_", "\"", "NP", "\"_", ",_", "self_", "._", "date_", ",_", "self_", "._", "sentence_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "np", "\\u", "replacement_", "._", "children_", "=_", "self_", "._", "children_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "np", "\\u", "replacement_", "._", "parent_", "=_", "self_", "._", "parent_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "np", "\\u", "replacement_", "._", "index_", "=_", "self_", "._", "index_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "parent_", "._", "children_", "._", "remove_", "(_", "self_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "parent_", "._", "children_", "._", "insert_", "(_", "self_", "._", "index_", ",_", "np", "\\u", "replacement_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "del_", "(_", "self_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "=_", "np", "\\u", "replacement_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "valid_", "=_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "Index", "Error_", "as_", "e_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "valid_", "=_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Verb", "Phrase", "_", "(_", "Phrase", "_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "get", "\\u", "theme_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Thi", "s", " ", "is", " ", "used", " ", "by", " ", "the", " ", "Nou", "n", "Phrase", ".", "get", "\\u", "meaning", "()", " ", "method", " ", "to", " ", "dete", "rmin", "e", " ", "rele", "van", "t", "\\", "10", ";", " ", " ", " ", " ", "informati", "on", " ", "in", " ", "the", " ", "Verb", "Phrase", ".", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "m_", "=_", "self_", "._", "get", "\\u", "meaning", "_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "isinstance_", "(_", "m_", "[_", "0_", "]_", ",_", "basestring_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "[_", "m_", "[_", "0_", "]_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "m_", "[_", "0_", "]_", "[_", "1_", "]_", "==_", "'", "passive", "'_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "m_", "[_", "0_", "]_", "[_", "0_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "[_", "m_", "[_", "0_", "]_", "[_", "1_", "]_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Verb", "Phrase", "_", "(_", "Phrase", "_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "return", "\\u", "meaning", "_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "self_", "._", "meaning", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Verb", "Phrase", "_", "(_", "Phrase", "_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "get", "\\u", "meaning", "_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Thi", "s", " ", "dete", "rmin", "es", " ", "the", " ", "event", " ", "codi", "ng", " ", "of", " ", "the", " ", "subtree", " ", "root", "ed", " ", "in", " ", "this", " ", "verb", " ", "phrase", ".", "\\", "10", ";", " ", " ", " ", " ", "\\", "10", ";", " ", " ", " ", " ", "Four", " ", "method", "s", " ", "are", " ", "key", " ", "in", " ", "this", " ", "process", ":", " ", "get", "\\u", "upper", "()", ",", " ", "get", "\\u", "lower", "()", ",", " ", "get", "\\u", "code", "()", " ", "\\", "10", ";", " ", " ", " ", " ", "and", " ", "match", "\\u", "transform", "()", ".", "\\", "10", ";", " ", " ", " ", " ", "\\", "10", ";", " ", " ", " ", " ", "Fi", "rst", ",", " ", "get", "\\u", "meaning", "()", " ", "gets", " ", "the", " ", "verb", " ", "code", " ", "from", " ", "get", "\\u", "code", "()", "\\", "10", ";", " ", " ", " ", " ", "\\", "10", ";", " ", " ", " ", " ", "The", "n", ",", " ", "it", " ", "checks", " ", "passi", "vity", ".", " ", "If", " ", "the", " ", "verb", " ", "is", " ", "passive", ",", " ", "then", " ", "it", " ", "look", "s", " ", "within", " ", "\\", "10", ";", " ", " ", " ", " ", "verb", " ", "phrase", "s", " ", "head", "ed", " ", "by", " ", "[", "by", ",", " ", "from", ",", " ", "in", "]", " ", "for", " ", "the", " ", "source", ",", " ", "and", " ", "for", " ", "an", " ", "explicit", " ", "target", "\\", "10", ";", " ", " ", " ", " ", "in", " ", "verb", " ", "phrase", "s", " ", "head", "ed", " ", "by", " ", "[", "at", ",", "against", ",", "int", "o", ",", "towards", "].", " ", "If", " ", "no", " ", "target", " ", "is", " ", "found", ",", "\\", "10", ";", " ", " ", " ", " ", "this", " ", "space", " ", "is", " ", "filled", " ", "with", " ", "'", "passive", "',", " ", "a", " ", "flag", " ", "used", " ", "late", "r", " ", "to", " ", "assign", " ", "a", " ", "target", "\\", "10", ";", " ", " ", " ", " ", "if", " ", "it", " ", "is", " ", "in", " ", "the", " ", "gram", "matical", " ", "subject", " ", "position", ".", " ", "\\", "10", ";", " ", " ", " ", " ", "\\", "10", ";", " ", " ", " ", " ", "If", " ", "the", " ", "verb", " ", "is", " ", "not", " ", "passive", ",", " ", "then", " ", "the", " ", "process", " ", "go", "es", ":", "\\", "10", ";", " ", " ", " ", " ", "\\", "10", ";", " ", " ", " ", " ", "1", ")", " ", "call", " ", "get", "\\u", "upper", "()", " ", "and", " ", "get", "\\u", "lower", "()", " ", "to", " ", "check", " ", "for", " ", "a", " ", "gram", "matical", " ", "subject", " ", "\\", "10", ";", " ", " ", " ", " ", "and", " ", "find", " ", "the", " ", "codi", "ng", " ", "of", " ", "the", " ", "subtree", " ", "and", " ", "child", "ren", ",", " ", "respec", "tiv", "el", "y", ".", "\\", "10", ";", " ", " ", " ", " ", "\\", "10", ";", " ", " ", " ", " ", "2", ")", " ", "If", " ", "get", "\\u", "lower", " ", "return", "ed", " ", "a", " ", "list", " ", "of", " ", "events", ",", " ", "combin", "e", " ", "tho", "se", " ", "events", " ", "with", "\\", "10", ";", " ", " ", " ", " ", "the", " ", "upper", " ", "and", " ", "code", ",", " ", "add", " ", "to", " ", "event", " ", "list", ".", "\\", "10", ";", " ", " ", " ", " ", "\\", "10", ";", " ", " ", " ", " ", "3", ")", " ", "Ot", "her", "wis", "e", ",", " ", "combin", "e", " ", "upper", ",", " ", "lower", ",", " ", "and", " ", "code", " ", " ", "and", " ", "add", " ", "to", " ", "event", " ", "list", "\\", "10", ";", " ", " ", " ", " ", "\\", "10", ";", " ", " ", " ", " ", "4", ")", " ", "Check", " ", "to", " ", "see", " ", "if", " ", "there", " ", "are", " ", "S", "-", "level", " ", "child", "ren", ",", " ", "if", " ", "so", ",", " ", "combin", "e", " ", "with", "\\", "10", ";", " ", " ", " ", " ", "upper", " ", "and", " ", "code", ",", " ", "add", " ", "to", " ", "list", ".", " ", "\\", "10", ";", " ", " ", " ", " ", "\\", "10", ";", " ", " ", " ", " ", "5", ")", " ", "call", " ", "match", "\\u", "transform", "()", " ", "on", " ", "all", " ", "events", " ", "in", " ", "the", " ", "list", "\\", "10", ";", " ", " ", " ", " ", "\\", "10", ";", " ", " ", " ", " ", "\\", "10", ";", " ", " ", " ", " ", "Parameter", "s", "\\", "10", ";", " ", " ", " ", " ", "----------", "\\", "10", ";", " ", " ", " ", " ", "self", ":", " ", "Verb", "Phrase", " ", "object", " ", "tha", "t", " ", "call", "ed", " ", "the", " ", "method", "\\", "10", ";", " ", " ", " ", "\\", "10", ";", " ", " ", " ", " ", "Return", "s", "\\", "10", ";", " ", " ", " ", " ", "-------", "\\", "10", ";", " ", " ", " ", " ", "events", ":", " ", "list", "\\", "10", ";", " ", " ", " ", " ", "List", " ", "of", " ", "events", " ", "code", "d", " ", "by", " ", "the", " ", "subtree", " ", "root", "ed", " ", "in", " ", "this", " ", "phrase", ".", "\\", "10", ";", " ", " ", " ", " ", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "time1_", "=_", "time_", "._", "time_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "get", "\\u", "meaning", "_", "=_", "self_", "._", "return", "\\u", "meaning", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "c_", ",_", "passive", "_", ",_", "meta_", "=_", "self_", "._", "get", "\\u", "code_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "s", "\\u", "options_", "=_", "filter_", "(_", "lambda_", "a_", ":_", "a_", "._", "label_", "in_", "\"", "SB", "AR", "\"_", ",_", "self_", "._", "children_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "resolve", "\\u", "events_", "(_", "event_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Help", "er", " ", "method", " ", "to", " ", "combin", "e", " ", "events", ",", " ", "accounti", "ng", " ", "for", " ", "\\", "10", ";", " ", " ", " ", " ", "missi", "ng", " ", "source", "s", ",", " ", "and", " ", " ", "target", "s", ",", " ", "passive", "s", ",", " ", "multiple", "-", "\\", "10", ";", " ", " ", " ", " ", "target", " ", "passive", "s", ",", " ", "and", " ", "code", "less", " ", "verbs", ".", "\\", "10", ";", " ", " ", " ", " ", "\\", "10", ";", " ", " ", " ", " ", "Parameter", "s", "\\", "10", ";", " ", " ", " ", " ", "----------", "\\", "10", ";", " ", " ", " ", " ", "event", ":", " ", "tuple", "\\", "10", ";", " ", "(", "source", ",", " ", "target", ",", " ", "code", ")", " ", "of", " ", "lower", " ", "event", "\\", "10", ";", " ", " ", " ", " ", "\\", "10", ";", " ", " ", " ", " ", "Return", "s", "\\", "10", ";", " ", " ", " ", " ", "-------", "\\", "10", ";", " ", " ", " ", " ", "return", "s", ":", " ", "[", "tuple", "]", "\\", "10", ";", " ", " ", " ", "list", " ", "of", " ", "resolve", "d", " ", "event", " ", "tuple", "s", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "returns_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "first_", ",_", "second_", ",_", "third_", "=_", "[_", "up_", ",_", "\"\"_", ",_", "\"\"_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "not_", "(_", "up_", "or_", "c_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "[_", "event_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "not_", "isinstance_", "(_", "event_", ",_", "tuple_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "second_", "=_", "event_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "third_", "=_", "c_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "passive", "_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "for_", "item_", "in_", "first_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "e2_", "=_", "(_", "[_", "second_", "]_", ",_", "item_", ",_", "passive", "_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "sentence_", "._", "metadata_", "[_", "id_", "(_", "e2_", ")_", "]_", "=_", "[_", "event_", ",_", "meta_", ",_", "7_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "returns_", "._", "append_", "(_", "e2_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "event_", "[_", "1_", "]_", "==_", "'", "passive", "'_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "first_", "=_", "event_", "[_", "0_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "third_", "=_", "utilities_", "._", "combin", "e\\u", "code_", "(_", "c_", ",_", "event_", "[_", "2_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "up_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "returns_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "source_", "in_", "up_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "e_", "=_", "(_", "first_", ",_", "source_", ",_", "third_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "sentence_", "._", "metadata_", "[_", "id_", "(_", "e_", ")_", "]_", "=_", "[_", "event_", ",_", "up_", ",_", "1_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "returns_", "._", "append_", "(_", "e_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "returns_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "second_", "=_", "'", "passive", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "not_", "event_", "[_", "0_", "]_", "in_", "[_", "''_", ",_", "[_", "]_", ",_", "[_", "\"\"_", "]_", ",_", "[_", "\"~\"_", "]_", ",_", "[_", "\"", "~~", "\"_", "]_", "]_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "second_", "=_", "event_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "third_", "=_", "c_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "second_", "=_", "event_", "[_", "1_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "third_", "=_", "utilities_", "._", "combin", "e\\u", "code_", "(_", "c_", ",_", "event_", "[_", "2_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "e_", "=_", "(_", "first_", ",_", "second_", ",_", "third_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "sentence_", "._", "metadata_", "[_", "id_", "(_", "e_", ")_", "]_", "=_", "[_", "event_", ",_", "c_", ",_", "meta_", ",_", "2_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "returns_", "+_", "[_", "e_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "events_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "up_", "=_", "self_", "._", "get", "\\u", "upper_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "self_", "._", "check", "\\u", "passive", "_", "(_", ")_", "or_", "(_", "passive", "_", "and_", "not_", "c_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Check", " ", "for", " ", "source", " ", "in", " ", "prep", "s_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "source", "\\u", "options_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "target", "\\u", "options_", "=_", "up_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "child_", "in_", "self_", "._", "children_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "isinstance_", "(_", "child_", ",_", "Prep", "Phrase", "_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "if_", "child_", "._", "get", "\\u", "prep_", "(_", ")_", "in_", "[_", "\"", "BY", "\"_", ",_", "\"", "FROM", "\"_", ",_", "\"", "IN", "\"_", "]_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "source", "\\u", "options_", "+=_", "child_", "._", "get", "\\u", "meaning", "_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "meta_", "._", "append_", "(_", "(_", "child_", "._", "prep_", ",_", "child_", "._", "get", "\\u", "meaning", "_", "(_", ")_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "child_", "._", "get", "\\u", "prep_", "(_", ")_", "in_", "[_", "\"", "AT", "\"_", ",_", "\"", "AGA", "INST", "\"_", ",_", "\"", "INT", "O", "\"_", ",_", "\"", "TO", "WARD", "S", "\"_", "]_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "target", "\\u", "options_", "+=_", "child_", "._", "get", "\\u", "meaning", "_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "meta_", "._", "append_", "(_", "(_", "child_", "._", "prep_", ",_", "child_", "._", "get", "\\u", "meaning", "_", "(_", ")_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "not_", "target", "\\u", "options_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "target", "\\u", "options_", "=_", "[_", "\"", "passive", "\"_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "source", "\\u", "options_", "or_", "c_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "for_", "i_", "in_", "target", "\\u", "options_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "e_", "=_", "(_", "source", "\\u", "options_", ",_", "i_", ",_", "c_", "if_", "self_", "._", "check", "\\u", "passive", "_", "(_", ")_", "else_", "passive", "_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "events_", "._", "append_", "(_", "e_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "sentence_", "._", "metadata_", "[_", "id_", "(_", "e_", ")_", "]_", "=_", "[_", "None_", ",_", "e_", ",_", "meta_", ",_", "3_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "meaning", "_", "=_", "events_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "events_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "up_", "=_", "\"\"_", "if_", "up_", "in_", "[_", "''_", ",_", "[_", "]_", ",_", "[_", "\"\"_", "]_", ",_", "[_", "\"~\"_", "]_", ",_", "[_", "\"", "~~", "\"_", "]_", "]_", "else_", "up_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "low_", ",_", "neg_", "=_", "self_", "._", "get", "\\u", "lower_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "not_", "low_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "low_", "=_", "\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "neg_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "c_", "=_", "0_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "isinstance_", "(_", "low_", ",_", "list_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "for_", "event_", "in_", "low_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "events_", "+=_", "resolve", "\\u", "events_", "(_", "event_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "not_", "s", "\\u", "options_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "up_", "or_", "c_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "e_", "=_", "(_", "up_", ",_", "low_", ",_", "c_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "sentence_", "._", "metadata_", "[_", "id_", "(_", "e_", ")_", "]_", "=_", "[_", "None_", ",_", "e_", ",_", "4_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "events_", "._", "append_", "(_", "e_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "low_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "events_", "._", "append_", "(_", "low_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "lower_", "=_", "map_", "(_", "lambda_", "a_", ":_", "a_", "._", "get", "\\u", "meaning", "_", "(_", ")_", ",_", "s", "\\u", "options_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "sents_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "for_", "item_", "in_", "lower_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "sents_", "+=_", "item_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "sents_", "and_", "not_", "events_", ":_", "#", " ", "On", "ly", " ", "if", " ", "not", "hing", " ", "else", " ", "has", " ", "bee", "n", " ", "found", " ", "do", " ", "we", " ", "look", " ", "at", " ", "lower", " ", "NP", "'", "s", "?", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Thi", "s", " ", "decrease", "s", " ", "our", " ", "codi", "ng", " ", "freque", "nc", "y", ",", " ", "but", " ", "remove", "s", " ", "many", " ", "fal", "se", " ", "positives", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "for_", "event_", "in_", "sents_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "isinstance_", "(_", "event_", ",_", "tuple_", ")_", "and_", "(_", "event_", "[_", "1_", "]_", "or_", "event_", "[_", "2_", "]_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "for_", "ev_", "in_", "resolve", "\\u", "events_", "(_", "event_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "if_", "isinstance_", "(_", "ev_", "[_", "1_", "]_", ",_", "list_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "for_", "item_", "in_", "ev_", "[_", "1_", "]_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "local_", "=_", "(_", "ev_", "[_", "0_", "]_", ",_", "item_", ",_", "ev_", "[_", "2_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "sentence_", "._", "metadata_", "[_", "id_", "(_", "local_", ")_", "]_", "=_", "[_", "ev_", ",_", "item_", ",_", "5_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "events_", "._", "append_", "(_", "local_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "events_", "+=_", "resolve", "\\u", "events_", "(_", "event_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "maps_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "i_", "in_", "events_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "evs", "_", "=_", "self_", "._", "match", "\\u", "transform_", "(_", "i_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "isinstance_", "(_", "evs", "_", ",_", "tuple_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "for_", "j_", "in_", "evs", "_", "[_", "0_", "]_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "maps_", "._", "append_", "(_", "j_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "sentence_", "._", "metadata_", "[_", "id_", "(_", "j_", ")_", "]_", "=_", "[_", "i_", ",_", "evs", "_", "[_", "1_", "]_", ",_", "6_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "maps_", "+=_", "evs", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "meaning", "_", "=_", "maps_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "maps_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Verb", "Phrase", "_", "(_", "Phrase", "_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "return", "\\u", "upper_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "self_", "._", "upper_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Verb", "Phrase", "_", "(_", "Phrase", "_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "return", "\\u", "passive", "_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "self_", "._", "passive", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Verb", "Phrase", "_", "(_", "Phrase", "_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "check", "\\u", "passive", "_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Check", " ", "if", " ", "the", " ", "verb", " ", "is", " ", "passive", " ", "under", " ", "these", " ", "condition", "s", ":", "\\", "10", ";", " ", " ", " ", " ", "1", ")", " ", "Verb", " ", "is", " ", "-", "ed", " ", "form", ",", " ", "whi", "ch", " ", "is", " ", "nota", "ted", " ", "by", " ", "stan", "for", "d", " ", "as", " ", "VB", "D", " ", "or", " ", "VB", "N", "\\", "10", ";", " ", " ", " ", " ", "2", ")", " ", "Verb", " ", "has", " ", "a", " ", "form", " ", "of", " ", "\"", "be", "\"", " ", "as", " ", "its", " ", "next", " ", "high", "est", " ", "verb", " ", "\\", "10", ";", " ", " ", " ", " ", "\\", "10", ";", " ", " ", " ", " ", "Parameter", "s", "\\", "10", ";", " ", " ", " ", " ", "----------", "\\", "10", ";", " ", " ", " ", " ", "self", ":", " ", "Verb", "Phrase", " ", "object", " ", "calling", " ", "the", " ", "method", "\\", "10", ";", " ", " ", " ", " ", "\\", "10", ";", " ", " ", " ", " ", "Return", "s", "\\", "10", ";", " ", " ", " ", " ", "-------", "\\", "10", ";", " ", " ", " ", " ", "self", ".", "passive", ":", " ", "boolean", "\\", "10", ";", " ", " ", " ", " ", "Whe", "ther", " ", "or", " ", "not", " ", "it", " ", "is", " ", "passive", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "--", " ", " ", "print", "('", "cp", "-", "entry", "')", "_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "check", "\\u", "passive", "_", "=_", "self_", "._", "return", "\\u", "passive", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "True_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "self_", "._", "children_", "[_", "0_", "]_", "._", "label_", "in_", "[_", "\"", "VB", "D", "\"_", ",_", "\"", "VB", "N", "\"_", "]_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "level_", "=_", "self_", "._", "parent_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "level_", "._", "label_", "==_", "\"", "NP", "\"_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "self_", "._", "passive", "_", "=_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "for_", "i_", "in_", "range_", "(_", "2_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "if_", "level_", "and_", "isinstance_", "(_", "level_", ",_", "Verb", "Phrase", "_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "if_", "level_", "._", "children_", "[_", "0_", "]_", "._", "text_", "in_", "[_", "\"", "AM", "\"_", ",_", "\"", "IS", "\"_", ",_", "\"", "ARE", "\"_", ",_", "\"", "WA", "S", "\"_", ",_", "\"", "WE", "RE", "\"_", ",_", "\"", "BE", "\"_", ",_", "\"", "BE", "EN", "\"_", ",_", "\"", "BE", "ING", "\"_", "]_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "self_", "._", "passive", "_", "=_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "level_", "=_", "level_", "._", "parent_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "not_", "level_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "break_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "print_", "(_", "\"", "Error", " ", "in", " ", "passive", " ", "check", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "passive", "_", "=_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Verb", "Phrase", "_", "(_", "Phrase", "_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "return", "\\u", "S_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "--", " ", " ", "print", "('", "r", "S", "-", "entry", "')", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "self_", "._", "S_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Verb", "Phrase", "_", "(_", "Phrase", "_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "get", "\\u", "S_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Navigat", "e", " ", "up", " ", "the", " ", "tree", " ", "follow", "ing", " ", "a", " ", "VP", " ", "path", " ", "to", " ", "find", " ", "the", " ", "closest", " ", "s", "-", "level", " ", "phrase", ".", " ", "\\", "10", ";", " ", " ", " ", " ", "There", " ", "is", " ", "the", " ", "extra", " ", "condition", " ", "tha", "t", " ", "if", " ", "the", " ", "S", "-", "level", " ", "phrase", " ", "is", " ", "a", " ", "\"", "TO", "\"-", "phrase", " ", "\\", "10", ";", " ", " ", " ", " ", "with", "out", " ", "a", " ", "second", " ", "subject", " ", "specified", ",", " ", "just", " ", "so", " ", "tha", "t", " ", "\"", "A", " ", "want", "s", " ", "to", " ", "help", " ", "B", "\"", " ", "will", "\\", "10", ";", " ", " ", " ", " ", "navigate", " ", "all", " ", "the", " ", "way", " ", "up", " ", "to", " ", "\"", "A", " ", "want", "s", "\"", " ", "rat", "her", " ", "than", " ", "stopping", " ", "at", " ", "\"", "to", "\"", "\\", "10", ";", " ", " ", " ", " ", "\\", "10", ";", " ", " ", " ", " ", "Parameter", "s", "\\", "10", ";", " ", " ", " ", " ", "-----------", "\\", "10", ";", " ", " ", " ", " ", "self", ":", " ", "Verb", "Phrase", " ", "object", " ", "tha", "t", " ", "call", "ed", " ", "the", " ", "method", "\\", "10", ";", " ", " ", " ", " ", "\\", "10", ";", " ", " ", " ", " ", "Return", "s", "\\", "10", ";", " ", " ", " ", " ", "-------", "\\", "10", ";", " ", " ", " ", " ", "level", ":", " ", "Verb", "Phrase", " ", "object", "\\", "10", ";", " ", " ", " ", "Lo", "west", " ", "non", "-", "TO", " ", "S", "-", "level", " ", "phrase", " ", "object", " ", "above", " ", "the", " ", "verb", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "--", " ", " ", "print", "('", "g", "S", "-", "entry", "')", "_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "get", "\\u", "S_", "=_", "self_", "._", "return", "\\u", "S_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "not", "\\u", "found_", "=_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "level_", "=_", "self_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "while_", "not", "\\u", "found_", "and_", "not_", "level_", "._", "parent_", "is_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "isinstance_", "(_", "level_", "._", "parent_", ",_", "Verb", "Phrase", "_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "level_", "=_", "level_", "._", "parent_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "level_", "._", "parent_", "._", "label_", "==_", "\"", "S", "\"_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "level_", "._", "children_", "[_", "0_", "]_", "._", "label_", "==_", "\"", "TO", "\"_", "and_", "level_", "._", "index_", "==_", "0_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "level_", "=_", "level_", "._", "parent_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "continue_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "S_", "=_", "level_", "._", "parent_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "level_", "._", "parent_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "level_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Verb", "Phrase", "_", "(_", "Phrase", "_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "get", "\\u", "upper_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Fin", "ds", " ", "the", " ", "meaning", " ", "of", " ", "the", " ", "specifier", " ", "(", "NP", " ", "sib", "ling", ")", " ", "of", " ", "the", " ", "VP", ".", " ", "\\", "10", ";", " ", " ", " ", " ", "\\", "10", ";", " ", " ", " ", " ", "Parameter", "s", "\\", "10", ";", " ", " ", " ", " ", "-----------", "\\", "10", ";", " ", " ", " ", " ", "self", ":", " ", "Verb", "Phrase", " ", "object", " ", "tha", "t", " ", "call", "ed", " ", "the", " ", "method", "\\", "10", ";", " ", " ", " ", " ", "\\", "10", ";", " ", " ", " ", " ", "Return", "s", "\\", "10", ";", " ", " ", " ", " ", "-------", "\\", "10", ";", " ", " ", " ", " ", "self", ".", "upper", ":", " ", "List", " ", "\\", "10", ";", " ", " ", "Act", "or", " ", "codes", " ", "of", " ", "spec", "-", "VP", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "get", "\\u", "upper_", "=_", "self_", "._", "return", "\\u", "upper_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "child_", "in_", "self_", "._", "parent_", "._", "children_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "isinstance_", "(_", "child_", ",_", "Nou", "n", "Phrase", "_", ")_", "and_", "not_", "child_", "._", "get", "\\u", "meaning", "_", "(_", ")_", "==_", "[_", "\"~\"_", "]_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "upper_", "=_", "child_", "._", "get", "\\u", "meaning", "_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "return_", "self_", "._", "upper_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Verb", "Phrase", "_", "(_", "Phrase", "_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "return", "\\u", "lower_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "self_", "._", "lower_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Verb", "Phrase", "_", "(_", "Phrase", "_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "get", "\\u", "lower_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Fin", "d", " ", "the", " ", "meaning", " ", "of", " ", "the", " ", "child", "ren", " ", "of", " ", "the", " ", "VP", ",", " ", "and", " ", "whe", "ther", " ", "or", " ", "not", " ", "there", " ", "is", " ", "a", " ", "\"", "not", "\"", " ", "in", " ", "the", " ", "VP", ".", "\\", "10", ";", " ", " ", " ", " ", "\\", "10", ";", " ", " ", " ", " ", "If", " ", "the", " ", "VP", " ", "has", " ", "VP", " ", "child", "ren", ",", " ", "look", " ", "only", " ", "at", " ", "these", ".", "\\", "10", ";", " ", " ", " ", " ", "\\", "10", ";", " ", " ", " ", " ", "Ot", "her", "wis", "e", ",", " ", "this", " ", "function", " ", "pretty", " ", "muc", "h", " ", "is", " ", "identi", "cal", " ", "to", " ", "the", " ", "Nou", "n", "Phrase", ".", "get", "\\u", "meaning", "()", " ", "\\", "10", ";", " ", " ", " ", " ", "method", ",", " ", "except", " ", "tha", "t", " ", "it", " ", "doe", "sn", "'", "t", " ", "look", " ", "at", " ", "word", "-", "level", " ", "child", "ren", ",", " ", "bec", "aus", "e", " ", "it", " ", "shou", "ld", "n", "'", "t", "\\", "10", ";", " ", " ", " ", " ", "have", " ", "any", ".", " ", "\\", "10", ";", " ", " ", " ", " ", "\\", "10", ";", " ", " ", " ", " ", "Parameter", "s", "\\", "10", ";", " ", " ", " ", " ", "-----------", "\\", "10", ";", " ", " ", " ", " ", "self", ":", " ", "Verb", "Phrase", " ", "object", " ", "tha", "t", " ", "call", "ed", " ", "the", " ", "method", "\\", "10", ";", " ", " ", " ", " ", "\\", "10", ";", " ", " ", " ", " ", "Return", "s", "\\", "10", ";", " ", " ", " ", " ", "-------", "\\", "10", ";", " ", " ", " ", " ", "self", ".", "lower", ":", " ", "list", "\\", "10", ";", " ", " ", "Act", "or", " ", "codes", " ", "or", " ", "Event", " ", "codes", ",", " ", "depend", "ing", " ", "on", " ", "situation", "\\", "10", ";", " ", " ", " ", " ", "\\", "10", ";", " ", " ", " ", " ", "negate", "d", ":", " ", "boolean", "\\", "10", ";", " ", " ", " ", " ", " ", "Whe", "ther", " ", "a", " ", "\"", "not", "\"", " ", "is", " ", "presen", "t", "\\", "10", ";", " ", " ", " ", " ", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "get", "\\u", "lower_", "=_", "self_", "._", "return", "\\u", "lower_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "lower_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "v", "\\u", "options_", "=_", "filter_", "(_", "lambda_", "a_", ":_", "(_", "isinstance_", "(_", "a_", ",_", "Verb", "Phrase", "_", ")_", "and_", "a_", "._", "is", "\\u", "valid_", "(_", ")_", ")_", ",_", "self_", "._", "children_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "lower_", "=_", "map_", "(_", "lambda_", "a_", ":_", "a_", "._", "get", "\\u", "meaning", "_", "(_", ")_", ",_", "v", "\\u", "options_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "events_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "len_", "(_", "self_", "._", "children_", ")_", ">_", "1_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "negate", "d_", "=_", "(_", "lower_", "and_", "self_", "._", "children_", "[_", "1_", "]_", "._", "text_", ")_", "==_", "\"", "NOT", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "negate", "d_", "=_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "for_", "item_", "in_", "lower_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "negate", "d_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "adjusted", "_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "event_", "in_", "item_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "if_", "isinstance_", "(_", "event_", ",_", "tuple_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "adjusted", "_", "._", "append_", "(_", "(_", "event_", "[_", "0_", "]_", ",_", "event_", "[_", "1_", "]_", ",_", "event_", "[_", "2_", "]_", "-_", "0xFFFF", "_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "adjusted", "_", "._", "append_", "(_", "event_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "item_", "=_", "adjusted", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "events_", "+=_", "item_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "events_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "lower_", "=_", "events_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "events_", ",_", "negate", "d_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "NP", "codes_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "PP", "codes_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "VP", "codes_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "for_", "child_", "in_", "self_", "._", "children_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "isinstance_", "(_", "child_", ",_", "Nou", "n", "Phrase", "_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "NP", "codes_", "+=_", "child_", "._", "get", "\\u", "meaning", "_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "isinstance_", "(_", "child_", ",_", "Prep", "Phrase", "_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "PP", "codes_", "+=_", "(_", "child_", "._", "get", "\\u", "meaning", "_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "False_", "and_", "child_", "._", "label_", "in_", "\"", "SB", "AR", "\"_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "for_", "ch_", "in_", "(_", "child_", "._", "children_", "[_", "-_", "1_", "]_", "._", "children_", "if_", "child_", "._", "label_", "==_", "\"", "SB", "AR", "\"_", "else_", "child_", "._", "children_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "if_", "isinstance_", "(_", "ch_", ",_", "Nou", "n", "Phrase", "_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "Sco", "des_", "+=_", "ch_", "._", "get", "\\u", "meaning", "_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "isinstance_", "(_", "ch_", ",_", "Prep", "Phrase", "_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "Sco", "des_", "+=_", "ch_", "._", "get", "\\u", "meaning", "_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "isinstance_", "(_", "ch_", ",_", "Verb", "Phrase", "_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "Sco", "des_", "+=_", "ch_", "._", "get", "\\u", "meaning", "_", "(_", ")_", "[_", "1_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "actor", "codes_", ",_", "agent", "codes_", "=_", "(_", "[_", "]_", ",_", "[_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "NP", "actor_", ",_", "NP", "agent_", "=_", "self_", "._", "resolve", "\\u", "codes_", "(_", "NP", "codes_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "PP", "actor_", ",_", "PP", "agent_", "=_", "self_", "._", "resolve", "\\u", "codes_", "(_", "PP", "codes_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "VP", "actor_", ",_", "VP", "agent_", "=_", "self_", "._", "resolve", "\\u", "codes_", "(_", "VP", "codes_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "actor", "codes_", "+=_", "NP", "actor_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "not_", "actor", "codes_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "actor", "codes_", "+=_", "PP", "actor_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "not_", "actor", "codes_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "actor", "codes_", "+=_", "VP", "actor_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "agent", "codes_", "+=_", "NP", "agent_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "not_", "agent", "codes_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "agent", "codes_", "+=_", "PP", "agent_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "not_", "agent", "codes_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "agent", "codes_", "+=_", "VP", "agent_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "lower_", "=_", "self_", "._", "mix", "\\u", "codes_", "(_", "agent", "codes_", ",_", "actor", "codes_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "self_", "._", "lower_", ",_", "negate", "d_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Verb", "Phrase", "_", "(_", "Phrase", "_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "return", "\\u", "code_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "self_", "._", "code_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Verb", "Phrase", "_", "(_", "Phrase", "_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "get", "\\u", "code_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Match", " ", "the", " ", "codes", " ", "from", " ", "the", " ", "Verb", " ", "Dict", "ionar", "y", ".", "\\", "10", ";", " ", " ", " ", " ", "\\", "10", ";", " ", " ", " ", " ", "Step", " ", "1", ".", " ", " ", "Check", " ", "for", " ", "compo", "und", " ", "verb", " ", "matche", "s", "\\", "10", ";", " ", " ", " ", " ", "\\", "10", ";", " ", " ", " ", " ", "Step", " ", "2", ".", " ", " ", "Check", " ", "for", " ", "pattern", " ", "matche", "s", " ", "via", " ", "match", "\\u", "pattern", "()", " ", "method", "\\", "10", ";", " ", " ", " ", " ", "\\", "10", ";", " ", " ", " ", " ", "\\", "10", ";", " ", " ", " ", " ", "Parameter", "s", "\\", "10", ";", " ", " ", " ", " ", "-----------", "\\", "10", ";", " ", " ", " ", " ", "self", ":", " ", "Verb", "Phrase", " ", "object", " ", "tha", "t", " ", "call", "ed", " ", "the", " ", "method", "\\", "10", ";", " ", " ", " ", " ", "\\", "10", ";", " ", " ", " ", " ", "Return", "s", "\\", "10", ";", " ", " ", " ", " ", "-------", "\\", "10", ";", " ", " ", " ", " ", "code", ":", " ", " ", " ", "int", "\\", "10", ";", " ", " ", " ", " ", "Code", " ", "descri", "bed", " ", "by", " ", "this", " ", "verb", ",", " ", "best", " ", "read", " ", "in", " ", "hex", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "get", "\\u", "code_", "=_", "self_", "._", "return", "\\u", "code_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "meta_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "dict_", "=_", "PE", "TR", "globals_", "._", "Verb", "Dict_", "[_", "'", "verbs", "'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "'", "AND", "'_", "in_", "map_", "(_", "lambda_", "a_", ":_", "a_", "._", "text_", ",_", "self_", "._", "children_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "0_", ",_", "0_", ",_", "[_", "'", "and", "'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "patterns_", "=_", "PE", "TR", "globals_", "._", "Verb", "Dict_", "[_", "'", "phrase", "s", "'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "verb_", "=_", "\"", "TO", "\"_", "if_", "self_", "._", "children_", "[_", "0_", "]_", "._", "label_", "==_", "\"", "TO", "\"_", "else_", "self_", "._", "get", "\\u", "head_", "(_", ")_", "[_", "0_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "meta_", "._", "append_", "(_", "verb_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "meaning", "_", "=_", "\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "path_", "=_", "dict_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "passive", "_", "=_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "verb_", "in_", "dict_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "code_", "=_", "0_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "path_", "=_", "dict_", "[_", "verb_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "[_", "'#'_", "]_", "==_", "path_", "._", "keys_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "path_", "=_", "path_", "[_", "'#'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "True_", "or_", "path_", "._", "keys_", "(_", ")_", "==_", "[_", "'#'_", "]_", ":_", "#", " ", "Pre", "-", "compounds", " ", "are", " ", "weird", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "code_", "=_", "path_", "[_", "'#'_", "]_", "[_", "'", "code", "'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "meaning", "_", "=_", "path_", "[_", "'#'_", "]_", "[_", "'", "meaning", "'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "verb", "class_", "=_", "meaning", "_", "if_", "not_", "meaning", "_", "==_", "\"\"_", "else_", "verb_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "not_", "code_", "==_", "''_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "active_", ",_", "passive", "_", "=_", "utilities_", "._", "convert", "\\u", "code_", "(_", "code_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "code_", "=_", "active_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "self_", "._", "code_", "=_", "(_", "0_", ",_", "0_", ",_", "[_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Post", " ", "-", " ", "compounds", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "for_", "child_", "in_", "self_", "._", "children_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "if_", "child_", "._", "label_", "in_", "[_", "\"", "PR", "T", "\"_", ",_", "\"", "ADV", "P", "\"_", "]_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "if_", "child_", "._", "children_", "[_", "0_", "]_", "._", "text_", "in_", "path_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "meta_", "._", "append_", "(_", "child_", "._", "children_", "[_", "0_", "]_", "._", "text_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "path_", "=_", "path_", "[_", "child_", "._", "children_", "[_", "0_", "]_", "._", "text_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "\"#\"_", "in_", "path_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "code_", "=_", "path_", "[_", "'#'_", "]_", "[_", "'#'_", "]_", "[_", "'", "code", "'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "meaning", "_", "=_", "path_", "[_", "'#'_", "]_", "[_", "'#'_", "]_", "[_", "'", "meaning", "'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "verb", "class_", "=_", "meaning", "_", "if_", "not_", "meaning", "_", "==_", "\"\"_", "else_", "verb_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "not_", "code_", "==_", "''_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "active_", ",_", "passive", "_", "=_", "utilities_", "._", "convert", "\\u", "code_", "(_", "code_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "code_", "=_", "active_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "pass_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "--", " ", " ", "print", "('", "++", "1", "')", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "match_", "=_", "self_", "._", "match", "\\u", "pattern_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "--", " ", " ", "print", "('", "++", "2", "')", "_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "match_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "--", " ", " ", " ", " ", " ", " ", "print", "('", "++", "4", "',", "match", ")_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "--", " ", " ", " ", " ", " ", " ", "print", "('", "++", "3", "',", "match", "['", "line", "'])", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "meta_", "._", "append_", "(_", "match_", "[_", "'", "line", "'_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "--", " ", " ", " ", " ", " ", " ", "print", "(", "match", ")_", "\\u\\u\\uNL\\u\\u\\u_", "active_", ",_", "passive", "_", "=_", "utilities_", "._", "convert", "\\u", "code_", "(_", "match_", "[_", "'", "code", "'_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "code_", "=_", "active_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "passive", "_", "and_", "not_", "active_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "check", "\\u", "passive", "_", "=_", "lambda_", ":_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "code_", "=_", "passive", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "self_", "._", "code_", ",_", "passive", "_", ",_", "meta_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Verb", "Phrase", "_", "(_", "Phrase", "_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "match", "\\u", "transform_", "(_", "self_", ",_", "e_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Check", " ", "to", " ", "see", " ", "if", " ", "the", " ", "event", " ", "e", " ", "follow", "s", " ", "one", " ", "of", " ", "the", " ", "verb", " ", "transformation", " ", "pattern", "s", "\\", "10", ";", " ", " ", " ", " ", "specified", " ", "at", " ", "the", " ", "bottom", " ", "of", " ", "the", " ", "Verb", " ", "Dict", "ionar", "y", " ", "file", ".", "\\", "10", ";", " ", " ", " ", " ", "\\", "10", ";", " ", " ", " ", " ", "If", " ", "the", " ", "transformation", " ", "is", " ", "presen", "t", ",", " ", "adjust", " ", "the", " ", "event", " ", "according", "ly", ".", " ", "\\", "10", ";", " ", " ", " ", " ", "If", " ", "no", " ", "transformation", " ", "is", " ", "presen", "t", ",", " ", "check", " ", "if", " ", "the", " ", "event", " ", "is", " ", "of", " ", "the", " ", "form", ":", "\\", "10", ";", " ", " ", " ", " ", "\\", "10", ";", " ", " ", "a", " ", "(", " ", "b", " ", ".", " ", "Q", " ", ")", " ", "P", " ", ",", " ", "where", " ", "Q", " ", "is", " ", "not", " ", "a", " ", "top", "-", "level", " ", "verb", ".", " ", "\\", "10", ";", " ", " ", " ", "\\", "10", ";", " ", " ", " ", " ", "and", " ", "then", " ", "convert", " ", "this", " ", "to", " ", "(", " ", "a", " ", "b", " ", "P", "+", "Q", " ", ")", "\\", "10", ";", " ", " ", " ", " ", "\\", "10", ";", " ", " ", " ", " ", "Ot", "her", "wis", "e", ",", " ", "return", " ", "the", " ", "event", " ", "as", "-", "is", ".", "\\", "10", ";", " ", " ", " ", " ", "\\", "10", ";", " ", " ", " ", " ", "Parameter", "s", "\\", "10", ";", " ", " ", " ", " ", "-----------", "\\", "10", ";", " ", " ", " ", " ", "e", ":", " ", "tuple", "\\", "10", ";", " ", " ", " ", "Event", " ", "to", " ", "be", " ", "transforme", "d", "\\", "10", ";", " ", " ", " ", " ", "\\", "10", ";", " ", " ", " ", " ", "Return", "s", "\\", "10", ";", " ", " ", " ", " ", "-------", "\\", "10", ";", " ", " ", " ", " ", "t", ":", " ", "list", " ", "of", " ", "tuple", "s", "\\", "10", ";", " ", " ", " ", "List", " ", "of", " ", "modifi", "ed", " ", "events", ",", " ", "sinc", "e", " ", "multiple", " ", "events", " ", "can", " ", "come", " ", "from", " ", "one", " ", "single", " ", "event", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "recurse_", "(_", "pdict", "_", ",_", "event_", ",_", "a2", "v_", "=_", "{_", "}_", ",_", "v2", "a_", "=_", "{_", "}_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "path_", "=_", "pdict", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "isinstance_", "(_", "pdict", "_", ",_", "list_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "line_", "=_", "pdict", "_", "[_", "1_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "path_", "=_", "pdict", "_", "[_", "0_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "verb_", "=_", "utilities_", "._", "convert", "\\u", "code_", "(_", "path_", "[_", "2_", "]_", ")_", "[_", "0_", "]_", "if_", "not_", "path_", "[_", "2_", "]_", "==_", "\"", "Q", "\"_", "else_", "v2", "a_", "[_", "\"", "Q", "\"_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "isinstance_", "(_", "v2", "a_", "[_", "path_", "[_", "1_", "]_", "]_", ",_", "tuple_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "results_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "item_", "in_", "v2", "a_", "[_", "path_", "[_", "1_", "]_", "]_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "results_", "._", "append_", "(_", "(_", "list_", "(_", "v2", "a_", "[_", "path_", "[_", "0_", "]_", "]_", ")_", ",_", "item_", ",_", "verb_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "results_", ",_", "line_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "[_", "(_", "list_", "(_", "v2", "a_", "[_", "path_", "[_", "0_", "]_", "]_", ")_", ",_", "v2", "a_", "[_", "path_", "[_", "1_", "]_", "]_", ",_", "verb_", ")_", "]_", ",_", "line_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "isinstance_", "(_", "event_", ",_", "tuple_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "actor_", "=_", "None_", "if_", "not_", "event_", "[_", "0_", "]_", "else_", "tuple_", "(_", "event_", "[_", "0_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "masks_", "=_", "filter_", "(_", "lambda_", "a_", ":_", "a_", "in_", "pdict", "_", ",_", "[_", "event_", "[_", "2_", "]_", ",_", "event_", "[_", "2_", "]_", "-_", "event_", "[_", "2_", "]_", "%_", "0x10_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "event_", "[_", "2_", "]_", "-_", "event_", "[_", "2_", "]_", "%_", "0x100", "_", ",_", "event_", "[_", "2_", "]_", "-_", "event_", "[_", "2_", "]_", "%_", "0x1000", "_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "masks_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "path_", "=_", "pdict", "_", "[_", "masks_", "[_", "0_", "]_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "-_", "1_", "in_", "pdict", "_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "v2", "a_", "[_", "\"", "Q", "\"_", "]_", "=_", "event_", "[_", "2_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "path_", "=_", "pdict", "_", "[_", "-_", "1_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "return_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "actor_", "=_", "event_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "actor_", "in_", "a2", "v_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "actor_", "=_", "a2", "v_", "[_", "actor_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "not_", "actor_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "actor_", "=_", "\"\\u\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "actor_", "in_", "path_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "recurse_", "(_", "path_", "[_", "actor_", "]_", ",_", "event_", "[_", "1_", "]_", ",_", "a2", "v_", ",_", "v2", "a_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "not_", "actor_", "==_", "'\\u'_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "for_", "var_", "in_", "sorted_", "(_", "path_", "._", "keys_", "(_", ")_", ")_", "[_", ":_", ":_", "-_", "1_", "]_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "if_", "var_", "in_", "v2", "a_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "continue_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "not_", "var_", "==_", "'.'_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "v2", "a_", "[_", "var_", "]_", "=_", "actor_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "a2", "v_", "[_", "actor_", "]_", "=_", "var_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "recurse_", "(_", "path_", "[_", "var_", "]_", ",_", "event_", "[_", "1_", "]_", ",_", "a2", "v_", ",_", "v2", "a_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "t_", "=_", "recurse_", "(_", "PE", "TR", "globals_", "._", "Verb", "Dict_", "[_", "'", "transformation", "s", "'_", "]_", ",_", "e_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "t_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "t_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "e_", "[_", "0_", "]_", "and_", "e_", "[_", "2_", "]_", "and_", "isinstance_", "(_", "e_", "[_", "1_", "]_", ",_", "tuple_", ")_", "and_", "e_", "[_", "1_", "]_", "[_", "0_", "]_", "and_", "not_", "e_", "[_", "1_", "]_", "[_", "2_", "]_", "/_", "(_", "16_", "**_", "3_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "if_", "isinstance_", "(_", "e_", "[_", "1_", "]_", "[_", "0_", "]_", ",_", "list_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "results_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "item_", "in_", "e_", "[_", "1_", "]_", "[_", "0_", "]_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "event_", "=_", "(_", "e_", "[_", "0_", "]_", ",_", "item_", ",_", "utilities_", "._", "combin", "e\\u", "code_", "(_", "e_", "[_", "1_", "]_", "[_", "2_", "]_", ",_", "e_", "[_", "2_", "]_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "results_", "._", "append_", "(_", "event_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "results_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "event_", "=_", "(_", "e_", "[_", "0_", "]_", ",_", "e_", "[_", "1_", "]_", "[_", "0_", "]_", ",_", "utilities_", "._", "combin", "e\\u", "code_", "(_", "e_", "[_", "2_", "]_", ",_", "e_", "[_", "1_", "]_", "[_", "2_", "]_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "[_", "event_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "Exception_", "as_", "ex_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "pass_", "#", "print", "(", "ex", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "[_", "e_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Verb", "Phrase", "_", "(_", "Phrase", "_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "match", "\\u", "pattern_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", " ", "\\", "10", ";", " ", " ", " ", " ", "Match", " ", "the", " ", "tree", " ", "against", " ", "pattern", "s", " ", "specified", " ", "in", " ", "the", " ", "dictionar", "y", ".", " ", "For", " ", "a", " ", "more", " ", "illust", "rated", " ", "expl", "anat", "ion", "\\", "10", ";", " ", " ", " ", " ", "of", " ", "how", " ", "this", " ", "process", " ", "works", ",", " ", "see", " ", "the", " ", "Pet", "rar", "ch", "2", ".", "pdf", " ", "file", " ", "in", " ", "the", " ", "documentation", ".", " ", "\\", "10", ";", " ", " ", " ", " ", "\\", "10", ";", " ", " ", " ", " ", "\\", "10", ";", " ", " ", " ", " ", "Parameter", "s", "\\", "10", ";", " ", " ", " ", " ", "-----------", "\\", "10", ";", " ", " ", " ", " ", "self", ":", " ", "Verb", "Phrase", " ", "object", " ", "tha", "t", " ", "call", "ed", " ", "the", " ", "method", "\\", "10", ";", " ", " ", " ", " ", "\\", "10", ";", " ", " ", " ", " ", "Return", "s", "\\", "10", ";", " ", " ", " ", " ", "-------", "\\", "10", ";", " ", " ", " ", " ", "Fal", "se", " ", "if", " ", "no", " ", "match", ",", " ", "dict", " ", "of", " ", "match", " ", "if", " ", "presen", "t", ".", "\\", "10", ";", " ", " ", " ", " ", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "meaning", "_", "=_", "self_", "._", "verb", "class_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "code_", "=_", "self_", "._", "code_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "match", "\\u", "phrase_", "(_", "path_", ",_", "phrase_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Ha", "ving", " ", "matche", "d", " ", "the", " ", "head", " ", "of", " ", "the", " ", "phrase", ",", " ", "this", " ", "matche", "s", " ", "the", " ", "full", " ", "noun", " ", "phrase", ",", " ", "if", " ", "specified", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "--", " ", " ", " ", " ", " ", " ", "print", "('", "mph", "-", "entry", "')", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "not_", "phrase_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "--", " ", " ", " ", " ", " ", " ", "print", "('", "mph", "-", "Fal", "se", "')", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "for_", "item_", "in_", "filter_", "(_", "lambda_", "b_", ":_", "b_", "._", "text_", "in_", "path_", ",_", "phrase_", "._", "children_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "subpath_", "=_", "path_", "[_", "item_", "._", "text_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "--", " ", " ", " ", " ", " ", " ", "print", "('", "mph", "-", "rr", "-1", "')", "_", "\\u\\u\\uNL\\u\\u\\u_", "match_", "=_", "rer", "oute", "_", "(_", "subpath_", ",_", "lambda_", "a_", ":_", "match", "\\u", "phrase_", "(_", "a_", ",_", "item_", "._", "head", "\\u", "phrase_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "match_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "item_", "._", "color_", "=_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "match_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "--", " ", " ", " ", " ", " ", " ", "print", "('", "mph", "-", "rer", "oute", "')", " ", " _", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "rer", "oute", "_", "(_", "path_", ",_", "lambda_", "a_", ":_", "match", "\\u", "phrase_", "(_", "a_", ",_", "phrase_", "._", "head", "\\u", "phrase_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "match", "\\u", "noun", "_", "(_", "path_", ",_", "phrase_", "=_", "self_", "if_", "not_", "self_", "._", "check", "\\u", "passive", "_", "(_", ")_", "else_", "self_", "._", "get", "\\u", "S_", "(_", ")_", ",_", "prep", "limit_", "=_", "0_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Match", "es", " ", "a", " ", "noun", " ", "or", " ", "head", " ", "of", " ", "noun", " ", "phrase_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "--", " ", " ", " ", " ", " ", " ", "print", "('", "mn", "-", "entry", "')", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "noun", "\\u", "phrases_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "not_", "phrase_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "prep", "limit_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "for_", "sib", "_", "in_", "phrase_", "._", "children_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "if_", "isinstance_", "(_", "sib", "_", ",_", "Prep", "Phrase", "_", ")_", "and_", "len_", "(_", "sib", "_", "._", "children_", ")_", ">_", "1_", "and_", "sib", "_", "._", "get", "\\u", "prep_", "(_", ")_", "in_", "[_", "\"", "BY", "\"_", ",_", "\"", "FROM", "\"_", "]_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "noun", "\\u", "phrases_", "._", "append_", "(_", "sib", "_", "._", "children_", "[_", "1_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "for_", "child_", "in_", "phrase_", "._", "children_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "if_", "child_", "._", "label_", "in_", "(_", "\"", "NP", "\"_", ",_", "\"", "ADV", "P", "\"_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "noun", "\\u", "phrases_", "._", "append_", "(_", "child_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "isinstance_", "(_", "phrase_", ",_", "Nou", "n", "Phrase", "_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "noun", "\\u", "phrases_", "._", "append_", "(_", "phrase_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "for_", "item_", "in_", "noun", "\\u", "phrases_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "head_", ",_", "head", "phrase_", "=_", "item_", "._", "get", "\\u", "head_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "head_", "and_", "head_", "in_", "path_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "subpath_", "=_", "path_", "[_", "head_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Fi", "rst", " ", "check", " ", "within", " ", "the", " ", "NP", " ", "for", " ", "PP", "'", "s_", "\\u\\u\\uNL\\u\\u\\u_", "skip_", "=_", "lambda_", "a_", ":_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "match_", "=_", "rer", "oute", "_", "(_", "subpath_", ",_", "skip_", ",_", "skip_", ",_", "lambda_", "a_", ":_", "match", "\\u", "prep_", "(_", "a_", ",_", "item_", ")_", ",_", "skip_", ",_", "0_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "match_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "head", "phrase_", "._", "children_", "[_", "-_", "1_", "]_", "._", "color_", "=_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "match_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "The", "n", " ", "check", " ", "the", " ", "other", " ", "siblings", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "match_", "=_", "rer", "oute", "_", "(_", "subpath_", ",_", "(_", "lambda_", "a_", ":_", "match", "\\u", "phrase_", "(_", "a_", ",_", "item_", "._", "head", "\\u", "phrase_", ")_", ")_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "isinstance_", "(_", "item_", ",_", "Nou", "n", "Phrase", "_", ")_", "else_", "None_", ")_", "#", " ", "pas", " ", "16.", "04", ".2", "1", ":", " ", "Tra", "pped", " ", "Non", "e", " ", "by", " ", "hav", "ing", " ", "rer", "oute", " ", "return", " ", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "match_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "head", "phrase_", "._", "children_", "[_", "-_", "1_", "]_", "._", "color_", "=_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "match_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "'", "^", "'_", "in_", "path_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "phrase_", "._", "color_", "=_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "--", " ", " ", " ", " ", " ", " ", "print", "('", "mn", "-", "rer", "oute", "1", "')", "_", "\\u\\u\\uNL\\u\\u\\u_", "return_", "rer", "oute", "_", "(_", "path_", "[_", "'", "^", "'_", "]_", ",_", "lambda_", "a_", ":_", "match", "\\u", "phrase_", "(_", "a_", ",_", "phrase_", "._", "head", "\\u", "phrase_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "--", " ", " ", " ", " ", " ", " ", "print", "('", "mn", "-", "rer", "oute", "2", "')", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "rer", "oute", "_", "(_", "path_", ",_", "lambda_", "a_", ":_", "match", "\\u", "phrase_", "(_", "a_", ",_", "phrase_", "._", "head", "\\u", "phrase_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "match", "\\u", "prep_", "(_", "path_", ",_", "phrase_", "=_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Match", "es", " ", "prepo", "sition", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "--", " ", " ", " ", " ", " ", " ", "print", "('", "mp", "-", "entry", "')", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "for_", "item_", "in_", "filter_", "(_", "lambda_", "b_", ":_", "isinstance_", "(_", "b_", ",_", "Prep", "Phrase", "_", ")_", ",_", "phrase_", "._", "children_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "prep_", "=_", "item_", "._", "children_", "[_", "0_", "]_", "._", "text_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "prep_", "in_", "path_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "subpath_", "=_", "path_", "[_", "prep_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "--", " ", " ", " ", " ", "print", "('", "mp", "-", "rer", "oute", "1", "')", " ", " _", "\\u\\u\\uNL\\u\\u\\u_", "match_", "=_", "rer", "oute", "_", "(_", "subpath_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "lambda_", "a_", ":_", "match", "\\u", "noun", "_", "(_", "a_", ",_", "item_", "._", "children_", "[_", "1_", "]_", ")_", "if_", "len_", "(_", "item_", "._", "children_", ")_", ">_", "1_", "else_", "False_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "match", "\\u", "prep_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "match_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "--", " ", " ", "print", "('", "mp", "-", "Fal", "se", "')", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "return_", "match_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "--", " ", " ", " ", " ", " ", " ", "print", "('", "mp", "-", "rer", "oute", "2", "')", " ", " _", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "rer", "oute", "_", "(_", "path_", ",_", "o2_", "=_", "match", "\\u", "prep_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "rer", "oute", "_", "(_", "subpath_", ",_", "o1_", "=_", "match", "\\u", "noun", "_", ",_", "o2_", "=_", "match", "\\u", "noun", "_", ",_", "o3", "_", "=_", "match", "\\u", "prep_", ",_", "o", "4_", "=_", "match", "\\u", "noun", "_", ",_", "exit_", "=_", "1_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "--", " ", " ", " ", " ", " ", " ", "print", "('", "rr", "-", "entry", ":'", ")", " ", "#", " ", ",", "subpath_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "not_", "o1_", ":_", "#", " ", "match", "\\u", "noun", "()", " ", "can", " ", "call", " ", "rer", "oute", "()", " ", "with", " ", "o", "1", " ", "==", " ", "Non", "e", ";", " ", "guess", "ing", " ", "return", "ing", " ", "Fal", "se", " ", "is", " ", "the", " ", "appropr", "iate", " ", "response", " ", "pas", " ", "16.", "04", ".2", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "return_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "'-'_", "in_", "subpath_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "match_", "=_", "o1_", "(_", "subpath_", "[_", "'-'_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "match_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "--", " ", " ", " ", " ", "print", "('", "rr", "--", " ", "match", "')", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "return_", "match_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "','_", "in_", "subpath_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "--", " ", " ", " ", " ", "print", "('", "rr", "-", ",'", ")_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "match_", "=_", "o2_", "(_", "subpath_", "[_", "','_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "match_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "return_", "match_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "'|'_", "in_", "subpath_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "--", " ", " ", " ", " ", "print", "('", "rr", "-|", "')", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "match_", "=_", "o3", "_", "(_", "subpath_", "[_", "'|'_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "match_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "return_", "match_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "'*'_", "in_", "subpath_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "--", " ", " ", " ", " ", "print", "('", "rr", "-*", "')", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "match_", "=_", "o", "4_", "(_", "subpath_", "[_", "'*'_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "match_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "return_", "match_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "'#'_", "in_", "subpath_", "and_", "exit_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "--", " ", " ", " ", " ", "print", "('", "rr", "-", "#'", ")_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "return_", "subpath_", "[_", "'#'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "--", " ", " ", " ", " ", " ", " ", "print", "('", "rr", "-", "Fal", "se", "')", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Match", " ", "pattern_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "meaning", "_", "in_", "PE", "TR", "globals_", "._", "Verb", "Dict_", "[_", "'", "phrase", "s", "'_", "]_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "path_", "=_", "PE", "TR", "globals_", "._", "Verb", "Dict_", "[_", "'", "phrase", "s", "'_", "]_", "[_", "meaning", "_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "self_", "._", "check", "\\u", "passive", "_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "match", "\\u", "noun", "_", "(_", "path_", ",_", "self_", ",_", "1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "match", "\\u", "noun", "_", "(_", "path_", ",_", "self_", "._", "get", "\\u", "S_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "class_", "Sentence", "_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Hold", "s", " ", "the", " ", "informati", "on", " ", "of", " ", "a", " ", "sentence", " ", "and", " ", "its", " ", "tree", ".", "\\", "10", ";", " ", " ", " ", " ", "\\", "10", ";", " ", " ", " ", " ", "Meth", "ods", "\\", "10", ";", " ", " ", " ", " ", "-------", "\\", "10", ";", " ", " ", " ", " ", "\\", "10", ";", " ", " ", " ", " ", "\\u\\u", "init", "\\u\\u", " ", ":", " ", "Initializ", "ation", " ", "and", " ", "instantiation", "\\", "10", ";", " ", " ", " ", " ", "\\", "10", ";", " ", " ", " ", " ", "str", "\\u", "to", "\\u", "tree", ":", " ", "Read", "s", " ", "Core", "NL", "P", " ", "parse", " ", "int", "o", " ", "memory", "\\", "10", ";", " ", " ", " ", " ", "\\", "10", ";", " ", " ", " ", " ", "get", "\\u", "events", ":", " ", "Extract", "s", " ", "events", " ", "from", " ", "sentence", " ", "tree", "\\", "10", ";", " ", " ", " ", " ", "\\", "10", ";", " ", " ", " ", " ", "print", "\\u", "tree", ":", " ", "Print", "s", " ", "tree", " ", "to", " ", "a", " ", "La", "Te", "X", " ", "file", "\\", "10", ";", " ", " ", " ", " ", "\\", "10", ";", " ", " ", " ", " ", "\\", "10", ";", " ", " ", " ", " ", "\\", "10", ";", " ", " ", " ", " ", "\\", "10", ";", " ", " ", " ", " ", "Meta", "data", "\\", "10", ";", " ", " ", " ", " ", "--------", "\\", "10", ";", " ", " ", " ", " ", "\\", "10", ";", " ", " ", " ", " ", "The", " ", "sentence", " ", "will", " ", "return", " ", "with", " ", "a", " ", "\"", "metadata", "\"", " ", "dict", ".", " ", "Thi", "s", " ", "has", " ", "two", " ", "part", "s", ".", "\\", "10", ";", " ", " ", " ", " ", "\\", "10", ";", " ", " ", " ", " ", "-", " ", "sent", ".", "metadata", "['", "noun", "s", "']", " ", "will", " ", "be", " ", "a", " ", "list", " ", "of", " ", "pair", "s", " ", "of", " ", "the", " ", "form", "\\", "10", ";", " ", " ", " ", " ", "\\", "10", ";", " ", " ", "(", " ", "[", "Word", "s", " ", "tha", "t", " ", "wer", "e", " ", "code", "d", "],", " ", "[", "Code", "s", " ", "produce", "d", "])", "\\", "10", ";", " ", " ", " ", " ", "\\", "10", ";", " ", " ", " ", " ", "Ea", "ch", " ", "list", " ", "in", " ", "the", " ", "tuple", " ", "usual", "ly", " ", "only", " ", "has", " ", "one", " ", "element", ",", " ", "but", " ", "somet", "imes", " ", "multiple", " ", "can", " ", "occur", "\\", "10", ";", " ", " ", " ", " ", "\\", "10", ";", " ", " ", " ", " ", "-", " ", "The", " ", "other", " ", "element", "s", " ", "of", " ", "sent", ".", "metadata", " ", "have", " ", "the", " ", "key", " ", "as", " ", "the", " ", "event", ",", " ", "and", "\\", "10", ";", " ", " ", " ", " ", "the", " ", "value", " ", "as", " ", "a", " ", "list", " ", "of", " ", "lists", ".", " ", "Ea", "ch", " ", "element", " ", "of", " ", "the", " ", "value", " ", "list", " ", "contain", "s", "\\", "10", ";", " ", " ", " ", " ", "some", " ", "informati", "on", " ", "abo", "ut", " ", "verbs", " ", "tha", "t", " ", "combin", "ed", " ", "to", " ", "form", " ", "tha", "t", " ", "event", ".", " ", "The", " ", "first", "\\", "10", ";", " ", " ", " ", " ", "element", " ", "usual", "ly", " ", "contain", "s", " ", "the", " ", "primary", " ", "verb", " ", "and", " ", "pattern", " ", "tha", "t", " ", "was", " ", "matche", "d", " ", "on", ",", " ", "and", " ", "the", " ", "latt", "er", "\\", "10", ";", " ", " ", " ", " ", "element", "s", " ", "are", " ", "help", "ing", " ", "verbs", " ", "tha", "t", " ", "wer", "e", " ", "combin", "ed", " ", "with", " ", "it", ".", "\\", "10", ";", " ", " ", " ", " ", "\\", "10", ";", " ", " ", " ", " ", "\\", "10", ";", " ", " ", " ", " ", "For", " ", "example", ",", " ", "the", " ", "metadata", " ", "for", " ", "the", " ", "sentence", " ", "\\", "10", ";", " ", " ", " ", " ", "\\", "10", ";", " ", " ", " ", " ", " ", "BO", "KO", " ", "HAR", "AM", " ", "HAS", " ", "LAUN", "CHE", "D", " ", "MAN", "Y", " ", "SIM", "ILA", "R", " ", "ATTA", "CK", "S", " ", "DU", "RING", " ", "IT", "S", " ", "SI", "X", "-", "YEA", "R", " ", "CAM", "PAI", "GN", " ", "FOR", " ", "A", " ", "STRI", "CT", " ", "IS", "LAM", "IC", " ", "STATE", " ", "IN", " ", "NOR", "THE", "AST", "ERN", " ", "NI", "GER", "IA", " ", ".", "\\", "10", ";", " ", " ", " ", " ", " ", "\\", "10", ";", " ", " ", " ", " ", " ", "\\", "10", ";", " ", " ", " ", " ", "Look", "s", " ", "like", ":", "\\", "10", ";", " ", " ", " ", " ", "\\", "10", ";", " ", " ", " ", " ", " ", "{", "\\", "10", ";", " ", " ", " ", " ", "(", "u", "'", "NG", "ARE", "B", "',", " ", "u", "'", "NG", "AM", "US", "',", " ", "u", "'", "190", "')", ":", " ", "[[", "u", "'", "LAUN", "CHE", "D", "',", " ", "'-", " ", "*", " ", "ATTA", "CK", "S", " ", "[", "190", "]'", "],", "\\", "10", ";", " ", " ", " ", " ", " ", "[", "u", "'", "HAS", "']]", ",", "\\", "10", ";", " ", " ", " ", " ", "\\", "10", ";", " ", " ", " ", " ", "u", "'", "noun", "s", "':", " ", " ", "[(", "[", "u", "'", "BO", "KO", " ", "HAR", "AM", "']", ",", " ", "[", "u", "'", "NG", "ARE", "B", "'])", ",", "\\", "10", ";", " ", " ", " ", " ", " ", " ", "([", "u", "'", "NI", "GER", "IA", "']", ",", " ", "[", "u", "'", "NG", "A", "'])", ",", "\\", "10", ";", " ", " ", " ", " ", " ", " ", "([", "u", "'", "IS", "LAM", "IC", "']", ",", " ", "[", "u", "'", "NG", "AM", "US", "'])", "]}", "\\", "10", ";", " ", " ", " ", " ", " ", "}", "\\", "10", ";", " ", " ", " ", " ", "\\", "10", ";", " ", " ", " ", " ", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "'''", "def", " ", "print", "\\u", "to", "\\u", "file", "(", "self", ",", "root", ",", "file", " ", "=", " ", "\"\"", "):", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"", "Print", "s", " ", "a", " ", "La", "Te", "X", " ", "represent", "ation", " ", "of", " ", "the", " ", "tree", " ", "to", " ", "a", " ", "file", ",", " ", "calls", " ", "the", " ", "recurs", "ive", " ", "method", "\\", "10", ";", " ", " ", " ", " ", "print", "\\u", "tree", "()", " ", "on", " ", "the", " ", "tree", " ", "to", " ", "print", " ", "all", " ", "of", " ", "it", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "print", "(\"", "\"\"", " ", " ", " ", "\\", "10", ";", " ", " ", "\\\\\\\\", "resiz", "ebo", "x", "{\\\\", "\\\\", "text", "widt", "h", "}{", "250", "pt", "}{", "%\\", "10", ";", " ", " ", "\\\\\\\\", "begin", "{", "tik", "zp", "ict", "ure", "}", "\\", "10", ";", " ", " ", "\\\\\\\\", "Tree", "\"\"\"", ",", " ", "file", "=", "file", ",", " ", "end", "=\"", " ", "\")", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "self", ".", "print", "\\u", "tree", "(", "root", ",", " ", "\"\"", ",", " ", "file", ")", "\\", "10", ";", " ", " ", " ", " ", "print", "(\"", "\\\\\\\\", "end", "{", "tik", "zp", "ict", "ure", "}}\\", "\\", "n", "\\\\", "n", "\",", " ", "file", "=", "file", ")", "\\", "10", ";", " ", " ", " ", " ", "print", "(\"", "EVENTS", ":", " ", "\",", "self", ".", "get", "\\u", "events", "()", ",", " ", "file", " ", "=", " ", "file", ")", "\\", "10", ";", " ", " ", " ", " ", "print", "(\"", "\\\\\\\\\\\\\\\\", "\\\\", "n", "TEXT", ":", " ", "\",", " ", "self", ".", "txt", ",", " ", "file", "=", "file", ")", "\\", "10", ";", " ", " ", " ", " ", "print", "(\"", "\\\\\\\\", "newpa", "ge", "\",", "file", "=", "file", ")'''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "[SEP]_", "class_", "Sentence", "_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "\\u\\u", "init\\u\\u_", "(_", "self_", ",_", "parse_", ",_", "text_", ",_", "date_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "trees", "tr_", "=_", "parse_", "._", "replace_", "(_", "')'_", ",_", "'", " ", ")'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "parse_", "=_", "parse_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "agent_", "=_", "\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "ID_", "=_", "-_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "actor_", "=_", "\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "date_", "=_", "date_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "long", "lat_", "=_", "(_", "-_", "1_", ",_", "-_", "1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "verbs", "_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "txt_", "=_", "\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "tree_", "=_", "self_", "._", "str", "\\u", "to", "\\u", "tree_", "(_", "parse_", "._", "strip_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "verb", "\\u", "analysis_", "=_", "{_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "events_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "metadata_", "=_", "{_", "'", "noun", "s", "'_", ":_", "[_", "]_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Sentence", "_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "str", "\\u", "to", "\\u", "tree_", "(_", "self_", ",_", "str_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Tak", "e", " ", "the", " ", "Stan", "for", "d", " ", "Core", "NL", "P", " ", "parse", " ", "and", " ", "convert", " ", "it", " ", "to", " ", "an", " ", "object", "/", "point", "er", " ", "tree", ".", "\\", "10", ";", " ", " ", " ", " ", "\\", "10", ";", " ", " ", " ", " ", "Parameter", "s", "\\", "10", ";", " ", " ", " ", " ", "-----------", "\\", "10", ";", " ", " ", " ", " ", "str", ":", " ", "string", " ", "\\", "10", ";", " ", " ", " ", " ", " ", "Pre", "-", "process", "ed", " ", "Core", "NL", "P", " ", "parse", ",", " ", "need", "s", " ", "to", " ", "be", " ", "formate", "d", " ", "by", " ", "util", "iti", "es", ".", "format\\u", "parsed", "\\u", "str", "\\", "10", ";", " ", " ", " ", " ", " ", "bef", "ore", " ", "bei", "ng", " ", "pass", "ed", ".", "\\", "10", ";", " ", " ", " ", " ", "\\", "10", ";", " ", " ", " ", " ", "Return", "s", "\\", "10", ";", " ", " ", " ", " ", "-------", "\\", "10", ";", " ", " ", " ", " ", "root", ":", " ", "Phrase", " ", "object", "\\", "10", ";", " ", " ", " ", " ", " ", " ", "Top", " ", "level", " ", "of", " ", "the", " ", "tree", " ", "tha", "t", " ", "represent", "s", " ", "the", " ", "sentence", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "segs_", "=_", "str_", "._", "split_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "root_", "=_", "Phrase", "_", "(_", "segs_", "[_", "0_", "]_", "[_", "1_", ":_", "]_", ",_", "self_", "._", "date_", ",_", "self_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "level", "\\u", "stack_", "=_", "[_", "root_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "existen", "tial", "s_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "for_", "element_", "in_", "segs_", "[_", "1_", ":_", "]_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "element_", "._", "startswith_", "(_", "\"(\"_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "lab_", "=_", "element_", "[_", "1_", ":_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "lab_", "==_", "\"", "NP", "\"_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "new_", "=_", "Nou", "n", "Phrase", "_", "(_", "lab_", ",_", "self_", "._", "date_", ",_", "self_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "lab_", "==_", "\"", "VP", "\"_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "new_", "=_", "Verb", "Phrase", "_", "(_", "lab_", ",_", "self_", "._", "date_", ",_", "self_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "verbs", "_", "._", "append_", "(_", "new_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "lab_", "==_", "\"", "PP", "\"_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "new_", "=_", "Prep", "Phrase", "_", "(_", "lab_", ",_", "self_", "._", "date_", ",_", "self_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "new_", "=_", "Phrase", "_", "(_", "lab_", ",_", "self_", "._", "date_", ",_", "self_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "lab_", "==_", "\"", "EX", "\"_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "existen", "tial", "s_", "._", "append_", "(_", "new_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "new_", "._", "parent_", "=_", "level", "\\u", "stack_", "[_", "-_", "1_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "new_", "._", "index_", "=_", "len_", "(_", "level", "\\u", "stack_", "[_", "-_", "1_", "]_", "._", "children_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "level", "\\u", "stack_", "[_", "-_", "1_", "]_", "._", "children_", "._", "append_", "(_", "new_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "level", "\\u", "stack_", "._", "append_", "(_", "new_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "element_", "._", "endswith_", "(_", "\")\"_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "level", "\\u", "stack_", "._", "pop_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "break_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "level", "\\u", "stack_", "[_", "-_", "1_", "]_", "._", "text_", "=_", "element_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "txt_", "+=_", "\"", " ", "\"_", "+_", "element_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "for_", "element_", "in_", "existen", "tial", "s_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "element_", "._", "parent_", "._", "convert", "\\u", "existen", "tial", "_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "pass_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "root_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Sentence", "_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "print", "\\u", "noun", "s_", "(_", "self_", ",_", "label_", ")_", ":_", "#", " ", "--", " _", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", " ", "Deb", "ugg", "ing", " ", "print", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "print_", "(_", "label_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "la_", "in_", "self_", "._", "metadata_", "[_", "'", "noun", "s", "'_", "]_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "print_", "(_", "'", " ", " ", " ", " ", "'_", ",_", "la_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Sentence", "_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "get", "\\u", "metadata_", "(_", "self_", ",_", "entry_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "metad", "ict_", "=_", "self_", "._", "metadata_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "next_", "=_", "entry_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "store_", "=_", "\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "meta", "\\u", "total_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "while_", "id_", "(_", "next_", ")_", "in_", "metad", "ict_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "store_", "=_", "metad", "ict_", "[_", "id_", "(_", "next_", ")_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "meta", "\\u", "total_", "._", "append_", "(_", "store_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "next_", "=_", "store_", "[_", "0_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", "if", " ", "not", " ", "meta", "\\u", "total", ":_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", " ", " ", " ", "print", "(", "entry", ",", "self", ".", "txt", ")_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", " ", " ", " ", "exit", "()", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "map_", "(_", "lambda_", "a_", ":_", "a_", "[_", "-_", "2_", "]_", "if_", "len_", "(_", "a_", ")_", ">_", "1_", "else_", "a_", "[_", "0_", "]_", ",_", "meta", "\\u", "total_", "[_", ":_", ":_", "-_", "1_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Sentence", "_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "return", "\\u", "events_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "self_", "._", "events_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Sentence", "_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "get", "\\u", "events_", "(_", "self_", ",_", "require", "\\u", "dy", "ad_", "=_", "1_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Tak", "e", " ", "the", " ", "codi", "ng", " ", "of", " ", "the", " ", "high", "est", " ", "verb", " ", "phrase", " ", "and", " ", "return", " ", "tha", "t", ",", " ", "give", "n", ":", "\\", "10", ";", " ", " ", " ", " ", "1", ")", " ", "Target", " ", "and", " ", "source", " ", "are", " ", "bot", "h", " ", "presen", "t", "\\", "10", ";", " ", " ", " ", " ", "2", ")", " ", "Code", " ", "is", " ", "non", "-", "zero", "\\", "10", ";", " ", " ", " ", " ", "3", ")", " ", "Target", " ", "isn", "'", "t", " ", "anot", "her", " ", "event", "\\", "10", ";", " ", " ", " ", " ", "\\", "10", ";", " ", " ", " ", " ", "Parameter", "s", "\\", "10", ";", " ", " ", " ", " ", "-----------", "\\", "10", ";", " ", " ", " ", " ", "self", ":", " ", "Sentence", " ", "object", " ", "calling", " ", "the", " ", "method", "\\", "10", ";", " ", " ", " ", " ", "\\", "10", ";", " ", " ", " ", " ", "Return", "s", "\\", "10", ";", " ", " ", " ", " ", "-------", "\\", "10", ";", " ", " ", " ", " ", "valid", ":", " ", "list", "\\", "10", ";", " ", " ", " ", "List", " ", "of", " ", "code", "d", " ", "events", " ", "tha", "t", " ", "satisfy", " ", "the", " ", "above", " ", "condition", "s", ",", " ", "of", " ", "form", "\\", "10", ";", " ", " ", " ", "(", "source", ",", " ", "target", ",", " ", "code", ")", " ", "where", " ", "the", " ", "code", " ", "has", " ", "bee", "n", " ", "convert", "ed", " ", "from", " ", "an", " ", "int", "\\", "10", ";", " ", " ", " ", "back", " ", "int", "o", " ", "CAM", "EO", "\\", "10", ";", " ", " ", " ", " ", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "events_", "=_", "map_", "(_", "lambda_", "a_", ":_", "a_", "._", "get", "\\u", "meaning", "_", "(_", ")_", ",_", "filter_", "(_", "lambda_", "b_", ":_", "b_", "._", "label_", "in_", "\"", "SV", "P", "\"_", ",_", "self_", "._", "tree_", "._", "children_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "meta_", "=_", "{_", "'", "noun", "s", "'_", ":_", "self_", "._", "metadata_", "[_", "'", "noun", "s", "'_", "]_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\"\"\"", "print", "('", "GF", "1", "',", "events", ")", " ", "#", " ", "--", " ", " ", "\\", "10", ";", "#", " ", "--", " ", " ", " ", " ", "print", "('", "GF", "2", "',", "meta", ")", " ", "#", " ", "--", " ", " ", "\\", "10", ";", " ", " ", " ", " ", "self", ".", "print", "\\u", "noun", "s", "('", "GF", "2", "')", " ", "#", " ", "--", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "valid_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "for_", "sent_", "in_", "events_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "for_", "event_", "in_", "sent_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "if_", "event_", "[_", "1_", "]_", "==_", "'", "passive", "'_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "event_", "=_", "(_", "event_", "[_", "0_", "]_", ",_", "None_", ",_", "event_", "[_", "2_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "isinstance_", "(_", "event_", ",_", "tuple_", ")_", "and_", "isinstance_", "(_", "event_", "[_", "1_", "]_", ",_", "basestring_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "code_", "=_", "utilities_", "._", "convert", "\\u", "code_", "(_", "event_", "[_", "2_", "]_", ",_", "0_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "print_", "(_", "'", "checking", " ", "event", "'_", ",_", "event_", ",_", "hex_", "(_", "event_", "[_", "2_", "]_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "event_", "[_", "0_", "]_", "and_", "event_", "[_", "1_", "]_", "and_", "code_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "for_", "source_", "in_", "event_", "[_", "0_", "]_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "valid_", "._", "append_", "(_", "(_", "source_", "._", "replace_", "(_", "'~'_", ",_", "'---", "'_", ")_", ",_", "event_", "[_", "1_", "]_", "._", "replace_", "(_", "'~'_", ",_", "'---", "'_", ")_", ",_", "code_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "meta_", "[_", "(_", "source_", "._", "replace_", "(_", "'~'_", ",_", "'---", "'_", ")_", ",_", "event_", "[_", "1_", "]_", "._", "replace_", "(_", "'~'_", ",_", "'---", "'_", ")_", ",_", "code_", ")_", "]_", "=_", "self_", "._", "get", "\\u", "metadata_", "(_", "event_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "(_", "not_", "require", "\\u", "dy", "ad_", ")_", "and_", "event_", "[_", "0_", "]_", "and_", "code_", "and_", "not_", "event_", "[_", "1_", "]_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "for_", "source_", "in_", "event_", "[_", "0_", "]_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "valid_", "._", "append_", "(_", "(_", "source_", "._", "replace_", "(_", "'~'_", ",_", "'---", "'_", ")_", ",_", "\"--", "-\"_", ",_", "code_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "(_", "not_", "require", "\\u", "dy", "ad_", ")_", "and_", "event_", "[_", "1_", "]_", "and_", "code_", "and_", "not_", "event_", "[_", "0_", "]_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "valid_", "._", "append_", "(_", "(_", "\"--", "-\"_", ",_", "event_", "[_", "1_", "]_", "._", "replace_", "(_", "'~'_", ",_", "'---", "'_", ")_", ",_", "code_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "If", " ", "there", " ", "are", " ", "multiple", " ", "actors", " ", "in", " ", "a", " ", "coop", "eratio", "n", " ", "scen", "ario", ",", " ", "code", " ", "thei", "r", " ", "coop", "eratio", "n", " ", "as", " ", "well_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "len_", "(_", "event_", "[_", "0_", "]_", ")_", ">_", "1_", "and_", "(_", "not_", "event_", "[_", "1_", "]_", ")_", "and_", "code_", "and_", "code_", "[_", ":_", "2_", "]_", "in_", "[_", "\"", "03", "\"_", ",_", "\"", "04", "\"_", ",_", "\"", "05", "\"_", ",_", "\"", "0", "6", "\"_", "]_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "for_", "source_", "in_", "event_", "[_", "0_", "]_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "for_", "target_", "in_", "event_", "[_", "0_", "]_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "if_", "not_", "source_", "==_", "target_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " ", " _", "valid_", "._", "append_", "(_", "(_", "source_", "._", "replace_", "(_", "'~'_", ",_", "'---", "'_", ")_", ",_", "target_", "._", "replace_", "(_", "'~'_", ",_", "'---", "'_", ")_", ",_", "code_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "events_", "=_", "list_", "(_", "set_", "(_", "valid_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "get", "\\u", "events_", "=_", "self_", "._", "return", "\\u", "events_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "--", " ", " ", " ", " ", "print", "('", "GF", "3", "',", "valid", ",'", "\\\\", "n", "GF", "4", "',", "meta", ")", " ", "#", " ", "--", " _", "\\u\\u\\uNL\\u\\u\\u_", "return_", "valid_", ",_", "meta_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "Exception_", "as_", "e_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "print_", "(_", "\"", "Error", " ", "in", " ", "pars", "ing", ":\"_", ",_", "e_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "None_", ",_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Sentence", "_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "print", "\\u", "to", "\\u", "file_", "(_", "self_", ",_", "root_", ",_", "file_", "=_", "\"\"_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Simplif", "ied", " ", "version", " ", "of", " ", "the", " ", "above", " ", "for", " ", "GF", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "print_", "(_", "\"", "EVENTS", ":", " ", "\"_", ",_", "self_", "._", "get", "\\u", "events_", "(_", ")_", ",_", "file_", "=_", "file_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "txt", "str", "g_", "=_", "self_", "._", "txt_", "._", "encode_", "(_", "'", "ascii", "'_", ",_", "'", "ignore", "'_", ")_", "._", "decode_", "(_", "'", "ascii", "'_", ")_", "#", " ", "<", "16.", "03", ".2", "9", ">", " ", "For", " ", "now", ",", " ", "just", " ", "zap", " ", "the", " ", "unicode_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "print_", "(_", "\"", "TEXT", ":", " ", "\"_", ",_", "txt", "str", "g_", ",_", "file_", "=_", "file_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Sentence", "_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "print", "\\u", "tree_", "(_", "self_", ",_", "root_", ",_", "indent_", "=_", "\"\"_", ",_", "f_", "=_", "\"\"_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Thi", "s", " ", "print", "s", " ", "a", " ", "La", "Te", "X", " ", "format", "ted", " ", "document", " ", "of", " ", "the", " ", "tree", ".", " ", "Calls", " ", "on", " ", "each", " ", "of", " ", "the", " ", "child", "ren", " ", "as", " ", "well", ".", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "print_", "(_", "\"[", ".\"_", "+_", "root_", "._", "label_", "._", "replace_", "(_", "\"$\"_", ",_", "\"\"_", ")_", ",_", "(_", "\"{\\\\", "\\\\", "bf", " ", "\"_", "+_", "root_", "._", "text_", "+_", "\"}\"_", "if_", "not_", "root_", "._", "text_", "==_", "\"\"_", "else_", "\"\"_", ")_", ",_", "file_", "=_", "f_", ",_", "end_", "=_", "\"", " ", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "root_", "._", "label_", "in_", "[_", "\"", "NP", "\"_", "]_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "m_", "=_", "root_", "._", "get", "\\u", "meaning", "_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "k_", "=_", "\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "i_", "in_", "m_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "k_", "+=_", "\"+\"_", "+_", "i_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "print_", "(_", "\"[", ".", "{\"_", "+_", "k_", "+_", "\"}\"_", ",_", "file_", "=_", "f_", ",_", "end_", "=_", "\"", " ", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "root_", "._", "label_", "in_", "[_", "\"", "VP", "\"_", "]_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "m_", "=_", "root_", "._", "get", "\\u", "meaning", "_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "print_", "(_", "\"[", ".", "{\\\\", "it", " ", "\"_", "+_", "utilities_", "._", "code", "\\u", "to", "\\u", "string_", "(_", "m_", ")_", "+_", "\"}\"_", ",_", "file_", "=_", "f_", ",_", "end_", "=_", "\"", " ", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "for_", "child_", "in_", "root_", "._", "children_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "print", "\\u", "tree_", "(_", "child_", ",_", "indent_", "+_", "\"\\\\", "t", "\"_", ",_", "f_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "root_", "._", "label_", "in_", "[_", "\"", "NP", "\"_", ",_", "\"", "VP", "\"_", "]_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "print_", "(_", "\"", " ", "]", " ", "]\"_", ",_", "file_", "=_", "f_", ",_", "end_", "=_", "\"", " ", "\\\\", "n", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "print_", "(_", "\"", " ", "]\"_", ",_", "file_", "=_", "f_", ",_", "end_", "=_", "\"", " ", "\"_", ")_" ]
[ 4, 4, 4, 4, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2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 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 ]
Unused import
alimanfoo/vcfnp/vcfnp/__init__.py
[ { "content": "# -*- coding: utf-8 -*-\nfrom __future__ import absolute_import, print_function, division\n\n\n__version__ = '2.3.0.dev0'\n\n\nimport vcfnp.config as config\nimport vcfnp.eff as eff\nfrom vcfnp.vcflib import PyVariantCallFile as VariantCallFile\nfrom vcfnp.array import variants, calldata, calldata_2d, view2d\nfrom vcfnp.table import VariantsTable\n", "metadata": "root", "header": "['module', '___EOS___']", "index": 0 } ]
[ { "span": "import vcfnp.config as config", "start_line": 7, "start_column": 0, "end_line": 7, "end_column": 29 }, { "span": "import vcfnp.eff as eff", "start_line": 8, "start_column": 0, "end_line": 8, "end_column": 23 }, { "span": "from vcfnp.vcflib import PyVariantCallFile as VariantCallFile", "start_line": 9, "start_column": 0, "end_line": 9, "end_column": 61 }, { "span": "from vcfnp.array import variants, calldata, calldata_2d, view2d", "start_line": 10, "start_column": 0, "end_line": 10, "end_column": 63 }, { "span": "from vcfnp.table import VariantsTable", "start_line": 11, "start_column": 0, "end_line": 11, "end_column": 37 } ]
[]
1
false
[ "[CLS]_", "Un", "used_", "import_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "#", " ", "-*-", " ", "codi", "ng", ":", " ", "utf", "-", "8", " ", "-*-", "_", "\\u\\u\\uNL\\u\\u\\u_", "from_", "\\u\\u", "future\\u\\u_", "import_", "abs", "olute", "\\u", "import_", ",_", "print", "\\u", "function_", ",_", "division_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u", "version\\u\\u_", "=_", "'", "2.3", ".0", ".", "dev", "0", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "import_", "vcf", "np_", "._", "config_", "as_", "config_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "vcf", "np_", "._", "eff_", "as_", "eff_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "vcf", "np_", "._", "vcf", "lib_", "import_", "Py", "Varia", "nt", "Call", "File_", "as_", "Varia", "nt", "Call", "File_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "vcf", "np_", "._", "array_", "import_", "variants_", ",_", "call", "data_", ",_", "call", "data\\u", "2d_", ",_", "view", "2d_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "vcf", "np_", "._", "table_", "import_", "Varia", "nts", "Table_" ]
[ 4, 4, 4, 4, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 1, 1, 1, 1, 1, 1, 2, 0, 1, 1, 1, 1, 1, 1, 2, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 0, 1, 1, 1, 1, 1, 1, 1, 1 ]
Except block handles 'BaseException'
modflowpy/flopy/flopy/modflow/mfhfb.py
[ { "content": " @staticmethod\n def load(f, model, ext_unit_dict=None):\n \"\"\"\n Load an existing package.\n\n Parameters\n ----------\n f : filename or file handle\n File to load.\n model : model object\n The model object (of type: class:`flopy.modflow.mf.Modflow`) \n to which this package will be added.\n ext_unit_dict : dictionary, optional\n If the arrays in the file are specified using EXTERNAL,\n or older style array control records, then `f` should be a file\n handle. In this case ext_unit_dict is required, which can be\n constructed using the function\n :class:`flopy.utils.mfreadnam.parsenamefile`.\n\n Returns\n -------\n hfb : ModflowHfb object\n ModflowHfb object (of type :class:`flopy.modflow.mfbas.ModflowHfb`)\n\n Examples\n --------\n\n >>> import flopy\n >>> m = flopy.modflow.Modflow()\n >>> hfb = flopy.modflow.ModflowHfb.load('test.hfb', m)\n\n \"\"\"\n\n if model.verbose:\n sys.stdout.write('loading hfb6 package file...\\n')\n\n if not hasattr(f, 'read'):\n filename = f\n f = open(filename, 'r')\n # dataset 0 -- header\n while True:\n line = f.readline()\n if line[0] != '#':\n break\n # dataset 1\n t = line.strip().split()\n nphfb = int(t[0])\n mxfb = int(t[1])\n nhfbnp = int(t[2])\n # check for no-print suppressor\n options = []\n aux_names = []\n if len(t) > 2:\n it = 2\n while it < len(t):\n toption = t[it]\n #print it, t[it]\n if toption.lower() is 'noprint':\n options.append(toption)\n elif 'aux' in toption.lower():\n options.append(' '.join(t[it:it + 2]))\n aux_names.append(t[it + 1].lower())\n it += 1\n it += 1\n # data set 2 and 3\n if nphfb > 0:\n dt = ModflowHfb.get_empty(1).dtype\n pak_parms = mfparbc.load(f, nphfb, dt, model.verbose)\n # data set 4\n bnd_output = None\n if nhfbnp > 0:\n specified = ModflowHfb.get_empty(nhfbnp)\n for ibnd in range(nhfbnp):\n line = f.readline()\n if \"open/close\" in line.lower():\n raise NotImplementedError(\"load() method does not support \\'open/close\\'\")\n t = line.strip().split()\n specified[ibnd] = tuple(t[:len(specified.dtype.names)])\n\n # convert indices to zero-based\n specified['k'] -= 1\n specified['irow1'] -= 1\n specified['icol1'] -= 1\n specified['irow2'] -= 1\n specified['icol2'] -= 1\n\n bnd_output = np.recarray.copy(specified)\n\n if nphfb > 0:\n partype = ['hydchr']\n line = f.readline()\n t = line.strip().split()\n nacthfb = int(t[0])\n for iparm in range(nacthfb):\n line = f.readline()\n t = line.strip().split()\n pname = t[0].lower()\n iname = 'static'\n par_dict, current_dict = pak_parms.get(pname)\n data_dict = current_dict[iname]\n #print par_dict\n #print data_dict\n\n par_current = ModflowHfb.get_empty(par_dict['nlst'])\n\n #\n if model.mfpar.pval is None:\n parval = np.float(par_dict['parval'])\n else:\n try:\n parval = np.float(model.mfpar.pval.pval_dict[pname])\n except:\n parval = np.float(par_dict['parval'])\n\n # fill current parameter data (par_current)\n for ibnd, t in enumerate(data_dict):\n par_current[ibnd] = tuple(t[:len(par_current.dtype.names)])\n\n # convert indices to zero-based\n par_current['k'] -= 1\n par_current['irow1'] -= 1\n par_current['icol1'] -= 1\n par_current['irow2'] -= 1\n par_current['icol2'] -= 1\n\n for ptype in partype:\n par_current[ptype] *= parval\n\n if bnd_output is None:\n bnd_output = np.recarray.copy(par_current)\n else:\n bnd_output = stack_arrays((bnd_output, par_current),\n asrecarray=True, usemask=False)\n\n hfb = ModflowHfb(model, nphfb=0, mxfb=0, nhfbnp=len(bnd_output),\n hfb_data=bnd_output,\n nacthfb=0, options=options)\n return hfb", "metadata": "root.ModflowHfb.load", "header": "['class', 'ModflowHfb', '(', 'Package', ')', ':', '___EOS___']", "index": 196 } ]
[ { "span": "except:", "start_line": 307, "start_column": 20, "end_line": 307, "end_column": 27 } ]
[]
1
true
[ "[CLS]_", "Except", "_", "block_", "handles_", "'", "Base", "Except", "ion", "'_", "[SEP]_", "class_", "Mod", "flow", "Hf", "b_", "(_", "Package_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "@_", "staticmethod_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "load_", "(_", "f_", ",_", "model_", ",_", "ext", "\\u", "unit", "\\u", "dict_", "=_", "None_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Load", " ", "an", " ", "exist", "ing", " ", "package", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "Parameter", "s", "\\", "10", ";", " ", " ", " ", " ", "----------", "\\", "10", ";", " ", " ", " ", " ", "f", " ", ":", " ", "filename", " ", "or", " ", "file", " ", "handle", "\\", "10", ";", " ", " ", " ", " ", "File", " ", "to", " ", "load", ".", "\\", "10", ";", " ", " ", " ", " ", "model", " ", ":", " ", "model", " ", "object", "\\", "10", ";", " ", " ", " ", " ", "The", " ", "model", " ", "object", " ", "(", "of", " ", "type", ":", " ", "class", ":`", "flop", "y", ".", "mod", "flow", ".", "mf", ".", "Mod", "flow", "`)", " ", "\\", "10", ";", " ", " ", " ", " ", "to", " ", "whi", "ch", " ", "this", " ", "package", " ", "will", " ", "be", " ", "adde", "d", ".", "\\", "10", ";", " ", " ", " ", " ", "ext", "\\u", "unit", "\\u", "dict", " ", ":", " ", "dictionar", "y", ",", " ", "option", "al", "\\", "10", ";", " ", " ", " ", " ", "If", " ", "the", " ", "arrays", " ", "in", " ", "the", " ", "file", " ", "are", " ", "specified", " ", "usi", "ng", " ", "EXTERNAL", ",", "\\", "10", ";", " ", " ", " ", " ", "or", " ", "older", " ", "style", " ", "array", " ", "control", " ", "record", "s", ",", " ", "then", " ", "`", "f", "`", " ", "shou", "ld", " ", "be", " ", "a", " ", "file", "\\", "10", ";", " ", " ", " ", " ", "handle", ".", " ", " ", "In", " ", "this", " ", "case", " ", "ext", "\\u", "unit", "\\u", "dict", " ", "is", " ", "require", "d", ",", " ", "whi", "ch", " ", "can", " ", "be", "\\", "10", ";", " ", " ", " ", " ", "construct", "ed", " ", "usi", "ng", " ", "the", " ", "function", "\\", "10", ";", " ", " ", " ", " ", ":", "class", ":`", "flop", "y", ".", "util", "s", ".", "mf", "read", "nam", ".", "parse", "name", "file", "`.", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "Return", "s", "\\", "10", ";", " ", " ", " ", " ", "-------", "\\", "10", ";", " ", " ", " ", " ", "hf", "b", " ", ":", " ", "Mod", "flow", "Hf", "b", " ", "object", "\\", "10", ";", " ", " ", " ", " ", "Mod", "flow", "Hf", "b", " ", "object", " ", "(", "of", " ", "type", " ", ":", "class", ":`", "flop", "y", ".", "mod", "flow", ".", "mf", "bas", ".", "Mod", "flow", "Hf", "b", "`)", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "Exam", "ples", "\\", "10", ";", " ", " ", " ", " ", "--------", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", ">>>", " ", "import", " ", "flop", "y", "\\", "10", ";", " ", " ", " ", " ", ">>>", " ", "m", " ", "=", " ", "flop", "y", ".", "mod", "flow", ".", "Mod", "flow", "()", "\\", "10", ";", " ", " ", " ", " ", ">>>", " ", "hf", "b", " ", "=", " ", "flop", "y", ".", "mod", "flow", ".", "Mod", "flow", "Hf", "b", ".", "load", "('", "test", ".", "hf", "b", "',", " ", "m", ")", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "model_", "._", "verbose_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "sys_", "._", "stdout_", "._", "write_", "(_", "'", "load", "ing", " ", "hf", "b6", " ", "package", " ", "file", "...", "\\\\", "n", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "not_", "hasattr_", "(_", "f_", ",_", "'", "read", "'_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "filename_", "=_", "f_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "f_", "=_", "open_", "(_", "filename_", ",_", "'", "r", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "dataset", " ", "0", " ", "--", " ", "header_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "while_", "True_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "line_", "=_", "f_", "._", "readline_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "line_", "[_", "0_", "]_", "!=_", "'#'_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "break_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "dataset", " ", "1_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "t_", "=_", "line_", "._", "strip_", "(_", ")_", "._", "split_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "np", "hf", "b_", "=_", "int_", "(_", "t_", "[_", "0_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "mx", "fb_", "=_", "int_", "(_", "t_", "[_", "1_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "nh", "fb", "np_", "=_", "int_", "(_", "t_", "[_", "2_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "check", " ", "for", " ", "no", "-", "print", " ", "suppress", "or_", "\\u\\u\\uNL\\u\\u\\u_", "options_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "aux", "\\u", "names_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "len_", "(_", "t_", ")_", ">_", "2_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "it_", "=_", "2_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "while_", "it_", "<_", "len_", "(_", "t_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "top", "tion_", "=_", "t_", "[_", "it_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", "print", " ", "it", ",", " ", "t", "[", "it", "]_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "top", "tion_", "._", "lower_", "(_", ")_", "is_", "'", "nop", "rint", "'_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "options_", "._", "append_", "(_", "top", "tion_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "'", "aux", "'_", "in_", "top", "tion_", "._", "lower_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "options_", "._", "append_", "(_", "'", " ", "'_", "._", "join_", "(_", "t_", "[_", "it_", ":_", "it_", "+_", "2_", "]_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "aux", "\\u", "names_", "._", "append_", "(_", "t_", "[_", "it_", "+_", "1_", "]_", "._", "lower_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "it_", "+=_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "it_", "+=_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "data", " ", "set", " ", "2", " ", "and", " ", "3_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "np", "hf", "b_", ">_", "0_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "dt_", "=_", "Mod", "flow", "Hf", "b_", "._", "get", "\\u", "empty_", "(_", "1_", ")_", "._", "dtype_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "pak", "\\u", "parms_", "=_", "mf", "par", "bc_", "._", "load_", "(_", "f_", ",_", "np", "hf", "b_", ",_", "dt_", ",_", "model_", "._", "verbose_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "data", " ", "set", " ", "4_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "bnd", "\\u", "output_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "nh", "fb", "np_", ">_", "0_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "specified", "_", "=_", "Mod", "flow", "Hf", "b_", "._", "get", "\\u", "empty_", "(_", "nh", "fb", "np_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "ib", "nd_", "in_", "range_", "(_", "nh", "fb", "np_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "line_", "=_", "f_", "._", "readline_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "\"", "open", "/", "close", "\"_", "in_", "line_", "._", "lower_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "raise_", "Not", "Impl", "ement", "ed", "Error_", "(_", "\"", "load", "()", " ", "method", " ", "doe", "s", " ", "not", " ", "support", " ", "\\\\'", "open", "/", "close", "\\\\'\"", "_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "t_", "=_", "line_", "._", "strip_", "(_", ")_", "._", "split_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "specified", "_", "[_", "ib", "nd_", "]_", "=_", "tuple_", "(_", "t_", "[_", ":_", "len_", "(_", "specified", "_", "._", "dtype_", "._", "names_", ")_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "convert", " ", "indice", "s", " ", "to", " ", "zero", "-", "based", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "specified", "_", "[_", "'", "k", "'_", "]_", "-=_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "specified", "_", "[_", "'", "iro", "w", "1", "'_", "]_", "-=_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "specified", "_", "[_", "'", "ico", "l1", "'_", "]_", "-=_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "specified", "_", "[_", "'", "iro", "w2", "'_", "]_", "-=_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "specified", "_", "[_", "'", "ico", "l2", "'_", "]_", "-=_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "bnd", "\\u", "output_", "=_", "np_", "._", "reca", "rray_", "._", "copy_", "(_", "specified", "_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "np", "hf", "b_", ">_", "0_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "part", "ype_", "=_", "[_", "'", "hy", "dch", "r", "'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "line_", "=_", "f_", "._", "readline_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "t_", "=_", "line_", "._", "strip_", "(_", ")_", "._", "split_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "nac", "th", "fb_", "=_", "int_", "(_", "t_", "[_", "0_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "ipa", "rm_", "in_", "range_", "(_", "nac", "th", "fb_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "line_", "=_", "f_", "._", "readline_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "t_", "=_", "line_", "._", "strip_", "(_", ")_", "._", "split_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "pname_", "=_", "t_", "[_", "0_", "]_", "._", "lower_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "iname", "_", "=_", "'", "static", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "par", "\\u", "dict_", ",_", "current", "\\u", "dict_", "=_", "pak", "\\u", "parms_", "._", "get_", "(_", "pname_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "data\\u", "dict_", "=_", "current", "\\u", "dict_", "[_", "iname", "_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", "print", " ", "par", "\\u", "dict_", "\\u\\u\\uNL\\u\\u\\u_", "#", "print", " ", "data\\u", "dict_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "par", "\\u", "current_", "=_", "Mod", "flow", "Hf", "b_", "._", "get", "\\u", "empty_", "(_", "par", "\\u", "dict_", "[_", "'", "nl", "st", "'_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", "_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "model_", "._", "mf", "par_", "._", "pval_", "is_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "par", "val_", "=_", "np_", "._", "float_", "(_", "par", "\\u", "dict_", "[_", "'", "par", "val", "'_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "par", "val_", "=_", "np_", "._", "float_", "(_", "model_", "._", "mf", "par_", "._", "pval_", "._", "pval", "\\u", "dict_", "[_", "pname_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "par", "val_", "=_", "np_", "._", "float_", "(_", "par", "\\u", "dict_", "[_", "'", "par", "val", "'_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "fill", " ", "current", " ", "parameter", " ", "data", " ", "(", "par", "\\u", "current", ")_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "for_", "ib", "nd_", ",_", "t_", "in_", "enumerate_", "(_", "data\\u", "dict_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "par", "\\u", "current_", "[_", "ib", "nd_", "]_", "=_", "tuple_", "(_", "t_", "[_", ":_", "len_", "(_", "par", "\\u", "current_", "._", "dtype_", "._", "names_", ")_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "convert", " ", "indice", "s", " ", "to", " ", "zero", "-", "based", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "par", "\\u", "current_", "[_", "'", "k", "'_", "]_", "-=_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "par", "\\u", "current_", "[_", "'", "iro", "w", "1", "'_", "]_", "-=_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "par", "\\u", "current_", "[_", "'", "ico", "l1", "'_", "]_", "-=_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "par", "\\u", "current_", "[_", "'", "iro", "w2", "'_", "]_", "-=_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "par", "\\u", "current_", "[_", "'", "ico", "l2", "'_", "]_", "-=_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "for_", "ptype_", "in_", "part", "ype_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "par", "\\u", "current_", "[_", "ptype_", "]_", "*=_", "par", "val_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "bnd", "\\u", "output_", "is_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "bnd", "\\u", "output_", "=_", "np_", "._", "reca", "rray_", "._", "copy_", "(_", "par", "\\u", "current_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "bnd", "\\u", "output_", "=_", "stack", "\\u", "arrays_", "(_", "(_", "bnd", "\\u", "output_", ",_", "par", "\\u", "current_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "as", "reca", "rray_", "=_", "True_", ",_", "use", "mask_", "=_", "False_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "hf", "b_", "=_", "Mod", "flow", "Hf", "b_", "(_", "model_", ",_", "np", "hf", "b_", "=_", "0_", ",_", "mx", "fb_", "=_", "0_", ",_", "nh", "fb", "np_", "=_", "len_", "(_", "bnd", "\\u", "output_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "hf", "b", "\\u", "data_", "=_", "bnd", "\\u", "output_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "nac", "th", "fb_", "=_", "0_", ",_", "options_", "=_", "options_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "hf", "b_" ]
[ 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,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2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 ]
Unused import
pybrain/pybrain/pybrain/supervised/trainers/svmtrainer.py
[ { "content": "from __future__ import print_function\n\n__author__ = \"Martin Felder, [email protected]\"\n\ntry:\n from svm import svm_model, svm_parameter, svm_problem, cross_validation #@UnresolvedImport\n from svm import C_SVC, NU_SVC, ONE_CLASS, EPSILON_SVR, NU_SVR #@UnresolvedImport @UnusedImport\n from svm import LINEAR, POLY, RBF, SIGMOID, PRECOMPUTED #@UnresolvedImport @UnusedImport\nexcept ImportError:\n raise ImportError(\"Cannot find LIBSVM installation. Make sure svm.py and svmc.* are in the PYTHONPATH!\")\n\nfrom numpy import * #@UnusedWildImport\nimport logging\n\n\n\n \n \n\n \n\n\n\n", "metadata": "root", "header": "['module', '___EOS___']", "index": 0 }, { "content": "class SVMTrainer(object):\n \"\"\"A class performing supervised learning of a DataSet by an SVM unit. See \n the remarks on :class:`SVMUnit` above. This whole class is a bit of a hack,\n and provided mostly for convenience of comparisons.\"\"\"\n \n \n \n \n \n \n \n ", "metadata": "root.SVMTrainer", "header": "['module', '___EOS___']", "index": 15 }, { "content": " def __init__(self, svmunit, dataset, modelfile=None, plot=False):\n \"\"\" Initialize data and unit to be trained, and load the model, if \n provided.\n \n The passed `svmunit` has to be an object of class :class:`SVMUnit` \n that is going to be trained on the :class:`ClassificationDataSet` object\n dataset. \n Compared to FNN training we do not use a test data set, instead 5-fold \n cross-validation is performed if needed.\n \n If `modelfile` is provided, this model is loaded instead of training.\n If `plot` is True, a grid search is performed and the resulting pattern\n is plotted.\"\"\"\n self.svm = svmunit\n self.ds = dataset\n self.svmtarget = dataset['target'].flatten()\n self.plot = plot\n self.searchlog = 'gridsearch_results.txt'\n # set default parameters for training\n self.params = {\n 'kernel_type':RBF\n }\n\n if modelfile is not None: self.load(modelfile)", "metadata": "root.SVMTrainer.__init__", "header": "['class', 'SVMTrainer', '(', 'object', ')', ':', '___EOS___']", "index": 20 }, { "content": " def train(self, search=False, **kwargs):\n \"\"\" Train the SVM on the dataset. For RBF kernels (the default), an optional meta-parameter search can be performed.\n\n :key search: optional name of grid search class to use for RBF kernels: 'GridSearch' or 'GridSearchDOE' \n :key log2g: base 2 log of the RBF width parameter\n :key log2C: base 2 log of the slack parameter\n :key searchlog: filename into which to dump the search log\n :key others: ...are passed through to the grid search and/or libsvm \n \"\"\"\n \n self.setParams(**kwargs)\n problem = svm_problem(self.ds['target'].flatten(), self.ds['input'].tolist())\n if search:\n # this is a bit of a hack...\n model = eval(search + \"(problem, self.svmtarget, cmin=[0,-7],cmax=[25,1], cstep=[0.5,0.2],plotflag=self.plot,searchlog=self.searchlog,**self.params)\")\n else:\n param = svm_parameter(**self.params)\n model = svm_model(problem, param)\n logging.info(\"Training completed with parameters:\")\n logging.info(repr(param))\n\n self.svm.setModel(model)", "metadata": "root.SVMTrainer.train", "header": "['class', 'SVMTrainer', '(', 'object', ')', ':', '___EOS___']", "index": 46 }, { "content": " def save(self, filename):\n \"\"\" save the trained SVM \"\"\"\n self.svm.saveModel(filename)", "metadata": "root.SVMTrainer.save", "header": "['class', 'SVMTrainer', '(', 'object', ')', ':', '___EOS___']", "index": 70 }, { "content": " def load(self, filename):\n \"\"\" no training at all - just load the SVM model from a file \"\"\"\n self.svm.loadModel(filename)", "metadata": "root.SVMTrainer.load", "header": "['class', 'SVMTrainer', '(', 'object', ')', ':', '___EOS___']", "index": 75 }, { "content": " def setParams(self, **kwargs):\n \"\"\" Set parameters for SVM training. Apart from the ones below, you can use all parameters \n defined for the LIBSVM svm_model class, see their documentation.\n\n :key searchlog: Save a list of coordinates and the achieved CV accuracy to this file.\"\"\"\n if 'weight' in kwargs:\n self.params['nr_weight'] = len(kwargs['weight'])\n if 'log2C' in kwargs:\n self.params['C'] = 2 ** kwargs['log2C']\n kwargs.pop('log2C')\n if 'log2g' in kwargs:\n self.params['gamma'] = 2 ** kwargs['log2g']\n kwargs.pop('log2g')\n if 'searchlog' in kwargs:\n self.searchlog = kwargs['searchlog']\n kwargs.pop('searchlog')\n self.params.update(kwargs)", "metadata": "root.SVMTrainer.setParams", "header": "['class', 'SVMTrainer', '(', 'object', ')', ':', '___EOS___']", "index": 79 }, { "content": "class GridSearch(svm_model):\n \"\"\"Helper class used by :class:`SVMTrainer` to perform an exhaustive grid search, and plot the\n resulting accuracy surface, if desired. Adapted from the LIBSVM python toolkit.\"\"\"\n \n allPts = []\n allScores = []\n \n \n \n \n \n\n\n\n ", "metadata": "root.GridSearch", "header": "['module', '___EOS___']", "index": 99 }, { "content": " def __init__(self, problem, targets, cmin, cmax, cstep=None, crossval=5,\n plotflag=False, maxdepth=8, searchlog='gridsearch_results.txt', **params):\n \"\"\" Set up (log) grid search over the two RBF kernel parameters C and gamma.\n\n :arg problem: the LIBSVM svm_problem to be optimized, ie. the input and target data\n :arg targets: unfortunately, the targets used in the problem definition have to be given again here\n :arg cmin: lower left corner of the log2C/log2gamma window to search\n :arg cmax: upper right corner of the log2C/log2gamma window to search\n :key cstep: step width for log2C and log2gamma (ignored for DOE search)\n :key crossval: split dataset into this many parts for cross-validation\n :key plotflag: if True, plot the error surface contour (regular) or search pattern (DOE)\n :key maxdepth: maximum window bisection depth (DOE only)\n :key searchlog: Save a list of coordinates and the achieved CV accuracy to this file\n :key others: ...are passed through to the cross_validation method of LIBSVM\n \"\"\"\n self.nPars = len(cmin)\n self.usermin = cmin\n self.usermax = cmax\n self.userstep = cstep\n self.crossval = crossval\n self.plotflag = plotflag\n self.maxdepth = maxdepth # number of zoom-in steps (DOE search only!)\n \n # set default parameters for training\n self.params = params\n \n if self.plotflag:\n import pylab as p \n p.ion()\n p.figure(figsize=[12, 8])\n \n assert isinstance(problem, svm_problem)\n self.problem = problem\n self.targets = targets\n \n self.resfile = open(searchlog, 'w')\n\n # do the parameter searching\n param = self.search()\n \n if self.plotflag: \n p.ioff()\n p.show()\n \n self.resfile.close()\n svm_model.__init__(self, problem, param)", "metadata": "root.GridSearch.__init__", "header": "['class', 'GridSearch', '(', 'svm_model', ')', ':', '___EOS___']", "index": 106 }, { "content": " def setParams(self, **kwargs):\n \"\"\" set parameters for SVM training \"\"\"\n if 'weight' in kwargs:\n self.params['nr_weight'] = len(kwargs['weight'])\n self.params.update(kwargs)", "metadata": "root.GridSearch.setParams", "header": "['class', 'GridSearch', '(', 'svm_model', ')', ':', '___EOS___']", "index": 153 }, { "content": " def search(self):\n \"\"\" iterate successive parameter grid refinement and evaluation; adapted from LIBSVM grid search tool \"\"\"\n jobs = self.calculate_jobs()\n scores = []\n for line in jobs:\n for (c, g) in line:\n # run cross-validation for this point\n self.setParams(C=2 ** c, gamma=2 ** g)\n param = svm_parameter(**self.params)\n cvresult = array(cross_validation(self.problem, param, self.crossval))\n corr, = where(cvresult == self.targets)\n res = (c, g, float(corr.size) / self.targets.size) \n scores.append(res)\n self._save_points(res)\n self._redraw(scores)\n scores = array(scores)\n best = scores[scores[:, 0].argmax(), 1:]\n self.setParams(C=2 ** best[0], gamma=2 ** best[1])\n logging.info(\"best log2C=%12.7g, log2g=%11.7g \" % (best[0], best[1]))\n param = svm_parameter(**self.params)\n return param", "metadata": "root.GridSearch.search", "header": "['class', 'GridSearch', '(', 'svm_model', ')', ':', '___EOS___']", "index": 159 }, { "content": " def _permute_sequence(self, seq):\n \"\"\" helper function to create a nice sequence of refined regular grids; from LIBSVM grid search tool \"\"\"\n n = len(seq)\n if n <= 1: return seq\n \n mid = int(n / 2)\n left = self._permute_sequence(seq[:mid])\n right = self._permute_sequence(seq[mid + 1:])\n \n ret = [seq[mid]]\n while left or right:\n if left: ret.append(left.pop(0))\n if right: ret.append(right.pop(0))\n \n return ret", "metadata": "root.GridSearch._permute_sequence", "header": "['class', 'GridSearch', '(', 'svm_model', ')', ':', '___EOS___']", "index": 182 }, { "content": " def _range_f(self, begin, end, step):\n \"\"\" like range, but works on non-integer too; from LIBSVM grid search tool \"\"\" \n seq = []\n while 1:\n if step > 0 and begin > end: break\n if step < 0 and begin < end: break\n seq.append(begin)\n begin = begin + step\n return seq", "metadata": "root.GridSearch._range_f", "header": "['class', 'GridSearch', '(', 'svm_model', ')', ':', '___EOS___']", "index": 198 }, { "content": " def calculate_jobs(self):\n \"\"\" like range, but works on non-integer too; from LIBSVM grid search tool \"\"\" \n c_seq = self._permute_sequence(self._range_f(self.usermin[0], self.usermax[0], self.userstep[0]))\n g_seq = self._permute_sequence(self._range_f(self.usermin[1], self.usermax[1], self.userstep[1]))\n nr_c = float(len(c_seq))\n nr_g = float(len(g_seq))\n global total_points\n total_points = (nr_g + 1) * (nr_g)\n i = 0\n j = 0\n jobs = []\n \n while i < nr_c or j < nr_g:\n if i / nr_c < j / nr_g:\n # increase C resolution\n line = []\n for k in range(0, j):\n line.append((c_seq[i], g_seq[k]))\n i = i + 1\n jobs.append(line)\n else:\n # increase g resolution\n line = []\n for k in range(0, i):\n line.append((c_seq[k], g_seq[j]))\n j = j + 1\n jobs.append(line)\n return jobs", "metadata": "root.GridSearch.calculate_jobs", "header": "['class', 'GridSearch', '(', 'svm_model', ')', ':', '___EOS___']", "index": 208 }, { "content": " def _save_points(self, res):\n \"\"\" save the list of points and corresponding scores into a file \"\"\"\n self.resfile.write(\"%g, %g, %g\\n\" % res)\n logging.info(\"log2C=%g, log2g=%g, res=%g\" % res)\n self.resfile.flush()", "metadata": "root.GridSearch._save_points", "header": "['class', 'GridSearch', '(', 'svm_model', ')', ':', '___EOS___']", "index": 237 }, { "content": " def _redraw(self, db, tofile=0, eta=None):\n \"\"\" redraw the updated grid interactively \"\"\"\n import pylab as p \n if len(db) <= 3 or not self.plotflag: return\n #begin_level = round(max(map(lambda(x):x[2],db))) - 3\n #step_size = 0.25\n nContours = 25\n #suffix = ''\n #if eta is not None:\n # suffix = \" (ETA: %5.2f min)\" % eta\n def cmp (x, y):\n if x[0] < y[0]: return - 1\n if x[0] > y[0]: return 1\n if x[1] > y[1]: return - 1\n if x[1] < y[1]: return 1\n return 0\n db.sort(cmp)\n dbarr = p.asarray(db)\n # reconstruct grid: array is ordered along first and second dimension\n x = dbarr[:, 0]\n dimy = len(x[x == x[0]])\n dimx = x.size / dimy\n print(('plotting: ', dimx, dimy))\n x = x.reshape(dimx, dimy)\n y = dbarr[:, 1]\n y = y.reshape(dimx, dimy)\n z = dbarr[:, 2].reshape(dimx, dimy)\n \n # plot using manual double buffer\n p.ioff()\n p.clf()\n p.contourf(x, y, z, nContours)\n p.hsv()\n p.colorbar()\n p.xlim(self.usermin[0], self.usermax[0])\n p.ylim(self.usermin[1], self.usermax[1])\n p.xlabel(r'$\\rm{log}_2(C)$')\n p.ylabel(r'$\\rm{log}_2(\\gamma)$')\n p.ion()\n p.draw_if_interactive()", "metadata": "root.GridSearch._redraw", "header": "['class', 'GridSearch', '(', 'svm_model', ')', ':', '___EOS___']", "index": 243 }, { "content": "class GridSearchDOE(GridSearch):\n \"\"\" Same as GridSearch, but implements a design-of-experiments based search pattern, as\n described by C. Staelin, http://www.hpl.hp.com/techreports/2002/HPL-2002-354R1.pdf \"\"\"\n\n # DOE pattern; the last 5 points do not need to be calculated when refining the grid \n doepat = array([[0.5, 1], [0.25, 0.75], [0.75, 0.75], [0, 0.5], [1, 0.5], \\\n [0.25, 0.25], [0.75, 0.25], [0.5, 0], [0, 1], [1, 1], [0.5, 0.5], [0, 0], [1, 0]])\n nPts = 13\n depth = 0\n \n \n \n ", "metadata": "root.GridSearchDOE", "header": "['module', '___EOS___']", "index": 286 }, { "content": " def search(self, cmin=None, cmax=None):\n \"\"\" iterate parameter grid refinement and evaluation recursively \"\"\"\n if self.depth > self.maxdepth:\n # maximum search depth reached - finish up\n best = self.allPts[self.allScores.argmax(), :]\n logging.info(\"best log2C=%12.7g, log2g=%11.7g \" % (best[0], best[1]))\n self.setParams(C=2 ** best[0], gamma=2 ** best[1])\n param = svm_parameter(**self.params)\n logging.info(\"Grid search completed! Final parameters:\")\n logging.info(repr(param))\n return param\n \n # generate DOE gridpoints using current range\n if cmin is None:\n # use initial values, if none given\n cmin = array(self.usermin)\n cmax = array(self.usermax)\n points = self.refineGrid(cmin, cmax)\n \n # calculate scores for all grid points using n-fold cross-validation\n scores = []\n isnew = array([True] * self.nPts)\n for i in range(self.nPts):\n idx = self._findIndex(points[i, :])\n if idx >= 0:\n # point already exists\n isnew[i] = False\n scores.append(self.allScores[idx])\n else: \n # new point, run cross-validation\n self.setParams(C=2 ** points[i, 0], gamma=2 ** points[i, 1])\n param = svm_parameter(**self.params)\n cvresult = array(cross_validation(self.problem, param, self.crossval))\n # save cross validation result as \"% correct\" \n corr, = where(cvresult == self.targets)\n corr = float(corr.size) / self.targets.size\n scores.append(corr)\n self._save_points((points[i, 0], points[i, 1], corr))\n\n scores = array(scores)\n \n # find max and new ranges by halving the old ones, whereby\n # entire search region must lie within original search range\n newctr = points[scores.argmax(), :].copy()\n newdiff = (cmax - cmin) / 4.0\n for i in range(self.nPars):\n newctr[i] = min([max([newctr[i], self.usermin[i] + newdiff[i]]), self.usermax[i] - newdiff[i]])\n cmin = newctr - newdiff\n cmax = newctr + newdiff\n logging.info(\"depth:\\t%3d\\tcrange:\\t%g\\tscore:\\t%g\" % (self.depth, cmax[0] - cmin[0], scores.max()))\n \n # append points and scores to the full list\n if self.depth == 0:\n self.allPts = points[isnew, :].copy()\n self.allScores = scores[isnew].copy()\n else:\n self.allPts = append(self.allPts, points[isnew, :], axis=0)\n self.allScores = append(self.allScores, scores[isnew], axis=0)\n \n if self.plotflag:\n import pylab as p \n if self.depth == 0:\n self.oPlot = p.plot(self.allPts[:, 0], self.allPts[:, 1], 'o')[0]\n # insert new data into plot\n self.oPlot.set_data(self.allPts[:, 0], self.allPts[:, 1])\n p.draw()\n \n # recursively call ourselves\n self.depth += 1 \n return self.search(cmin, cmax)", "metadata": "root.GridSearchDOE.search", "header": "['class', 'GridSearchDOE', '(', 'GridSearch', ')', ':', '___EOS___']", "index": 296 }, { "content": " def refineGrid(self, cmin, cmax):\n \"\"\" given grid boundaries, generate the corresponding DOE pattern from template\"\"\"\n diff = array((cmax - cmin).tolist()*self.nPts).reshape(self.nPts, self.nPars)\n return self.doepat * diff + array(cmin.tolist()*self.nPts).reshape(self.nPts, self.nPars)", "metadata": "root.GridSearchDOE.refineGrid", "header": "['class', 'GridSearchDOE', '(', 'GridSearch', ')', ':', '___EOS___']", "index": 368 }, { "content": " def _findIndex(self, point):\n \"\"\" determines whether given point already exists in list of all calculated points.\n raises exception if more than one point is found, returns -1 if no point is found \"\"\"\n if self.depth == 0: return - 1\n check = self.allPts[:, 0] == point[0]\n for i in range(1, point.size):\n check = check & (self.allPts[:, i] == point[i])\n idx, = where(check)\n if idx.size == 0:\n return - 1\n elif idx.size > 1:\n logging.error(\"Something went wrong - found more than one matching point!\")\n logging.error(str(point))\n logging.error(str(self.allPts))\n raise\n else:\n return idx[0]", "metadata": "root.GridSearchDOE._findIndex", "header": "['class', 'GridSearchDOE', '(', 'GridSearch', ')', ':', '___EOS___']", "index": 373 } ]
[ { "span": "from svm import C_SVC, NU_SVC, ONE_CLASS, EPSILON_SVR, NU_SVR ", "start_line": 6, "start_column": 4, "end_line": 6, "end_column": 65 }, { "span": "from svm import LINEAR, POLY, RBF, SIGMOID, PRECOMPUTED ", "start_line": 7, "start_column": 4, "end_line": 7, "end_column": 59 } ]
[]
1
false
[ "[CLS]_", "Un", "used_", "import_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "from_", "\\u\\u", "future\\u\\u_", "import_", "print", "\\u", "function_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u", "author\\u\\u_", "=_", "\"", "Mart", "in", " ", "Fel", "der", ",", " ", "fel", "der", "@", "in", ".", "tum", ".", "de", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "from_", "svm_", "import_", "svm", "\\u", "model_", ",_", "svm", "\\u", "parameter_", ",_", "svm", "\\u", "problem_", ",_", "cross", "\\u", "validation_", "#@", "Unre", "solved", "Import_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "svm_", "import_", "C", "\\u", "SVC_", ",_", "NU", "\\u", "SVC_", ",_", "ONE", "\\u", "CLASS_", ",_", "EPS", "ILO", "N", "\\u", "SV", "R_", ",_", "NU", "\\u", "SV", "R_", "#@", "Unre", "solved", "Import", " ", "@", "Un", "used", "Import_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "svm_", "import_", "LINEAR", "_", ",_", "POLY", "_", ",_", "RB", "F_", ",_", "SIG", "MO", "ID_", ",_", "PRE", "COMPUTE", "D_", "#@", "Unre", "solved", "Import", " ", "@", "Un", "used", "Import_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "Import", "Error_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "raise_", "Import", "Error_", "(_", "\"", "Cann", "ot", " ", "find", " ", "LIBS", "VM", " ", "installation", ".", " ", "Make", " ", "sure", " ", "svm", ".", "py", " ", "and", " ", "svm", "c", ".*", " ", "are", " ", "in", " ", "the", " ", "PYTHON", "PATH", "!\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "from_", "numpy_", "import_", "*_", "#@", "Un", "used", "Wild", "Import_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "logging_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "class_", "SV", "MT", "rain", "er_", "(_", "object_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "A", " ", "class", " ", "perform", "ing", " ", "supervis", "ed", " ", "learn", "ing", " ", "of", " ", "a", " ", "Data", "Set", " ", "by", " ", "an", " ", "SV", "M", " ", "unit", ".", " ", "See", " ", "\\", "10", ";", " ", " ", " ", " ", "the", " ", "remark", "s", " ", "on", " ", ":", "class", ":`", "SV", "MU", "nit", "`", " ", "above", ".", " ", "Thi", "s", " ", "whole", " ", "class", " ", "is", " ", "a", " ", "bit", " ", "of", " ", "a", " ", "hack", ",", "\\", "10", ";", " ", " ", " ", " ", "and", " ", "provided", " ", "most", "ly", " ", "for", " ", "convenien", "ce", " ", "of", " ", "comparisons", ".\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "[SEP]_", "class_", "SV", "MT", "rain", "er_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "\\u\\u", "init\\u\\u_", "(_", "self_", ",_", "svm", "unit_", ",_", "dataset_", ",_", "modelf", "ile_", "=_", "None_", ",_", "plot_", "=_", "False_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", " ", "Initializ", "e", " ", "data", " ", "and", " ", "unit", " ", "to", " ", "be", " ", "trained", ",", " ", "and", " ", "load", " ", "the", " ", "model", ",", " ", "if", " ", "\\", "10", ";", " ", " ", " ", " ", "provided", ".", "\\", "10", ";", " ", " ", " ", " ", "\\", "10", ";", " ", " ", " ", " ", "The", " ", "pass", "ed", " ", "`", "svm", "unit", "`", " ", "has", " ", "to", " ", "be", " ", "an", " ", "object", " ", "of", " ", "class", " ", ":", "class", ":`", "SV", "MU", "nit", "`", " ", "\\", "10", ";", " ", " ", " ", " ", "tha", "t", " ", "is", " ", "goi", "ng", " ", "to", " ", "be", " ", "trained", " ", "on", " ", "the", " ", ":", "class", ":`", "Classificat", "ion", "Data", "Set", "`", " ", "object", "\\", "10", ";", " ", " ", " ", " ", "dataset", ".", " ", "\\", "10", ";", " ", " ", " ", " ", "Compare", "d", " ", "to", " ", "FN", "N", " ", "train", "ing", " ", "we", " ", "do", " ", "not", " ", "use", " ", "a", " ", "test", " ", "data", " ", "set", ",", " ", "inst", "ead", " ", "5", "-", "fold", " ", "\\", "10", ";", " ", " ", " ", " ", "cross", "-", "validation", " ", "is", " ", "perform", "ed", " ", "if", " ", "need", "ed", ".", "\\", "10", ";", " ", " ", " ", " ", "\\", "10", ";", " ", " ", " ", " ", "If", " ", "`", "modelf", "ile", "`", " ", "is", " ", "provided", ",", " ", "this", " ", "model", " ", "is", " ", "load", "ed", " ", "inst", "ead", " ", "of", " ", "train", "ing", ".", "\\", "10", ";", " ", " ", " ", " ", "If", " ", "`", "plot", "`", " ", "is", " ", "Tru", "e", ",", " ", "a", " ", "grid", " ", "search", " ", "is", " ", "perform", "ed", " ", "and", " ", "the", " ", "result", "ing", " ", "pattern", "\\", "10", ";", " ", " ", " ", " ", "is", " ", "plott", "ed", ".\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "svm_", "=_", "svm", "unit_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "ds_", "=_", "dataset_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "svm", "target_", "=_", "dataset_", "[_", "'", "target", "'_", "]_", "._", "flatten_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "plot_", "=_", "plot_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "search", "log_", "=_", "'", "grids", "ear", "ch", "\\u", "results", ".", "txt", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "set", " ", "default", " ", "parameter", "s", " ", "for", " ", "training_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "params_", "=_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "'", "kernel", "\\u", "type", "'_", ":_", "RB", "F_", "\\u\\u\\uNL\\u\\u\\u_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "modelf", "ile_", "is_", "not_", "None_", ":_", "self_", "._", "load_", "(_", "modelf", "ile_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "SV", "MT", "rain", "er_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "train_", "(_", "self_", ",_", "search_", "=_", "False_", ",_", "**_", "kwargs_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", " ", "Train", " ", "the", " ", "SV", "M", " ", "on", " ", "the", " ", "dataset", ".", " ", "For", " ", "RB", "F", " ", "kernels", " ", "(", "the", " ", "default", "),", " ", "an", " ", "option", "al", " ", "meta", "-", "parameter", " ", "search", " ", "can", " ", "be", " ", "perform", "ed", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", ":", "key", " ", "search", ":", " ", "option", "al", " ", "name", " ", "of", " ", "grid", " ", "search", " ", "class", " ", "to", " ", "use", " ", "for", " ", "RB", "F", " ", "kernels", ":", " ", "'", "Grid", "Sear", "ch", "'", " ", "or", " ", "'", "Grid", "Sear", "ch", "DO", "E", "'", " ", "\\", "10", ";", " ", " ", " ", " ", ":", "key", " ", "log", "2g", ":", " ", "base", " ", "2", " ", "log", " ", "of", " ", "the", " ", "RB", "F", " ", "widt", "h", " ", "parameter", "\\", "10", ";", " ", " ", " ", " ", ":", "key", " ", "log", "2", "C", ":", " ", "base", " ", "2", " ", "log", " ", "of", " ", "the", " ", "slac", "k", " ", "parameter", "\\", "10", ";", " ", " ", " ", " ", ":", "key", " ", "search", "log", ":", " ", "filename", " ", "int", "o", " ", "whi", "ch", " ", "to", " ", "dump", " ", "the", " ", "search", " ", "log", "\\", "10", ";", " ", " ", " ", " ", ":", "key", " ", "other", "s", ":", " ", "...", "are", " ", "pass", "ed", " ", "through", " ", "to", " ", "the", " ", "grid", " ", "search", " ", "and", "/", "or", " ", "libs", "vm", " ", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "set", "Params_", "(_", "**_", "kwargs_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "problem_", "=_", "svm", "\\u", "problem_", "(_", "self_", "._", "ds_", "[_", "'", "target", "'_", "]_", "._", "flatten_", "(_", ")_", ",_", "self_", "._", "ds_", "[_", "'", "input", "'_", "]_", "._", "tolist_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "search_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "this", " ", "is", " ", "a", " ", "bit", " ", "of", " ", "a", " ", "hack", "..._", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "model_", "=_", "eval_", "(_", "search_", "+_", "\"(", "problem", ",", " ", "self", ".", "svm", "target", ",", " ", "cmi", "n", "=[", "0", ",-", "7", "],", "cma", "x", "=[", "25", ",", "1", "],", " ", "cst", "ep", "=[", "0.", "5", ",", "0.", "2", "],", "plot", "flag", "=", "self", ".", "plot", ",", "search", "log", "=", "self", ".", "search", "log", ",*", "*", "self", ".", "params", ")\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "param_", "=_", "svm", "\\u", "parameter_", "(_", "**_", "self_", "._", "params_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "model_", "=_", "svm", "\\u", "model_", "(_", "problem_", ",_", "param_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "logging_", "._", "info_", "(_", "\"", "Train", "ing", " ", "complete", "d", " ", "with", " ", "parameter", "s", ":\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "logging_", "._", "info_", "(_", "repr_", "(_", "param_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "svm_", "._", "set", "Model_", "(_", "model_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "SV", "MT", "rain", "er_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "save_", "(_", "self_", ",_", "filename_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", " ", "save", " ", "the", " ", "trained", " ", "SV", "M", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "svm_", "._", "save", "Model_", "(_", "filename_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "SV", "MT", "rain", "er_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "load_", "(_", "self_", ",_", "filename_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", " ", "no", " ", "train", "ing", " ", "at", " ", "all", " ", "-", " ", "just", " ", "load", " ", "the", " ", "SV", "M", " ", "model", " ", "from", " ", "a", " ", "file", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "svm_", "._", "load", "Model_", "(_", "filename_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "SV", "MT", "rain", "er_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "set", "Params_", "(_", "self_", ",_", "**_", "kwargs_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", " ", "Set", " ", "parameter", "s", " ", "for", " ", "SV", "M", " ", "train", "ing", ".", " ", "Ap", "art", " ", "from", " ", "the", " ", "ones", " ", "belo", "w", ",", " ", "you", " ", "can", " ", "use", " ", "all", " ", "parameter", "s", " ", "\\", "10", ";", " ", " ", " ", " ", "defin", "ed", " ", "for", " ", "the", " ", "LIBS", "VM", " ", "svm", "\\u", "model", " ", "class", ",", " ", "see", " ", "thei", "r", " ", "documentation", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", ":", "key", " ", "search", "log", ":", " ", "Save", " ", "a", " ", "list", " ", "of", " ", "coordinate", "s", " ", "and", " ", "the", " ", "achieve", "d", " ", "CV", " ", "accu", "rac", "y", " ", "to", " ", "this", " ", "file", ".\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "'", "weight", "'_", "in_", "kwargs_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "params_", "[_", "'", "nr", "\\u", "weight", "'_", "]_", "=_", "len_", "(_", "kwargs_", "[_", "'", "weight", "'_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "'", "log", "2", "C", "'_", "in_", "kwargs_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "params_", "[_", "'", "C", "'_", "]_", "=_", "2_", "**_", "kwargs_", "[_", "'", "log", "2", "C", "'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "kwargs_", "._", "pop_", "(_", "'", "log", "2", "C", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "'", "log", "2g", "'_", "in_", "kwargs_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "params_", "[_", "'", "gamma", "'_", "]_", "=_", "2_", "**_", "kwargs_", "[_", "'", "log", "2g", "'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "kwargs_", "._", "pop_", "(_", "'", "log", "2g", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "'", "search", "log", "'_", "in_", "kwargs_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "search", "log_", "=_", "kwargs_", "[_", "'", "search", "log", "'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "kwargs_", "._", "pop_", "(_", "'", "search", "log", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "params_", "._", "update_", "(_", "kwargs_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "class_", "Grid", "Search_", "(_", "svm", "\\u", "model_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "Help", "er", " ", "class", " ", "used", " ", "by", " ", ":", "class", ":`", "SV", "MT", "rain", "er", "`", " ", "to", " ", "perform", " ", "an", " ", "exhaust", "ive", " ", "grid", " ", "search", ",", " ", "and", " ", "plot", " ", "the", "\\", "10", ";", " ", " ", " ", " ", "result", "ing", " ", "accu", "rac", "y", " ", "surf", "ace", ",", " ", "if", " ", "desi", "red", ".", " ", "Adapt", "ed", " ", "from", " ", "the", " ", "LIBS", "VM", " ", "python", " ", "tool", "kit", ".\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "all", "Pts_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "all", "Scores_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "[SEP]_", "class_", "Grid", "Search_", "(_", "svm", "\\u", "model_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "\\u\\u", "init\\u\\u_", "(_", "self_", ",_", "problem_", ",_", "targets_", ",_", "cmi", "n_", ",_", "cma", "x_", ",_", "cst", "ep_", "=_", "None_", ",_", "cross", "val_", "=_", "5_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "plot", "flag_", "=_", "False_", ",_", "maxd", "epth", "_", "=_", "8_", ",_", "search", "log_", "=_", "'", "grids", "ear", "ch", "\\u", "results", ".", "txt", "'_", ",_", "**_", "params_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", " ", "Set", " ", "up", " ", "(", "log", ")", " ", "grid", " ", "search", " ", "over", " ", "the", " ", "two", " ", "RB", "F", " ", "kernel", " ", "parameter", "s", " ", "C", " ", "and", " ", "gamma", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", ":", "arg", " ", "problem", ":", " ", "the", " ", "LIBS", "VM", " ", "svm", "\\u", "problem", " ", "to", " ", "be", " ", "optimize", "d", ",", " ", "ie", ".", " ", "the", " ", "input", " ", "and", " ", "target", " ", "data", "\\", "10", ";", " ", " ", " ", " ", ":", "arg", " ", "target", "s", ":", " ", "unfo", "rtu", "nat", "el", "y", ",", " ", "the", " ", "target", "s", " ", "used", " ", "in", " ", "the", " ", "problem", " ", "definit", "ion", " ", "have", " ", "to", " ", "be", " ", "give", "n", " ", "again", " ", "here", "\\", "10", ";", " ", " ", " ", " ", ":", "arg", " ", "cmi", "n", ":", " ", "lower", " ", "left", " ", "corn", "er", " ", "of", " ", "the", " ", "log", "2", "C", "/", "log", "2g", "amma", " ", "window", " ", "to", " ", "search", "\\", "10", ";", " ", " ", " ", " ", ":", "arg", " ", "cma", "x", ":", " ", "upper", " ", "right", " ", "corn", "er", " ", "of", " ", "the", " ", "log", "2", "C", "/", "log", "2g", "amma", " ", "window", " ", "to", " ", "search", "\\", "10", ";", " ", " ", " ", " ", ":", "key", " ", "cst", "ep", ":", " ", "step", " ", "widt", "h", " ", "for", " ", "log", "2", "C", " ", "and", " ", "log", "2g", "amma", " ", "(", "ignore", "d", " ", "for", " ", "DO", "E", " ", "search", ")", "\\", "10", ";", " ", " ", " ", " ", ":", "key", " ", "cross", "val", ":", " ", "split", " ", "dataset", " ", "int", "o", " ", "this", " ", "many", " ", "part", "s", " ", "for", " ", "cross", "-", "validation", "\\", "10", ";", " ", " ", " ", " ", ":", "key", " ", "plot", "flag", ":", " ", "if", " ", "Tru", "e", ",", " ", "plot", " ", "the", " ", "error", " ", "surf", "ace", " ", "conto", "ur", " ", "(", "regular", ")", " ", "or", " ", "search", " ", "pattern", " ", "(", "DO", "E", ")", "\\", "10", ";", " ", " ", " ", " ", ":", "key", " ", "maxd", "epth", ":", " ", "maxim", "um", " ", "window", " ", "bisect", "ion", " ", "depth", " ", "(", "DO", "E", " ", "only", ")", "\\", "10", ";", " ", " ", " ", " ", ":", "key", " ", "search", "log", ":", " ", "Save", " ", "a", " ", "list", " ", "of", " ", "coordinate", "s", " ", "and", " ", "the", " ", "achieve", "d", " ", "CV", " ", "accu", "rac", "y", " ", "to", " ", "this", " ", "file", "\\", "10", ";", " ", " ", " ", " ", ":", "key", " ", "other", "s", ":", " ", "...", "are", " ", "pass", "ed", " ", "through", " ", "to", " ", "the", " ", "cross", "\\u", "validation", " ", "method", " ", "of", " ", "LIBS", "VM", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "n", "Pars", "_", "=_", "len_", "(_", "cmi", "n_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "userm", "in_", "=_", "cmi", "n_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "userm", "ax_", "=_", "cma", "x_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "users", "tep_", "=_", "cst", "ep_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "cross", "val_", "=_", "cross", "val_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "plot", "flag_", "=_", "plot", "flag_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "maxd", "epth", "_", "=_", "maxd", "epth", "_", "#", " ", "number", " ", "of", " ", "zoom", "-", "in", " ", "step", "s", " ", "(", "DO", "E", " ", "search", " ", "only", "!)", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "set", " ", "default", " ", "parameter", "s", " ", "for", " ", "training_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "params_", "=_", "params_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "self_", "._", "plot", "flag_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "import_", "pylab_", "as_", "p_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "p_", "._", "ion_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "p_", "._", "figure_", "(_", "figsize_", "=_", "[_", "12_", ",_", "8_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "assert_", "isinstance_", "(_", "problem_", ",_", "svm", "\\u", "problem_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "problem_", "=_", "problem_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "targets_", "=_", "targets_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "res", "file_", "=_", "open_", "(_", "search", "log_", ",_", "'", "w", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "do", " ", "the", " ", "parameter", " ", "search", "ing_", "\\u\\u\\uNL\\u\\u\\u_", "param_", "=_", "self_", "._", "search_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "self_", "._", "plot", "flag_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "p_", "._", "io", "ff_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "p_", "._", "show_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "res", "file_", "._", "close_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "svm", "\\u", "model_", "._", "\\u\\u", "init\\u\\u_", "(_", "self_", ",_", "problem_", ",_", "param_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Grid", "Search_", "(_", "svm", "\\u", "model_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "set", "Params_", "(_", "self_", ",_", "**_", "kwargs_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", " ", "set", " ", "parameter", "s", " ", "for", " ", "SV", "M", " ", "train", "ing", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "'", "weight", "'_", "in_", "kwargs_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "params_", "[_", "'", "nr", "\\u", "weight", "'_", "]_", "=_", "len_", "(_", "kwargs_", "[_", "'", "weight", "'_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "params_", "._", "update_", "(_", "kwargs_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Grid", "Search_", "(_", "svm", "\\u", "model_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "search_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", " ", "iterate", " ", "success", "ive", " ", "parameter", " ", "grid", " ", "refinement", " ", "and", " ", "evaluat", "ion", ";", " ", "adapt", "ed", " ", "from", " ", "LIBS", "VM", " ", "grid", " ", "search", " ", "tool", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "jobs_", "=_", "self_", "._", "calcul", "ate", "\\u", "jobs_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "scores_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "line_", "in_", "jobs_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "for_", "(_", "c_", ",_", "g_", ")_", "in_", "line_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "run", " ", "cross", "-", "validation", " ", "for", " ", "this", " ", "point_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "set", "Params_", "(_", "C_", "=_", "2_", "**_", "c_", ",_", "gamma_", "=_", "2_", "**_", "g_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "param_", "=_", "svm", "\\u", "parameter_", "(_", "**_", "self_", "._", "params_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "cv", "result_", "=_", "array_", "(_", "cross", "\\u", "validation_", "(_", "self_", "._", "problem_", ",_", "param_", ",_", "self_", "._", "cross", "val_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "corr_", ",_", "=_", "where_", "(_", "cv", "result_", "==_", "self_", "._", "targets_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "res_", "=_", "(_", "c_", ",_", "g_", ",_", "float_", "(_", "corr_", "._", "size_", ")_", "/_", "self_", "._", "targets_", "._", "size_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "scores_", "._", "append_", "(_", "res_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "\\u", "save", "\\u", "points_", "(_", "res_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "\\u", "redraw_", "(_", "scores_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "scores_", "=_", "array_", "(_", "scores_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "best_", "=_", "scores_", "[_", "scores_", "[_", ":_", ",_", "0_", "]_", "._", "argmax_", "(_", ")_", ",_", "1_", ":_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "set", "Params_", "(_", "C_", "=_", "2_", "**_", "best_", "[_", "0_", "]_", ",_", "gamma_", "=_", "2_", "**_", "best_", "[_", "1_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "logging_", "._", "info_", "(_", "\"", "best", " ", "log", "2", "C", "=", "%", "12.", "7", "g", ",", " ", "log", "2g", "=", "%", "11.", "7", "g", " ", "\"_", "%_", "(_", "best_", "[_", "0_", "]_", ",_", "best_", "[_", "1_", "]_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "param_", "=_", "svm", "\\u", "parameter_", "(_", "**_", "self_", "._", "params_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "param_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Grid", "Search_", "(_", "svm", "\\u", "model_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "\\u", "permute", "\\u", "sequence_", "(_", "self_", ",_", "seq_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", " ", "help", "er", " ", "function", " ", "to", " ", "create", " ", "a", " ", "nice", " ", "sequence", " ", "of", " ", "refine", "d", " ", "regular", " ", "grids", ";", " ", "from", " ", "LIBS", "VM", " ", "grid", " ", "search", " ", "tool", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "n_", "=_", "len_", "(_", "seq_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "n_", "<=_", "1_", ":_", "return_", "seq_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "mid_", "=_", "int_", "(_", "n_", "/_", "2_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "left_", "=_", "self_", "._", "\\u", "permute", "\\u", "sequence_", "(_", "seq_", "[_", ":_", "mid_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "right_", "=_", "self_", "._", "\\u", "permute", "\\u", "sequence_", "(_", "seq_", "[_", "mid_", "+_", "1_", ":_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "ret_", "=_", "[_", "seq_", "[_", "mid_", "]_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "while_", "left_", "or_", "right_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "left_", ":_", "ret_", "._", "append_", "(_", "left_", "._", "pop_", "(_", "0_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "right_", ":_", "ret_", "._", "append_", "(_", "right_", "._", "pop_", "(_", "0_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "ret_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Grid", "Search_", "(_", "svm", "\\u", "model_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "\\u", "range", "\\u", "f_", "(_", "self_", ",_", "begin_", ",_", "end_", ",_", "step_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", " ", "like", " ", "range", ",", " ", "but", " ", "works", " ", "on", " ", "non", "-", "integ", "er", " ", "too", ";", " ", "from", " ", "LIBS", "VM", " ", "grid", " ", "search", " ", "tool", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "seq_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "while_", "1_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "step_", ">_", "0_", "and_", "begin_", ">_", "end_", ":_", "break_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "step_", "<_", "0_", "and_", "begin_", "<_", "end_", ":_", "break_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "seq_", "._", "append_", "(_", "begin_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "begin_", "=_", "begin_", "+_", "step_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "seq_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Grid", "Search_", "(_", "svm", "\\u", "model_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "calcul", "ate", "\\u", "jobs_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", " ", "like", " ", "range", ",", " ", "but", " ", "works", " ", "on", " ", "non", "-", "integ", "er", " ", "too", ";", " ", "from", " ", "LIBS", "VM", " ", "grid", " ", "search", " ", "tool", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "c\\u", "seq_", "=_", "self_", "._", "\\u", "permute", "\\u", "sequence_", "(_", "self_", "._", "\\u", "range", "\\u", "f_", "(_", "self_", "._", "userm", "in_", "[_", "0_", "]_", ",_", "self_", "._", "userm", "ax_", "[_", "0_", "]_", ",_", "self_", "._", "users", "tep_", "[_", "0_", "]_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "g", "\\u", "seq_", "=_", "self_", "._", "\\u", "permute", "\\u", "sequence_", "(_", "self_", "._", "\\u", "range", "\\u", "f_", "(_", "self_", "._", "userm", "in_", "[_", "1_", "]_", ",_", "self_", "._", "userm", "ax_", "[_", "1_", "]_", ",_", "self_", "._", "users", "tep_", "[_", "1_", "]_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "nr", "\\u", "c_", "=_", "float_", "(_", "len_", "(_", "c\\u", "seq_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "nr", "\\u", "g_", "=_", "float_", "(_", "len_", "(_", "g", "\\u", "seq_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "global_", "total", "\\u", "points_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "total", "\\u", "points_", "=_", "(_", "nr", "\\u", "g_", "+_", "1_", ")_", "*_", "(_", "nr", "\\u", "g_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "i_", "=_", "0_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "j_", "=_", "0_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "jobs_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "while_", "i_", "<_", "nr", "\\u", "c_", "or_", "j_", "<_", "nr", "\\u", "g_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "i_", "/_", "nr", "\\u", "c_", "<_", "j_", "/_", "nr", "\\u", "g_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "increase", " ", "C", " ", "resolution_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "line_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "k_", "in_", "range_", "(_", "0_", ",_", "j_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "line_", "._", "append_", "(_", "(_", "c\\u", "seq_", "[_", "i_", "]_", ",_", "g", "\\u", "seq_", "[_", "k_", "]_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "i_", "=_", "i_", "+_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "jobs_", "._", "append_", "(_", "line_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "increase", " ", "g", " ", "resolution_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "line_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "k_", "in_", "range_", "(_", "0_", ",_", "i_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "line_", "._", "append_", "(_", "(_", "c\\u", "seq_", "[_", "k_", "]_", ",_", "g", "\\u", "seq_", "[_", "j_", "]_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "j_", "=_", "j_", "+_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "jobs_", "._", "append_", "(_", "line_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "jobs_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Grid", "Search_", "(_", "svm", "\\u", "model_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "\\u", "save", "\\u", "points_", "(_", "self_", ",_", "res_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", " ", "save", " ", "the", " ", "list", " ", "of", " ", "points", " ", "and", " ", "correspond", "ing", " ", "score", "s", " ", "int", "o", " ", "a", " ", "file", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "res", "file_", "._", "write_", "(_", "\"%", "g", ",", " ", "%", "g", ",", " ", "%", "g", "\\\\", "n", "\"_", "%_", "res_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "logging_", "._", "info_", "(_", "\"", "log", "2", "C", "=", "%", "g", ",", " ", "log", "2g", "=", "%", "g", ",", " ", "res", "=", "%", "g", "\"_", "%_", "res_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "res", "file_", "._", "flush_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Grid", "Search_", "(_", "svm", "\\u", "model_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "\\u", "redraw_", "(_", "self_", ",_", "db_", ",_", "tofi", "le_", "=_", "0_", ",_", "eta_", "=_", "None_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", " ", "redraw", " ", "the", " ", "update", "d", " ", "grid", " ", "interactive", "ly", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "pylab_", "as_", "p_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "len_", "(_", "db_", ")_", "<=_", "3_", "or_", "not_", "self_", "._", "plot", "flag_", ":_", "return_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", "begin", "\\u", "level", " ", "=", " ", "round", "(", "max", "(", "map", "(", "lambda", "(", "x", "):", "x", "[", "2", "],", "db", ")))", " ", "-", " ", "3_", "\\u\\u\\uNL\\u\\u\\u_", "#", "step", "\\u", "size", " ", "=", " ", "0.25_", "\\u\\u\\uNL\\u\\u\\u_", "n", "Contours", "_", "=_", "25_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", "suff", "ix", " ", "=", " ", "''_", "\\u\\u\\uNL\\u\\u\\u_", "#", "if", " ", "eta", " ", "is", " ", "not", " ", "Non", "e", ":_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", " ", " ", " ", "suff", "ix", " ", "=", " ", "\"", " ", "(", "ETA", ":", " ", "%", "5.2", "f", " ", "min", ")\"", " ", "%", " ", "eta_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "cmp_", "(_", "x_", ",_", "y_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "x_", "[_", "0_", "]_", "<_", "y_", "[_", "0_", "]_", ":_", "return_", "-_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "x_", "[_", "0_", "]_", ">_", "y_", "[_", "0_", "]_", ":_", "return_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "x_", "[_", "1_", "]_", ">_", "y_", "[_", "1_", "]_", ":_", "return_", "-_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "x_", "[_", "1_", "]_", "<_", "y_", "[_", "1_", "]_", ":_", "return_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "0_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "db_", "._", "sort_", "(_", "cmp_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "dba", "rr_", "=_", "p_", "._", "asarray_", "(_", "db_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "reconstruct", " ", "grid", ":", " ", "array", " ", "is", " ", "order", "ed", " ", "along", " ", "first", " ", "and", " ", "second", " ", "dimension_", "\\u\\u\\uNL\\u\\u\\u_", "x_", "=_", "dba", "rr_", "[_", ":_", ",_", "0_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "dim", "y_", "=_", "len_", "(_", "x_", "[_", "x_", "==_", "x_", "[_", "0_", "]_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "dim", "x_", "=_", "x_", "._", "size_", "/_", "dim", "y_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "print_", "(_", "(_", "'", "plott", "ing", ":", " ", "'_", ",_", "dim", "x_", ",_", "dim", "y_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "x_", "=_", "x_", "._", "reshape_", "(_", "dim", "x_", ",_", "dim", "y_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "y_", "=_", "dba", "rr_", "[_", ":_", ",_", "1_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "y_", "=_", "y_", "._", "reshape_", "(_", "dim", "x_", ",_", "dim", "y_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "z_", "=_", "dba", "rr_", "[_", ":_", ",_", "2_", "]_", "._", "reshape_", "(_", "dim", "x_", ",_", "dim", "y_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "plot", " ", "usi", "ng", " ", "manu", "al", " ", "double", " ", "buffer_", "\\u\\u\\uNL\\u\\u\\u_", "p_", "._", "io", "ff_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "p_", "._", "clf_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "p_", "._", "conto", "urf", "_", "(_", "x_", ",_", "y_", ",_", "z_", ",_", "n", "Contours", "_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "p_", "._", "hsv_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "p_", "._", "colorbar_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "p_", "._", "xlim_", "(_", "self_", "._", "userm", "in_", "[_", "0_", "]_", ",_", "self_", "._", "userm", "ax_", "[_", "0_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "p_", "._", "ylim_", "(_", "self_", "._", "userm", "in_", "[_", "1_", "]_", ",_", "self_", "._", "userm", "ax_", "[_", "1_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "p_", "._", "xlabel_", "(_", "r", "'$", "\\\\", "rm", "{", "log", "}\\u", "2", "(", "C", ")$'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "p_", "._", "ylabel_", "(_", "r", "'$", "\\\\", "rm", "{", "log", "}\\u", "2", "(\\\\", "gamma", ")$'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "p_", "._", "ion_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "p_", "._", "draw", "\\u", "if", "\\u", "interactive_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "class_", "Grid", "Sear", "ch", "DO", "E_", "(_", "Grid", "Search_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", " ", "Sam", "e", " ", "as", " ", "Grid", "Sear", "ch", ",", " ", "but", " ", "implement", "s", " ", "a", " ", "design", "-", "of", "-", "experiment", "s", " ", "based", " ", "search", " ", "pattern", ",", " ", "as", "\\", "10", ";", " ", " ", " ", " ", "descri", "bed", " ", "by", " ", "C", ".", " ", "Sta", "elin", ",", " ", "http", "://", "www", ".", "hp", "l", ".", "hp", ".", "com", "/", "tech", "report", "s", "/", "2002", "/", "HP", "L", "-", "2002", "-", "354", "R1", ".", "pdf", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "DO", "E", " ", "pattern", ";", " ", "the", " ", "last", " ", "5", " ", "points", " ", "do", " ", "not", " ", "need", " ", "to", " ", "be", " ", "calculated", " ", "whe", "n", " ", "refi", "ning", " ", "the", " ", "grid", " _", "\\u\\u\\uNL\\u\\u\\u_", "doe", "pat_", "=_", "array_", "(_", "[_", "[_", "0.5_", ",_", "1_", "]_", ",_", "[_", "0.25_", ",_", "0.75_", "]_", ",_", "[_", "0.75_", ",_", "0.75_", "]_", ",_", "[_", "0_", ",_", "0.5_", "]_", ",_", "[_", "1_", ",_", "0.5_", "]_", ",_", "[_", "0.25_", ",_", "0.25_", "]_", ",_", "[_", "0.75_", ",_", "0.25_", "]_", ",_", "[_", "0.5_", ",_", "0_", "]_", ",_", "[_", "0_", ",_", "1_", "]_", ",_", "[_", "1_", ",_", "1_", "]_", ",_", "[_", "0.5_", ",_", "0.5_", "]_", ",_", "[_", "0_", ",_", "0_", "]_", ",_", "[_", "1_", ",_", "0_", "]_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "n", "Pts_", "=_", "13_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "depth_", "=_", "0_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "[SEP]_", "class_", "Grid", "Sear", "ch", "DO", "E_", "(_", "Grid", "Search_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "search_", "(_", "self_", ",_", "cmi", "n_", "=_", "None_", ",_", "cma", "x_", "=_", "None_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", " ", "iterate", " ", "parameter", " ", "grid", " ", "refinement", " ", "and", " ", "evaluat", "ion", " ", "recurs", "ively", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "self_", "._", "depth_", ">_", "self_", "._", "maxd", "epth", "_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "maxim", "um", " ", "search", " ", "depth", " ", "reache", "d", " ", "-", " ", "finish", " ", "up_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "best_", "=_", "self_", "._", "all", "Pts_", "[_", "self_", "._", "all", "Scores_", "._", "argmax_", "(_", ")_", ",_", ":_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "logging_", "._", "info_", "(_", "\"", "best", " ", "log", "2", "C", "=", "%", "12.", "7", "g", ",", " ", "log", "2g", "=", "%", "11.", "7", "g", " ", "\"_", "%_", "(_", "best_", "[_", "0_", "]_", ",_", "best_", "[_", "1_", "]_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "set", "Params_", "(_", "C_", "=_", "2_", "**_", "best_", "[_", "0_", "]_", ",_", "gamma_", "=_", "2_", "**_", "best_", "[_", "1_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "param_", "=_", "svm", "\\u", "parameter_", "(_", "**_", "self_", "._", "params_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "logging_", "._", "info_", "(_", "\"", "Grid", " ", "search", " ", "complete", "d", "!", " ", "Final", " ", "parameter", "s", ":\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "logging_", "._", "info_", "(_", "repr_", "(_", "param_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "param_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "generat", "e", " ", "DO", "E", " ", "grid", "points", " ", "usi", "ng", " ", "current", " ", "range_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "cmi", "n_", "is_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "use", " ", "initial", " ", "values", ",", " ", "if", " ", "none", " ", "given_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "cmi", "n_", "=_", "array_", "(_", "self_", "._", "userm", "in_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "cma", "x_", "=_", "array_", "(_", "self_", "._", "userm", "ax_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "points_", "=_", "self_", "._", "refine", "Grid_", "(_", "cmi", "n_", ",_", "cma", "x_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "calcul", "ate", " ", "score", "s", " ", "for", " ", "all", " ", "grid", " ", "points", " ", "usi", "ng", " ", "n", "-", "fold", " ", "cross", "-", "validation_", "\\u\\u\\uNL\\u\\u\\u_", "scores_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "isn", "ew_", "=_", "array_", "(_", "[_", "True_", "]_", "*_", "self_", "._", "n", "Pts_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "i_", "in_", "range_", "(_", "self_", "._", "n", "Pts_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "idx_", "=_", "self_", "._", "\\u", "find", "Index_", "(_", "points_", "[_", "i_", ",_", ":_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "idx_", ">=_", "0_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "point", " ", "alr", "ead", "y", " ", "exists_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "isn", "ew_", "[_", "i_", "]_", "=_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "scores_", "._", "append_", "(_", "self_", "._", "all", "Scores_", "[_", "idx_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "new", " ", "point", ",", " ", "run", " ", "cross", "-", "validation_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "set", "Params_", "(_", "C_", "=_", "2_", "**_", "points_", "[_", "i_", ",_", "0_", "]_", ",_", "gamma_", "=_", "2_", "**_", "points_", "[_", "i_", ",_", "1_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "param_", "=_", "svm", "\\u", "parameter_", "(_", "**_", "self_", "._", "params_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "cv", "result_", "=_", "array_", "(_", "cross", "\\u", "validation_", "(_", "self_", "._", "problem_", ",_", "param_", ",_", "self_", "._", "cross", "val_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "save", " ", "cross", " ", "validation", " ", "result", " ", "as", " ", "\"%", " ", "correct", "\"", " _", "\\u\\u\\uNL\\u\\u\\u_", "corr_", ",_", "=_", "where_", "(_", "cv", "result_", "==_", "self_", "._", "targets_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "corr_", "=_", "float_", "(_", "corr_", "._", "size_", ")_", "/_", "self_", "._", "targets_", "._", "size_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "scores_", "._", "append_", "(_", "corr_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "\\u", "save", "\\u", "points_", "(_", "(_", "points_", "[_", "i_", ",_", "0_", "]_", ",_", "points_", "[_", "i_", ",_", "1_", "]_", ",_", "corr_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "scores_", "=_", "array_", "(_", "scores_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "find", " ", "max", " ", "and", " ", "new", " ", "ranges", " ", "by", " ", "hal", "ving", " ", "the", " ", "old", " ", "ones", ",", " ", "where", "by_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "entire", " ", "search", " ", "region", " ", "must", " ", "lie", " ", "within", " ", "original", " ", "search", " ", "range_", "\\u\\u\\uNL\\u\\u\\u_", "newc", "tr_", "=_", "points_", "[_", "scores_", "._", "argmax_", "(_", ")_", ",_", ":_", "]_", "._", "copy_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "newdi", "ff_", "=_", "(_", "cma", "x_", "-_", "cmi", "n_", ")_", "/_", "4.0_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "i_", "in_", "range_", "(_", "self_", "._", "n", "Pars", "_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "newc", "tr_", "[_", "i_", "]_", "=_", "min_", "(_", "[_", "max_", "(_", "[_", "newc", "tr_", "[_", "i_", "]_", ",_", "self_", "._", "userm", "in_", "[_", "i_", "]_", "+_", "newdi", "ff_", "[_", "i_", "]_", "]_", ")_", ",_", "self_", "._", "userm", "ax_", "[_", "i_", "]_", "-_", "newdi", "ff_", "[_", "i_", "]_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "cmi", "n_", "=_", "newc", "tr_", "-_", "newdi", "ff_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "cma", "x_", "=_", "newc", "tr_", "+_", "newdi", "ff_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "logging_", "._", "info_", "(_", "\"", "depth", ":\\\\", "t", "%", "3d", "\\\\", "tc", "range", ":\\\\", "t", "%", "g", "\\\\", "tsc", "ore", ":\\\\", "t", "%", "g", "\"_", "%_", "(_", "self_", "._", "depth_", ",_", "cma", "x_", "[_", "0_", "]_", "-_", "cmi", "n_", "[_", "0_", "]_", ",_", "scores_", "._", "max_", "(_", ")_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "append", " ", "points", " ", "and", " ", "score", "s", " ", "to", " ", "the", " ", "full", " ", "list_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "self_", "._", "depth_", "==_", "0_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "all", "Pts_", "=_", "points_", "[_", "isn", "ew_", ",_", ":_", "]_", "._", "copy_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "all", "Scores_", "=_", "scores_", "[_", "isn", "ew_", "]_", "._", "copy_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "all", "Pts_", "=_", "append_", "(_", "self_", "._", "all", "Pts_", ",_", "points_", "[_", "isn", "ew_", ",_", ":_", "]_", ",_", "axis_", "=_", "0_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "all", "Scores_", "=_", "append_", "(_", "self_", "._", "all", "Scores_", ",_", "scores_", "[_", "isn", "ew_", "]_", ",_", "axis_", "=_", "0_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "self_", "._", "plot", "flag_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "import_", "pylab_", "as_", "p_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "self_", "._", "depth_", "==_", "0_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "o", "Plot_", "=_", "p_", "._", "plot_", "(_", "self_", "._", "all", "Pts_", "[_", ":_", ",_", "0_", "]_", ",_", "self_", "._", "all", "Pts_", "[_", ":_", ",_", "1_", "]_", ",_", "'", "o", "'_", ")_", "[_", "0_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "insert", " ", "new", " ", "data", " ", "int", "o", " ", "plot_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "o", "Plot_", "._", "set\\u", "data_", "(_", "self_", "._", "all", "Pts_", "[_", ":_", ",_", "0_", "]_", ",_", "self_", "._", "all", "Pts_", "[_", ":_", ",_", "1_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "p_", "._", "draw_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "recurs", "ively", " ", "call", " ", "ours", "elv", "es_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "depth_", "+=_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "self_", "._", "search_", "(_", "cmi", "n_", ",_", "cma", "x_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Grid", "Sear", "ch", "DO", "E_", "(_", "Grid", "Search_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "refine", "Grid_", "(_", "self_", ",_", "cmi", "n_", ",_", "cma", "x_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", " ", "give", "n", " ", "grid", " ", "bound", "aries", ",", " ", "generat", "e", " ", "the", " ", "correspond", "ing", " ", "DO", "E", " ", "pattern", " ", "from", " ", "template", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "diff_", "=_", "array_", "(_", "(_", "cma", "x_", "-_", "cmi", "n_", ")_", "._", "tolist_", "(_", ")_", "*_", "self_", "._", "n", "Pts_", ")_", "._", "reshape_", "(_", "self_", "._", "n", "Pts_", ",_", "self_", "._", "n", "Pars", "_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "self_", "._", "doe", "pat_", "*_", "diff_", "+_", "array_", "(_", "cmi", "n_", "._", "tolist_", "(_", ")_", "*_", "self_", "._", "n", "Pts_", ")_", "._", "reshape_", "(_", "self_", "._", "n", "Pts_", ",_", "self_", "._", "n", "Pars", "_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Grid", "Sear", "ch", "DO", "E_", "(_", "Grid", "Search_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "\\u", "find", "Index_", "(_", "self_", ",_", "point_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", " ", "dete", "rmin", "es", " ", "whe", "ther", " ", "give", "n", " ", "point", " ", "alr", "ead", "y", " ", "exist", "s", " ", "in", " ", "list", " ", "of", " ", "all", " ", "calculated", " ", "points", ".", "\\", "10", ";", " ", " ", " ", " ", "raise", "s", " ", "exception", " ", "if", " ", "more", " ", "than", " ", "one", " ", "point", " ", "is", " ", "found", ",", " ", "return", "s", " ", "-1", " ", "if", " ", "no", " ", "point", " ", "is", " ", "found", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "self_", "._", "depth_", "==_", "0_", ":_", "return_", "-_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "check_", "=_", "self_", "._", "all", "Pts_", "[_", ":_", ",_", "0_", "]_", "==_", "point_", "[_", "0_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "i_", "in_", "range_", "(_", "1_", ",_", "point_", "._", "size_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "check_", "=_", "check_", "&_", "(_", "self_", "._", "all", "Pts_", "[_", ":_", ",_", "i_", "]_", "==_", "point_", "[_", "i_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "idx_", ",_", "=_", "where_", "(_", "check_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "idx_", "._", "size_", "==_", "0_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "-_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "idx_", "._", "size_", ">_", "1_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "logging_", "._", "error_", "(_", "\"", "Some", "thing", " ", "wen", "t", " ", "wrong", " ", "-", " ", "found", " ", "more", " ", "than", " ", "one", " ", "matchi", "ng", " ", "point", "!\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "logging_", "._", "error_", "(_", "str_", "(_", "point_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "logging_", "._", "error_", "(_", "str_", "(_", "self_", "._", "all", "Pts_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "raise_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "idx_", "[_", "0_", "]_" ]
[ 4, 4, 4, 4, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,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2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 ]
Unused import
frappe/frappe/frappe/utils/sel.py
[ { "content": "# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors\n# MIT License. See license.txt\n\nfrom __future__ import unicode_literals\n\nfrom selenium.webdriver.common.keys import Keys\nfrom selenium import webdriver\nfrom selenium.webdriver.common.by import By\nfrom selenium.webdriver.support.ui import WebDriverWait\nfrom selenium.webdriver.support.select import Select\nfrom selenium.webdriver.support import expected_conditions as EC\nfrom selenium.common.exceptions import TimeoutException\nfrom urllib import unquote\nimport time, subprocess\nimport signal\nimport sys\n\nhost = \"http://localhost\"\npipe = None\nport = \"8000\"\n_driver = None\n_verbose = None\nlogged_in = False\ncur_route = False\ninput_wait = 0\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n", "metadata": "root", "header": "['module', '___EOS___']", "index": 0 }, { "content": "def get_localhost():\n\treturn \"{host}:{port}\".format(host=host, port=port)", "metadata": "root.get_localhost", "header": "['module', '___EOS___']", "index": 26 }, { "content": "def start(verbose=None, driver=None):\n\tglobal _driver, _verbose\n\t_verbose = verbose\n\n\t_driver = getattr(webdriver, driver or \"PhantomJS\")()\n\t_driver.set_window_size(1080,800)\n\n\tsignal.signal(signal.SIGINT, signal_handler)", "metadata": "root.start", "header": "['module', '___EOS___']", "index": 29 }, { "content": "def signal_handler(signal, frame):\n\tclose()\n\tsys.exit(0)", "metadata": "root.signal_handler", "header": "['module', '___EOS___']", "index": 38 }, { "content": "def start_test_server(verbose):\n\tglobal pipe\n\tpipe = subprocess.Popen([\"bench\", \"serve\", \"--port\", port], stdout=subprocess.PIPE, stderr=subprocess.PIPE)\n\t#time.sleep(5)\n\twhile not pipe.stderr.readline():\n\t\ttime.sleep(0.5)\n\tif verbose:\n\t\tprint \"Test server started\"", "metadata": "root.start_test_server", "header": "['module', '___EOS___']", "index": 42 }, { "content": "def get(url):\n\t_driver.get(url)", "metadata": "root.get", "header": "['module', '___EOS___']", "index": 51 }, { "content": "def login(wait_for_id=\"#page-desktop\"):\n\tglobal logged_in\n\tif logged_in:\n\t\treturn\n\tget(get_localhost() + \"/login\")\n\twait(\"#login_email\")\n\tset_input(\"#login_email\", \"Administrator\")\n\tset_input(\"#login_password\", \"admin\", key=Keys.RETURN)\n\twait(wait_for_id)\n\tlogged_in = True", "metadata": "root.login", "header": "['module', '___EOS___']", "index": 54 }, { "content": "def go_to_module(module_name, item=None):\n\tglobal cur_route\n\n\t# desktop\n\tfind(\".navbar-home\", True)[0].click()\n\tcur_route = None\n\twait(\"#page-desktop\")\n\n\tpage = \"Module/\" + module_name\n\tm = find('#page-desktop [data-link=\"{0}\"] .app-icon'.format(page))\n\tif not m:\n\t\tpage = \"List/\" + module_name\n\t\tm = find('#page-desktop [data-link=\"{0}\"] .app-icon'.format(page))\n\tif not m:\n\t\traise Exception, \"Module {0} not found\".format(module_name)\n\n\tm[0].click()\n\twait_for_page(page)\n\n\tif item:\n\t\telem = find('[data-label=\"{0}\"]'.format(item))[0]\n\t\telem.click()\n\t\tpage = elem.get_attribute(\"data-route\")\n\t\twait_for_page(page)", "metadata": "root.go_to_module", "header": "['module', '___EOS___']", "index": 66 }, { "content": "def new_doc(module, doctype):\n\tgo_to_module(module, doctype)\n\tprimary_action()\n\twait_for_page(\"Form/\" + doctype)", "metadata": "root.new_doc", "header": "['module', '___EOS___']", "index": 91 }, { "content": "def add_child(fieldname):\n\tfind('[data-fieldname=\"{0}\"] .grid-add-row'.format(fieldname))[0].click()\n\twait('[data-fieldname=\"{0}\"] .form-grid'.format(fieldname))", "metadata": "root.add_child", "header": "['module', '___EOS___']", "index": 96 }, { "content": "def done_add_child(fieldname):\n\tselector = '[data-fieldname=\"{0}\"] .grid-row-open .btn-success'.format(fieldname)\n\tscroll_to(selector)\n\twait_till_clickable(selector).click()", "metadata": "root.done_add_child", "header": "['module', '___EOS___']", "index": 100 }, { "content": "def find(selector, everywhere=False):\n\tif cur_route and not everywhere:\n\t\tselector = cur_route + \" \" + selector\n\treturn _driver.find_elements_by_css_selector(selector)", "metadata": "root.find", "header": "['module', '___EOS___']", "index": 105 }, { "content": "def set_field(fieldname, value, fieldtype=\"input\"):\n\t_driver.switch_to.window(_driver.current_window_handle)\n\tselector = '{0}[data-fieldname=\"{1}\"]'.format(fieldtype, fieldname)\n\tset_input(selector, value, key=Keys.TAB)\n\twait_for_ajax()", "metadata": "root.set_field", "header": "['module', '___EOS___']", "index": 110 }, { "content": "def set_select(fieldname, value):\n\tselect = Select(find('select[data-fieldname=\"{0}\"]'.format(fieldname))[0])\n\tselect.select_by_value(value)\n\twait_for_ajax()", "metadata": "root.set_select", "header": "['module', '___EOS___']", "index": 116 }, { "content": "def primary_action():\n\tselector = \".page-actions .primary-action\"\n\tscroll_to(selector)\n\twait_till_clickable(selector).click()\n\twait_for_ajax()", "metadata": "root.primary_action", "header": "['module', '___EOS___']", "index": 121 }, { "content": "def wait_for_page(name):\n\tglobal cur_route\n\tcur_route = None\n\troute = '[data-page-route=\"{0}\"]'.format(name)\n\twait_for_ajax()\n\telem = wait(route)\n\twait_for_ajax()\n\tcur_route = route\n\treturn elem", "metadata": "root.wait_for_page", "header": "['module', '___EOS___']", "index": 127 }, { "content": "def wait_till_clickable(selector):\n\tif cur_route:\n\t\tselector = cur_route + \" \" + selector\n\treturn get_wait().until(EC.element_to_be_clickable((By.CSS_SELECTOR, selector)))", "metadata": "root.wait_till_clickable", "header": "['module', '___EOS___']", "index": 137 }, { "content": "def wait_till_visible(selector):\n\tif cur_route:\n\t\tselector = cur_route + \" \" + selector\n\treturn get_wait().until(EC.visibility_of_element_located((By.CSS_SELECTOR, selector)))", "metadata": "root.wait_till_visible", "header": "['module', '___EOS___']", "index": 142 }, { "content": "def wait_for_ajax():\n\twait('body[data-ajax-state=\"complete\"]', True)", "metadata": "root.wait_for_ajax", "header": "['module', '___EOS___']", "index": 147 }, { "content": "def wait_for_state(state):\n\treturn wait(cur_route + '[data-state=\"{0}\"]'.format(state), True)", "metadata": "root.wait_for_state", "header": "['module', '___EOS___']", "index": 150 }, { "content": "def wait(selector, everywhere=False):\n\tif cur_route and not everywhere:\n\t\tselector = cur_route + \" \" + selector\n\n\ttime.sleep(0.5)\n\telem = get_wait().until(EC.presence_of_element_located((By.CSS_SELECTOR, selector)))\n\treturn elem", "metadata": "root.wait", "header": "['module', '___EOS___']", "index": 153 }, { "content": "def get_wait():\n\treturn WebDriverWait(_driver, 20)", "metadata": "root.get_wait", "header": "['module', '___EOS___']", "index": 161 }, { "content": "def set_input(selector, text, key=None):\n\telem = find(selector)[0]\n\telem.clear()\n\telem.send_keys(text)\n\tif key:\n\t\ttime.sleep(0.5)\n\t\telem.send_keys(key)\n\tif input_wait:\n\t\ttime.sleep(input_wait)", "metadata": "root.set_input", "header": "['module', '___EOS___']", "index": 164 }, { "content": "def scroll_to(selector):\n\texecute_script(\"frappe.ui.scroll('{0}')\".format(selector))", "metadata": "root.scroll_to", "header": "['module', '___EOS___']", "index": 174 }, { "content": "def execute_script(js):\n\t_driver.execute_script(js)", "metadata": "root.execute_script", "header": "['module', '___EOS___']", "index": 177 }, { "content": "def close():\n\tglobal _driver, pipe\n\tif _driver:\n\t\t_driver.quit()\n\tif pipe:\n\t\tpipe.kill()\n\t_driver = pipe = None", "metadata": "root.close", "header": "['module', '___EOS___']", "index": 180 } ]
[ { "span": "from selenium.common.exceptions import TimeoutException", "start_line": 11, "start_column": 0, "end_line": 11, "end_column": 55 } ]
[]
1
false
[ "[CLS]_", "Un", "used_", "import_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "#", " ", "Copy", "right", " ", "(", "c", ")", " ", "201", "5", ",", " ", "Fra", "ppe", " ", "Techno", "logi", "es", " ", "Pv", "t", ".", " ", "Lt", "d", ".", " ", "and", " ", "Contributor", "s_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "MIT", " ", "License", ".", " ", "See", " ", "license", ".", "txt_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "from_", "\\u\\u", "future\\u\\u_", "import_", "unicode", "\\u", "literals_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "from_", "selenium_", "._", "webdriver_", "._", "common_", "._", "keys_", "import_", "Keys_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "selenium_", "import_", "webdriver_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "selenium_", "._", "webdriver_", "._", "common_", "._", "by_", "import_", "By_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "selenium_", "._", "webdriver_", "._", "support_", "._", "ui_", "import_", "Web", "Drive", "r", "Wait_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "selenium_", "._", "webdriver_", "._", "support_", "._", "select_", "import_", "Select_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "selenium_", "._", "webdriver_", "._", "support_", "import_", "expected", "\\u", "conditions_", "as_", "EC_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "selenium_", "._", "common_", "._", "exceptions_", "import_", "Time", "out", "Exception_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "urllib_", "import_", "unquote_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "time_", ",_", "subprocess_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "signal_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "sys_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "host_", "=_", "\"", "http", "://", "local", "host", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "pipe_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "port_", "=_", "\"", "800", "0", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u", "driver_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u", "verbose_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "logged", "\\u", "in_", "=_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "cur", "\\u", "route_", "=_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "input", "\\u", "wait_", "=_", "0_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uN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\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "get", "\\u", "local", "host_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "_", "return_", "\"{", "host", "}:", "{", "port", "}\"_", "._", "format_", "(_", "host_", "=_", "host_", ",_", "port_", "=_", "port_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "start_", "(_", "verbose_", "=_", "None_", ",_", "driver_", "=_", "None_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "_", "global_", "\\u", "driver_", ",_", "\\u", "verbose_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u", "verbose_", "=_", "verbose_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u", "driver_", "=_", "getattr_", "(_", "webdriver_", ",_", "driver_", "or_", "\"", "Pha", "nto", "m", "JS", "\"_", ")_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u", "driver_", "._", "set\\u", "window", "\\u", "size_", "(_", "1080", "_", ",_", "800_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "signal_", "._", "signal_", "(_", "signal_", "._", "SIGINT_", ",_", "signal", "\\u", "handler_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "signal", "\\u", "handler_", "(_", "signal_", ",_", "frame_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "_", "close_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "sys_", "._", "exit_", "(_", "0_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "start", "\\u", "test\\u", "server_", "(_", "verbose_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "_", "global_", "pipe_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "pipe_", "=_", "subprocess_", "._", "Popen_", "(_", "[_", "\"", "bench", "\"_", ",_", "\"", "serve", "\"_", ",_", "\"--", "port", "\"_", ",_", "port_", "]_", ",_", "stdout_", "=_", "subprocess_", "._", "PIPE_", ",_", "stderr_", "=_", "subprocess_", "._", "PIPE_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", "time", ".", "sleep", "(", "5", ")_", "\\u\\u\\uNL\\u\\u\\u_", "while_", "not_", "pipe_", "._", "stderr_", "._", "readline_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t_", "time_", "._", "sleep_", "(_", "0.5_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "verbose_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t_", "print_", "\"", "Test", " ", "server", " ", "start", "ed", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "get_", "(_", "url_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "_", "\\u", "driver_", "._", "get_", "(_", "url_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "login_", "(_", "wait", "\\u", "for", "\\u", "id_", "=_", "\"#", "page", "-", "desk", "top", "\"_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "_", "global_", "logged", "\\u", "in_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "logged", "\\u", "in_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t_", "return_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "get_", "(_", "get", "\\u", "local", "host_", "(_", ")_", "+_", "\"/", "login", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "wait_", "(_", "\"#", "login", "\\u", "email", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "set\\u", "input_", "(_", "\"#", "login", "\\u", "email", "\"_", ",_", "\"", "Administra", "tor", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "set\\u", "input_", "(_", "\"#", "login", "\\u", "password", "\"_", ",_", "\"", "admin", "\"_", ",_", "key_", "=_", "Keys_", "._", "RETURN_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "wait_", "(_", "wait", "\\u", "for", "\\u", "id_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "logged", "\\u", "in_", "=_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "go", "\\u", "to", "\\u", "module_", "(_", "module", "\\u", "name_", ",_", "item_", "=_", "None_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "_", "global_", "cur", "\\u", "route_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "desktop_", "\\u\\u\\uNL\\u\\u\\u_", "find_", "(_", "\".", "navbar", "-", "home", "\"_", ",_", "True_", ")_", "[_", "0_", "]_", "._", "click_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "cur", "\\u", "route_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "wait_", "(_", "\"#", "page", "-", "desk", "top", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "page_", "=_", "\"", "Modul", "e", "/\"_", "+_", "module", "\\u", "name_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "m_", "=_", "find_", "(_", "'#", "page", "-", "desk", "top", " ", "[", "data", "-", "link", "=\"", "{", "0", "}\"", "]", " ", ".", "app", "-", "icon", "'_", "._", "format_", "(_", "page_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "not_", "m_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t_", "page_", "=_", "\"", "List", "/\"_", "+_", "module", "\\u", "name_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "m_", "=_", "find_", "(_", "'#", "page", "-", "desk", "top", " ", "[", "data", "-", "link", "=\"", "{", "0", "}\"", "]", " ", ".", "app", "-", "icon", "'_", "._", "format_", "(_", "page_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "not_", "m_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t_", "raise_", "Exception_", ",_", "\"", "Modul", "e", " ", "{", "0", "}", " ", "not", " ", "found", "\"_", "._", "format_", "(_", "module", "\\u", "name_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "m_", "[_", "0_", "]_", "._", "click_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "wait", "\\u", "for", "\\u", "page_", "(_", "page_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "item_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t_", "elem_", "=_", "find_", "(_", "'[", "data", "-", "label", "=\"", "{", "0", "}\"", "]'_", "._", "format_", "(_", "item_", ")_", ")_", "[_", "0_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "elem_", "._", "click_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "page_", "=_", "elem_", "._", "get", "\\u", "attribute_", "(_", "\"", "data", "-", "route", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "wait", "\\u", "for", "\\u", "page_", "(_", "page_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "new", "\\u", "doc_", "(_", "module_", ",_", "doctype_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "_", "go", "\\u", "to", "\\u", "module_", "(_", "module_", ",_", "doctype_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "primary", "\\u", "action_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "wait", "\\u", "for", "\\u", "page_", "(_", "\"", "Form", "/\"_", "+_", "doctype_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "add", "\\u", "child_", "(_", "fieldname_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "_", "find_", "(_", "'[", "data", "-", "field", "name", "=\"", "{", "0", "}\"", "]", " ", ".", "grid", "-", "add", "-", "row", "'_", "._", "format_", "(_", "fieldname_", ")_", ")_", "[_", "0_", "]_", "._", "click_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "wait_", "(_", "'[", "data", "-", "field", "name", "=\"", "{", "0", "}\"", "]", " ", ".", "form", "-", "grid", "'_", "._", "format_", "(_", "fieldname_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "don", "e\\u", "add", "\\u", "child_", "(_", "fieldname_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "_", "selector_", "=_", "'[", "data", "-", "field", "name", "=\"", "{", "0", "}\"", "]", " ", ".", "grid", "-", "row", "-", "open", " ", ".", "btn", "-", "success", "'_", "._", "format_", "(_", "fieldname_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "scroll", "\\u", "to_", "(_", "selector_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "wait", "\\u", "till", "\\u", "click", "able_", "(_", "selector_", ")_", "._", "click_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "find_", "(_", "selector_", ",_", "every", "where_", "=_", "False_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "_", "if_", "cur", "\\u", "route_", "and_", "not_", "every", "where_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t_", "selector_", "=_", "cur", "\\u", "route_", "+_", "\"", " ", "\"_", "+_", "selector_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "\\u", "driver_", "._", "find", "\\u", "element", "s", "\\u", "by", "\\u", "css", "\\u", "selector_", "(_", "selector_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "set\\u", "field_", "(_", "fieldname_", ",_", "value_", ",_", "field", "type_", "=_", "\"", "input", "\"_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "_", "\\u", "driver_", "._", "switch", "\\u", "to_", "._", "window_", "(_", "\\u", "driver_", "._", "current", "\\u", "window", "\\u", "handle_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "selector_", "=_", "'{", "0", "}[", "data", "-", "field", "name", "=\"", "{", "1", "}\"", "]'_", "._", "format_", "(_", "field", "type_", ",_", "fieldname_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "set\\u", "input_", "(_", "selector_", ",_", "value_", ",_", "key_", "=_", "Keys_", "._", "TAB", "_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "wait", "\\u", "for", "\\u", "ajax_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "set\\u", "select_", "(_", "fieldname_", ",_", "value_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "_", "select_", "=_", "Select_", "(_", "find_", "(_", "'", "select", "[", "data", "-", "field", "name", "=\"", "{", "0", "}\"", "]'_", "._", "format_", "(_", "fieldname_", ")_", ")_", "[_", "0_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "select_", "._", "select", "\\u", "by", "\\u", "value_", "(_", "value_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "wait", "\\u", "for", "\\u", "ajax_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "primary", "\\u", "action_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "_", "selector_", "=_", "\".", "page", "-", "action", "s", " ", ".", "primary", "-", "action", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "scroll", "\\u", "to_", "(_", "selector_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "wait", "\\u", "till", "\\u", "click", "able_", "(_", "selector_", ")_", "._", "click_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "wait", "\\u", "for", "\\u", "ajax_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "wait", "\\u", "for", "\\u", "page_", "(_", "name_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "_", "global_", "cur", "\\u", "route_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "cur", "\\u", "route_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "route_", "=_", "'[", "data", "-", "page", "-", "route", "=\"", "{", "0", "}\"", "]'_", "._", "format_", "(_", "name_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "wait", "\\u", "for", "\\u", "ajax_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "elem_", "=_", "wait_", "(_", "route_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "wait", "\\u", "for", "\\u", "ajax_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "cur", "\\u", "route_", "=_", "route_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "elem_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "wait", "\\u", "till", "\\u", "click", "able_", "(_", "selector_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "_", "if_", "cur", "\\u", "route_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t_", "selector_", "=_", "cur", "\\u", "route_", "+_", "\"", " ", "\"_", "+_", "selector_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "get", "\\u", "wait_", "(_", ")_", "._", "until_", "(_", "EC_", "._", "element", "\\u", "to", "\\u", "be", "\\u", "click", "able_", "(_", "(_", "By_", "._", "CS", "S", "\\u", "SELECTO", "R_", ",_", "selector_", ")_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "wait", "\\u", "till", "\\u", "visible_", "(_", "selector_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "_", "if_", "cur", "\\u", "route_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t_", "selector_", "=_", "cur", "\\u", "route_", "+_", "\"", " ", "\"_", "+_", "selector_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "get", "\\u", "wait_", "(_", ")_", "._", "until_", "(_", "EC_", "._", "visi", "bilit", "y", "\\u", "of", "\\u", "element", "\\u", "located", "_", "(_", "(_", "By_", "._", "CS", "S", "\\u", "SELECTO", "R_", ",_", "selector_", ")_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "wait", "\\u", "for", "\\u", "ajax_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "_", "wait_", "(_", "'", "body", "[", "data", "-", "aja", "x", "-", "state", "=\"", "complete", "\"]'_", ",_", "True_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "wait", "\\u", "for", "\\u", "state_", "(_", "state_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "_", "return_", "wait_", "(_", "cur", "\\u", "route_", "+_", "'[", "data", "-", "state", "=\"", "{", "0", "}\"", "]'_", "._", "format_", "(_", "state_", ")_", ",_", "True_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "wait_", "(_", "selector_", ",_", "every", "where_", "=_", "False_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "_", "if_", "cur", "\\u", "route_", "and_", "not_", "every", "where_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t_", "selector_", "=_", "cur", "\\u", "route_", "+_", "\"", " ", "\"_", "+_", "selector_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "time_", "._", "sleep_", "(_", "0.5_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "elem_", "=_", "get", "\\u", "wait_", "(_", ")_", "._", "until_", "(_", "EC_", "._", "presen", "ce", "\\u", "of", "\\u", "element", "\\u", "located", "_", "(_", "(_", "By_", "._", "CS", "S", "\\u", "SELECTO", "R_", ",_", "selector_", ")_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "elem_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "get", "\\u", "wait_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "_", "return_", "Web", "Drive", "r", "Wait_", "(_", "\\u", "driver_", ",_", "20_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "set\\u", "input_", "(_", "selector_", ",_", "text_", ",_", "key_", "=_", "None_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "_", "elem_", "=_", "find_", "(_", "selector_", ")_", "[_", "0_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "elem_", "._", "clear_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "elem_", "._", "send", "\\u", "keys_", "(_", "text_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "key_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t_", "time_", "._", "sleep_", "(_", "0.5_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "elem_", "._", "send", "\\u", "keys_", "(_", "key_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "input", "\\u", "wait_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t_", "time_", "._", "sleep_", "(_", "input", "\\u", "wait_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "scroll", "\\u", "to_", "(_", "selector_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "_", "execute", "\\u", "script_", "(_", "\"", "fra", "ppe", ".", "ui", ".", "scroll", "('{", "0", "}')", "\"_", "._", "format_", "(_", "selector_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "execute", "\\u", "script_", "(_", "js_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "_", "\\u", "driver_", "._", "execute", "\\u", "script_", "(_", "js_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "close_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "_", "global_", "\\u", "driver_", ",_", "pipe_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "\\u", "driver_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t_", "\\u", "driver_", "._", "quit_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "pipe_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t_", "pipe_", "._", "kill_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u", "driver_", "=_", "pipe_", "=_", "None_" ]
[ 4, 4, 4, 4, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 ]
Unnecessary pass
nipy/nitime/nitime/tests/test_timeseries.py
[ { "content": "def test_TimeArray_init_int64():\n \"\"\"Make sure that we can initialize TimeArray with an array of ints\"\"\"\n time = ts.TimeArray(np.int64(1))\n npt.assert_equal(time.__repr__(), '1.0 s')\n\n pass", "metadata": "root.test_TimeArray_init_int64", "header": "['module', '___EOS___']", "index": 109 }, { "content": "def test_event_subclass_slicing():\n \"Subclassing Events should preserve the subclass after slicing\"\n class Events_with_X(ts.Events):\n \"A class which shows as attributes all of the event data\"\n def __getattr__(self,k):\n return self.data[k]\n pass\n time = np.linspace(0,10,11)\n x,y = np.sin(time),np.cos(time)\n e = Events_with_X(time, **dict(x=x,y=y))\n npt.assert_equal(e.x, e.data['x'])\n npt.assert_equal(e.y, e.data['y'])\n slice_of_e = e[:4]\n slice_of_e.x # should not raise attribute error\n slice_of_e.y # should not raise attribute error\n npt.assert_equal(slice_of_e.x, x[:4])\n npt.assert_equal(slice_of_e.y, y[:4])\n assert(slice_of_e.__class__ == Events_with_X)", "metadata": "root.test_event_subclass_slicing", "header": "['module', '___EOS___']", "index": 824 } ]
[ { "span": "pass", "start_line": 114, "start_column": 4, "end_line": 114, "end_column": 8 }, { "span": "pass", "start_line": 830, "start_column": 8, "end_line": 830, "end_column": 12 } ]
[]
1
true
[ "[CLS]_", "Un", "necessar", "y_", "pass_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "Time", "Array", "\\u", "init", "\\u", "int64_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "Make", " ", "sure", " ", "tha", "t", " ", "we", " ", "can", " ", "initialize", " ", "Time", "Array", " ", "with", " ", "an", " ", "array", " ", "of", " ", "ints", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "time_", "=_", "ts_", "._", "Time", "Array_", "(_", "np_", "._", "int64_", "(_", "1_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "npt_", "._", "assert", "\\u", "equal_", "(_", "time_", "._", "\\u\\u", "repr\\u\\u_", "(_", ")_", ",_", "'", "1.0", " ", "s", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "pass_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "event", "\\u", "subclass", "\\u", "slicing", "_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"", "Subc", "lass", "ing", " ", "Event", "s", " ", "shou", "ld", " ", "preserve", " ", "the", " ", "subclass", " ", "after", " ", "slicing", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "class_", "Event", "s", "\\u", "with", "\\u", "X_", "(_", "ts_", "._", "Events_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"", "A", " ", "class", " ", "whi", "ch", " ", "show", "s", " ", "as", " ", "attribute", "s", " ", "all", " ", "of", " ", "the", " ", "event", " ", "data", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "\\u\\u", "getattr\\u\\u_", "(_", "self_", ",_", "k_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "self_", "._", "data_", "[_", "k_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "pass_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "time_", "=_", "np_", "._", "linspace_", "(_", "0_", ",_", "10_", ",_", "11_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "x_", ",_", "y_", "=_", "np_", "._", "sin_", "(_", "time_", ")_", ",_", "np_", "._", "cos_", "(_", "time_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "e_", "=_", "Event", "s", "\\u", "with", "\\u", "X_", "(_", "time_", ",_", "**_", "dict_", "(_", "x_", "=_", "x_", ",_", "y_", "=_", "y_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "npt_", "._", "assert", "\\u", "equal_", "(_", "e_", "._", "x_", ",_", "e_", "._", "data_", "[_", "'", "x", "'_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "npt_", "._", "assert", "\\u", "equal_", "(_", "e_", "._", "y_", ",_", "e_", "._", "data_", "[_", "'", "y", "'_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "slice", "\\u", "of", "\\u", "e_", "=_", "e_", "[_", ":_", "4_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "slice", "\\u", "of", "\\u", "e_", "._", "x_", "#", " ", "shou", "ld", " ", "not", " ", "raise", " ", "attribute", " ", "error_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "slice", "\\u", "of", "\\u", "e_", "._", "y_", "#", " ", "shou", "ld", " ", "not", " ", "raise", " ", "attribute", " ", "error_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "npt_", "._", "assert", "\\u", "equal_", "(_", "slice", "\\u", "of", "\\u", "e_", "._", "x_", ",_", "x_", "[_", ":_", "4_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "npt_", "._", "assert", "\\u", "equal_", "(_", "slice", "\\u", "of", "\\u", "e_", "._", "y_", ",_", "y_", "[_", ":_", "4_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "assert_", "(_", "slice", "\\u", "of", "\\u", "e_", "._", "\\u\\u", "class\\u\\u_", "==_", "Event", "s", "\\u", "with", "\\u", "X_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_" ]
[ 4, 4, 4, 4, 4, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 2, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 ]
`__eq__` not overridden when adding attributes
edoburu/django-parler/parler/utils/views.py
[ { "content": "class TabsList(list):\n", "metadata": "root.TabsList", "header": "['module', '___EOS___']", "index": 74 }, { "content": " def __init__(self, seq=(), css_class=None):\n self.css_class = css_class\n self.current_is_translated = False\n self.allow_deletion = False\n super(TabsList, self).__init__(seq)", "metadata": "root.TabsList.__init__", "header": "['class', 'TabsList', '(', 'list', ')', ':', '___EOS___']", "index": 76 } ]
[ { "span": "class TabsList(list):", "start_line": 74, "start_column": 0, "end_line": 74, "end_column": 21 } ]
[ { "span": "self.css_class ", "start_line": 77, "start_column": 8, "end_line": 77, "end_column": 22 }, { "span": "self.current_is_translated ", "start_line": 78, "start_column": 8, "end_line": 78, "end_column": 34 }, { "span": "self.allow_deletion ", "start_line": 79, "start_column": 8, "end_line": 79, "end_column": 27 } ]
1
false
[ "[CLS]_", "`_", "\\u\\u", "eq\\u\\u_", "`_", "not_", "overrid", "den_", "when_", "addin", "g_", "attributes_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "class_", "Tabs", "List_", "(_", "list_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "[SEP]_", "class_", "Tabs", "List_", "(_", "list_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "def_", "\\u\\u", "init\\u\\u_", "(_", "self_", ",_", "seq_", "=_", "(_", ")_", ",_", "css", "\\u", "class_", "=_", "None_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "css", "\\u", "class_", "=_", "css", "\\u", "class_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "current", "\\u", "is", "\\u", "translated_", "=_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "allow", "\\u", "deletion_", "=_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "super_", "(_", "Tabs", "List_", ",_", "self_", ")_", "._", "\\u\\u", "init\\u\\u_", "(_", "seq_", ")_" ]
[ 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 2, 2, 2, 0, 1, 1, 1, 1, 1, 1, 1, 2, 2, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 1, 1, 1, 1, 1, 1, 2, 2, 2, 3, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 ]
Unused import
facebook/PathPicker/src/colorPrinter.py
[ { "content": "# Copyright (c) 2015-present, Facebook, Inc.\n# All rights reserved.\n#\n# This source code is licensed under the BSD-style license found in the\n# LICENSE file in the root directory of this source tree. An additional grant\n# of patent rights can be found in the PATENTS file in the same directory.\n#\nfrom __future__ import print_function\n\nimport output\n\n\n", "metadata": "root", "header": "['module', '___EOS___']", "index": 0 }, { "content": "class ColorPrinter(object):\n\n \"\"\"A thin wrapper over screens in ncurses that caches colors and\n attribute state\"\"\"\n\n DEFAULT_COLOR_INDEX = 1\n CURRENT_COLORS = -1\n\n\n\n", "metadata": "root.ColorPrinter", "header": "['module', '___EOS___']", "index": 12 }, { "content": " def __init__(self, screen, cursesAPI):\n self.colors = {}\n self.colors[(0, 0)] = 0 # 0,0 = white on black is hardcoded\n # in general, we want to use -1,-1 for most \"normal\" text printing\n self.colors[(-1, -1)] = self.DEFAULT_COLOR_INDEX\n self.cursesAPI = cursesAPI\n self.cursesAPI.initPair(self.DEFAULT_COLOR_INDEX, -1, -1)\n self.screen = screen\n self.currentAttributes = False # initialized in setAttributes", "metadata": "root.ColorPrinter.__init__", "header": "['class', 'ColorPrinter', '(', 'object', ')', ':', '___EOS___']", "index": 20 }, { "content": " def setAttributes(self, foreColor, backColor, other):\n self.currentAttributes = self.getAttributes(foreColor, backColor,\n other)", "metadata": "root.ColorPrinter.setAttributes", "header": "['class', 'ColorPrinter', '(', 'object', ')', ':', '___EOS___']", "index": 30 }, { "content": " def getAttributes(self, foreColor, backColor, other):\n colorIndex = -1\n colorPair = (foreColor, backColor)\n if not colorPair in self.colors:\n newIndex = len(self.colors)\n if newIndex < self.cursesAPI.getColorPairs():\n self.cursesAPI.initPair(newIndex, foreColor, backColor)\n self.colors[colorPair] = newIndex\n colorIndex = newIndex\n else:\n colorIndex = self.colors[colorPair]\n\n attr = self.cursesAPI.colorPair(colorIndex)\n\n attr = attr | other\n\n return attr", "metadata": "root.ColorPrinter.getAttributes", "header": "['class', 'ColorPrinter', '(', 'object', ')', ':', '___EOS___']", "index": 34 }, { "content": " def addstr(self, y, x, text, attr=None):\n if attr is None:\n attr = self.cursesAPI.colorPair(self.DEFAULT_COLOR_INDEX)\n elif attr == self.CURRENT_COLORS:\n attr = self.currentAttributes\n\n self.screen.addstr(y, x, text, attr)", "metadata": "root.ColorPrinter.addstr", "header": "['class', 'ColorPrinter', '(', 'object', ')', ':', '___EOS___']", "index": 52 } ]
[ { "span": "import output", "start_line": 9, "start_column": 0, "end_line": 9, "end_column": 13 } ]
[]
1
false
[ "[CLS]_", "Un", "used_", "import_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "#", " ", "Copy", "right", " ", "(", "c", ")", " ", "201", "5", "-", "presen", "t", ",", " ", "Face", "book", ",", " ", "Inc", "._", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "All", " ", "rights", " ", "reserve", "d", "._", "\\u\\u\\uNL\\u\\u\\u_", "#", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Thi", "s", " ", "source", " ", "code", " ", "is", " ", "license", "d", " ", "under", " ", "the", " ", "BS", "D", "-", "style", " ", "license", " ", "found", " ", "in", " ", "the_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "LICENSE", " ", "file", " ", "in", " ", "the", " ", "root", " ", "director", "y", " ", "of", " ", "this", " ", "source", " ", "tree", ".", " ", "An", " ", "addition", "al", " ", "grant_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "of", " ", "pate", "nt", " ", "rights", " ", "can", " ", "be", " ", "found", " ", "in", " ", "the", " ", "PAT", "ENT", "S", " ", "file", " ", "in", " ", "the", " ", "same", " ", "director", "y", "._", "\\u\\u\\uNL\\u\\u\\u_", "#", "_", "\\u\\u\\uNL\\u\\u\\u_", "from_", "\\u\\u", "future\\u\\u_", "import_", "print", "\\u", "function_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "import_", "output_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "class_", "Color", "Printer_", "(_", "object_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "A", " ", "thin", " ", "wrapp", "er", " ", "over", " ", "screens", " ", "in", " ", "ncu", "rse", "s", " ", "tha", "t", " ", "cache", "s", " ", "colors", " ", "and", "\\", "10", ";", " ", " ", " ", " ", "attribute", " ", "state", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "DEF", "AUL", "T", "\\u", "COLOR", "\\u", "INDEX_", "=_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "CURREN", "T", "\\u", "COLORS_", "=_", "-_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "[SEP]_", "class_", "Color", "Printer_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "\\u\\u", "init\\u\\u_", "(_", "self_", ",_", "screen_", ",_", "curse", "s", "API_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "colors_", "=_", "{_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "colors_", "[_", "(_", "0_", ",_", "0_", ")_", "]_", "=_", "0_", "#", " ", "0", ",", "0", " ", "=", " ", "white", " ", "on", " ", "black", " ", "is", " ", "hard", "code", "d_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "in", " ", "genera", "l", ",", " ", "we", " ", "want", " ", "to", " ", "use", " ", "-1", ",-", "1", " ", "for", " ", "most", " ", "\"", "normal", "\"", " ", "text", " ", "printin", "g_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "colors_", "[_", "(_", "-_", "1_", ",_", "-_", "1_", ")_", "]_", "=_", "self_", "._", "DEF", "AUL", "T", "\\u", "COLOR", "\\u", "INDEX_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "curse", "s", "API_", "=_", "curse", "s", "API_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "curse", "s", "API_", "._", "init", "Pair_", "(_", "self_", "._", "DEF", "AUL", "T", "\\u", "COLOR", "\\u", "INDEX_", ",_", "-_", "1_", ",_", "-_", "1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "screen_", "=_", "screen_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "current", "Attributes_", "=_", "False_", "#", " ", "initialize", "d", " ", "in", " ", "set", "Attributes_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Color", "Printer_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "set", "Attributes_", "(_", "self_", ",_", "fore", "Color_", ",_", "back", "Color_", ",_", "other_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "current", "Attributes_", "=_", "self_", "._", "get", "Attributes_", "(_", "fore", "Color_", ",_", "back", "Color_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "other_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Color", "Printer_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "get", "Attributes_", "(_", "self_", ",_", "fore", "Color_", ",_", "back", "Color_", ",_", "other_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "color", "Index_", "=_", "-_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "color", "Pair_", "=_", "(_", "fore", "Color_", ",_", "back", "Color_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "not_", "color", "Pair_", "in_", "self_", "._", "colors_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "new", "Index_", "=_", "len_", "(_", "self_", "._", "colors_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "new", "Index_", "<_", "self_", "._", "curse", "s", "API_", "._", "get", "Color", "Pairs_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "curse", "s", "API_", "._", "init", "Pair_", "(_", "new", "Index_", ",_", "fore", "Color_", ",_", "back", "Color_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "colors_", "[_", "color", "Pair_", "]_", "=_", "new", "Index_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "color", "Index_", "=_", "new", "Index_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "color", "Index_", "=_", "self_", "._", "colors_", "[_", "color", "Pair_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "attr_", "=_", "self_", "._", "curse", "s", "API_", "._", "color", "Pair_", "(_", "color", "Index_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "attr_", "=_", "attr_", "|_", "other_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "return_", "attr_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Color", "Printer_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "addstr_", "(_", "self_", ",_", "y_", ",_", "x_", ",_", "text_", ",_", "attr_", "=_", "None_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "attr_", "is_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "attr_", "=_", "self_", "._", "curse", "s", "API_", "._", "color", "Pair_", "(_", "self_", "._", "DEF", "AUL", "T", "\\u", "COLOR", "\\u", "INDEX_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "attr_", "==_", "self_", "._", "CURREN", "T", "\\u", "COLORS_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "attr_", "=_", "self_", "._", "current", "Attributes_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "screen_", "._", "addstr_", "(_", "y_", ",_", "x_", ",_", "text_", ",_", "attr_", ")_" ]
[ 4, 4, 4, 4, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 1, 2, 2, 2, 2, 2, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 ]
Unused local variable
ekzhu/datasketch/benchmark/lsh_benchmark.py
[ { "content": "def benchmark_groud_truth(threshold, index_data, query_data):\n times = []\n results = []\n for q in query_data.shingles:\n start = time.clock()\n result = []\n for key, a in zip(index_data.filenames, index_data.shingles):\n intersection = 0\n for w in a:\n if w in q:\n intersection += 1\n j = float(intersection) / float(len(a) + len(q) - intersection)\n if j >= threshold:\n result.append(key)\n duration = time.clock() - start\n results.append(result)\n return times, results", "metadata": "root.benchmark_groud_truth", "header": "['module', '___EOS___']", "index": 68 } ]
[ { "span": "duration ", "start_line": 82, "start_column": 8, "end_line": 82, "end_column": 16 } ]
[]
1
true
[ "[CLS]_", "Un", "used_", "local_", "variable_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "bench", "mark", "\\u", "grou", "d\\u", "truth_", "(_", "threshold_", ",_", "index", "\\u", "data_", ",_", "query", "\\u", "data_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "times_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "results_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "q_", "in_", "query", "\\u", "data_", "._", "shing", "les_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "start_", "=_", "time_", "._", "clock_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "result_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "key_", ",_", "a_", "in_", "zip_", "(_", "index", "\\u", "data_", "._", "filenames_", ",_", "index", "\\u", "data_", "._", "shing", "les_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "intersection_", "=_", "0_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "w_", "in_", "a_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "w_", "in_", "q_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "intersection_", "+=_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "j_", "=_", "float_", "(_", "intersection_", ")_", "/_", "float_", "(_", "len_", "(_", "a_", ")_", "+_", "len_", "(_", "q_", ")_", "-_", "intersection_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "j_", ">=_", "threshold_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "result_", "._", "append_", "(_", "key_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "duration_", "=_", "time_", "._", "clock_", "(_", ")_", "-_", "start_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "results_", "._", "append_", "(_", "result_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "times_", ",_", "results_", "\\u\\u\\uNEWLINE\\u\\u\\u_" ]
[ 4, 4, 4, 4, 4, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 ]
Unused import
edoburu/django-fluent-contents/fluent_contents/plugins/sharedcontent/south_migrations/0003_migrate_translated_fields.py
[ { "content": "# -*- coding: utf-8 -*-\nimport datetime\nfrom django.core.exceptions import ObjectDoesNotExist\nfrom south.db import db\nfrom south.v2 import DataMigration\nfrom django.db import models\nfrom fluent_contents import appsettings\n\n\n", "metadata": "root", "header": "['module', '___EOS___']", "index": 0 }, { "content": "class Migration(DataMigration):\n\n\n\n models = {\n u'contenttypes.contenttype': {\n 'Meta': {'ordering': \"('name',)\", 'unique_together': \"(('app_label', 'model'),)\", 'object_name': 'ContentType', 'db_table': \"'django_content_type'\"},\n 'app_label': ('django.db.models.fields.CharField', [], {'max_length': '100'}),\n u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),\n 'model': ('django.db.models.fields.CharField', [], {'max_length': '100'}),\n 'name': ('django.db.models.fields.CharField', [], {'max_length': '100'})\n },\n 'fluent_contents.contentitem': {\n 'Meta': {'ordering': \"('placeholder', 'sort_order')\", 'object_name': 'ContentItem'},\n u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),\n 'language_code': ('django.db.models.fields.CharField', [], {'default': \"''\", 'max_length': '15', 'db_index': 'True'}),\n 'parent_id': ('django.db.models.fields.IntegerField', [], {'null': 'True'}),\n 'parent_type': ('django.db.models.fields.related.ForeignKey', [], {'to': u\"orm['contenttypes.ContentType']\"}),\n 'placeholder': ('django.db.models.fields.related.ForeignKey', [], {'related_name': \"'contentitems'\", 'null': 'True', 'on_delete': 'models.SET_NULL', 'to': \"orm['fluent_contents.Placeholder']\"}),\n 'polymorphic_ctype': ('django.db.models.fields.related.ForeignKey', [], {'related_name': \"'polymorphic_fluent_contents.contentitem_set'\", 'null': 'True', 'to': u\"orm['contenttypes.ContentType']\"}),\n 'sort_order': ('django.db.models.fields.IntegerField', [], {'default': '1', 'db_index': 'True'})\n },\n 'fluent_contents.placeholder': {\n 'Meta': {'unique_together': \"(('parent_type', 'parent_id', 'slot'),)\", 'object_name': 'Placeholder'},\n u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),\n 'parent_id': ('django.db.models.fields.IntegerField', [], {'null': 'True'}),\n 'parent_type': ('django.db.models.fields.related.ForeignKey', [], {'to': u\"orm['contenttypes.ContentType']\", 'null': 'True', 'blank': 'True'}),\n 'role': ('django.db.models.fields.CharField', [], {'default': \"'m'\", 'max_length': '1'}),\n 'slot': ('django.db.models.fields.SlugField', [], {'max_length': '50'}),\n 'title': ('django.db.models.fields.CharField', [], {'max_length': '255', 'blank': 'True'})\n },\n u'sharedcontent.sharedcontent': {\n 'Meta': {'object_name': 'SharedContent'},\n u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),\n 'slug': ('django.db.models.fields.SlugField', [], {'unique': 'True', 'max_length': '50'}),\n 'title': ('django.db.models.fields.CharField', [], {'max_length': '200'})\n },\n u'sharedcontent.sharedcontent_translation': {\n 'Meta': {'unique_together': \"[('language_code', 'master')]\", 'object_name': 'SharedContent_Translation'},\n u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),\n 'language_code': ('django.db.models.fields.CharField', [], {'max_length': '15', 'db_index': 'True'}),\n 'master': ('django.db.models.fields.related.ForeignKey', [], {'related_name': \"'translations'\", 'null': 'True', 'to': u\"orm['sharedcontent.SharedContent']\"}),\n 'title': ('django.db.models.fields.CharField', [], {'max_length': '200'})\n },\n u'sharedcontent.sharedcontentitem': {\n 'Meta': {'ordering': \"('placeholder', 'sort_order')\", 'object_name': 'SharedContentItem', 'db_table': \"u'contentitem_sharedcontent_sharedcontentitem'\", '_ormbases': ['fluent_contents.ContentItem']},\n u'contentitem_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': \"orm['fluent_contents.ContentItem']\", 'unique': 'True', 'primary_key': 'True'}),\n 'shared_content': ('django.db.models.fields.related.ForeignKey', [], {'related_name': \"'shared_content_items'\", 'to': u\"orm['sharedcontent.SharedContent']\"})\n }\n }\n\n complete_apps = ['sharedcontent']\n symmetrical = True", "metadata": "root.Migration", "header": "['module', '___EOS___']", "index": 9 }, { "content": " def forwards(self, orm):\n db.execute(\n 'INSERT INTO sharedcontent_sharedcontent_translation(title, language_code, master_id)'\n ' SELECT title, %s, id FROM sharedcontent_sharedcontent',\n [appsettings.FLUENT_CONTENTS_DEFAULT_LANGUAGE_CODE]\n )", "metadata": "root.Migration.forwards", "header": "['class', 'Migration', '(', 'DataMigration', ')', ':', '___EOS___']", "index": 11 }, { "content": " def backwards(self, orm):\n # Convert all fields back to the single-language table.\n for sharedcontent in orm['sharedcontent.SharedContent'].objects.all():\n translations = orm['sharedcontent.SharedContent_Translation'].objects.filter(master_id=sharedcontent.id)\n try:\n # Try default translation\n translation = translations.get(language_code=appsettings.FLUENT_CONTENTS_DEFAULT_LANGUAGE_CODE)\n except ObjectDoesNotExist:\n try:\n # Try internal fallback\n translation = translations.get(language_code__in=('en-us', 'en'))\n except ObjectDoesNotExist:\n # Hope there is a single translation\n translation = translations.get()\n\n sharedcontent.title = translation.title\n sharedcontent.save()", "metadata": "root.Migration.backwards", "header": "['class', 'Migration', '(', 'DataMigration', ')', ':', '___EOS___']", "index": 18 } ]
[ { "span": "import datetime", "start_line": 1, "start_column": 0, "end_line": 1, "end_column": 15 }, { "span": "from django.db import models", "start_line": 5, "start_column": 0, "end_line": 5, "end_column": 28 } ]
[]
1
false
[ "[CLS]_", "Un", "used_", "import_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "#", " ", "-*-", " ", "codi", "ng", ":", " ", "utf", "-", "8", " ", "-*-", "_", "\\u\\u\\uNL\\u\\u\\u_", "import_", "datetime_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "django_", "._", "core_", "._", "exceptions_", "import_", "Object", "Do", "es", "Not", "Exist_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "south_", "._", "db_", "import_", "db_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "south_", "._", "v2_", "import_", "Data", "Migration_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "django_", "._", "db_", "import_", "models_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "fluen", "t", "\\u", "contents_", "import_", "appse", "ttings_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "class_", "Migration_", "(_", "Data", "Migration_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "models_", "=_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "u", "'", "contenttype", "s", ".", "contenttype", "'_", ":_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "'", "Meta", "'_", ":_", "{_", "'", "orderi", "ng", "'_", ":_", "\"(", "'", "name", "',)\"_", ",_", "'", "unique", "\\u", "tog", "ether", "'_", ":_", "\"(", "('", "app", "\\u", "label", "',", " ", "'", "model", "'),)\"_", ",_", "'", "object\\u", "name", "'_", ":_", "'", "Conten", "t", "Type", "'_", ",_", "'", "db", "\\u", "table", "'_", ":_", "\"'", "django", "\\u", "content", "\\u", "type", "'\"_", "}_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "app", "\\u", "label", "'_", ":_", "(_", "'", "django", ".", "db", ".", "model", "s", ".", "fields", ".", "Char", "Field", "'_", ",_", "[_", "]_", ",_", "{_", "'", "max", "\\u", "length", "'_", ":_", "'", "100", "'_", "}_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "u", "'", "id", "'_", ":_", "(_", "'", "django", ".", "db", ".", "model", "s", ".", "fields", ".", "Auto", "Field", "'_", ",_", "[_", "]_", ",_", "{_", "'", "primary", "\\u", "key", "'_", ":_", "'", "Tru", "e", "'_", "}_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "model", "'_", ":_", "(_", "'", "django", ".", "db", ".", "model", "s", ".", "fields", ".", "Char", "Field", "'_", ",_", "[_", "]_", ",_", "{_", "'", "max", "\\u", "length", "'_", ":_", "'", "100", "'_", "}_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "name", "'_", ":_", "(_", "'", "django", ".", "db", ".", "model", "s", ".", "fields", ".", "Char", "Field", "'_", ",_", "[_", "]_", ",_", "{_", "'", "max", "\\u", "length", "'_", ":_", "'", "100", "'_", "}_", ")_", "\\u\\u\\uNL\\u\\u\\u_", "}_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "fluen", "t", "\\u", "content", "s", ".", "content", "item", "'_", ":_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "'", "Meta", "'_", ":_", "{_", "'", "orderi", "ng", "'_", ":_", "\"(", "'", "placehold", "er", "',", " ", "'", "sort", "\\u", "order", "')\"_", ",_", "'", "object\\u", "name", "'_", ":_", "'", "Conten", "t", "Item", "'_", "}_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "u", "'", "id", "'_", ":_", "(_", "'", "django", ".", "db", ".", "model", "s", ".", "fields", ".", "Auto", "Field", "'_", ",_", "[_", "]_", ",_", "{_", "'", "primary", "\\u", "key", "'_", ":_", "'", "Tru", "e", "'_", "}_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "language", "\\u", "code", "'_", ":_", "(_", "'", "django", ".", "db", ".", "model", "s", ".", "fields", ".", "Char", "Field", "'_", ",_", "[_", "]_", ",_", "{_", "'", "default", "'_", ":_", "\"''\"_", ",_", "'", "max", "\\u", "length", "'_", ":_", "'", "15", "'_", ",_", "'", "db", "\\u", "index", "'_", ":_", "'", "Tru", "e", "'_", "}_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "parent", "\\u", "id", "'_", ":_", "(_", "'", "django", ".", "db", ".", "model", "s", ".", "fields", ".", "Integer", "Field", "'_", ",_", "[_", "]_", ",_", "{_", "'", "null", "'_", ":_", "'", "Tru", "e", "'_", "}_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "parent", "\\u", "type", "'_", ":_", "(_", "'", "django", ".", "db", ".", "model", "s", ".", "fields", ".", "relate", "d", ".", "Fore", "ign", "Key", "'_", ",_", "[_", "]_", ",_", "{_", "'", "to", "'_", ":_", "u", "\"", "orm", "['", "contenttype", "s", ".", "Conten", "t", "Type", "']\"_", "}_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "placehold", "er", "'_", ":_", "(_", "'", "django", ".", "db", ".", "model", "s", ".", "fields", ".", "relate", "d", ".", "Fore", "ign", "Key", "'_", ",_", "[_", "]_", ",_", "{_", "'", "relate", "d\\u", "name", "'_", ":_", "\"'", "content", "items", "'\"_", ",_", "'", "null", "'_", ":_", "'", "Tru", "e", "'_", ",_", "'", "on", "\\u", "delete", "'_", ":_", "'", "model", "s", ".", "SET", "\\u", "NULL", "'_", ",_", "'", "to", "'_", ":_", "\"", "orm", "['", "fluen", "t", "\\u", "content", "s", ".", "Place", "holder", "']\"_", "}_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "polymorphic", "\\u", "ctype", "'_", ":_", "(_", "'", "django", ".", "db", ".", "model", "s", ".", "fields", ".", "relate", "d", ".", "Fore", "ign", "Key", "'_", ",_", "[_", "]_", ",_", "{_", "'", "relate", "d\\u", "name", "'_", ":_", "\"'", "polymorphic", "\\u", "fluen", "t", "\\u", "content", "s", ".", "content", "item", "\\u", "set", "'\"_", ",_", "'", "null", "'_", ":_", "'", "Tru", "e", "'_", ",_", "'", "to", "'_", ":_", "u", "\"", "orm", "['", "contenttype", "s", ".", "Conten", "t", "Type", "']\"_", "}_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "sort", "\\u", "order", "'_", ":_", "(_", "'", "django", ".", "db", ".", "model", "s", ".", "fields", ".", "Integer", "Field", "'_", ",_", "[_", "]_", ",_", "{_", "'", "default", "'_", ":_", "'", "1", "'_", ",_", "'", "db", "\\u", "index", "'_", ":_", "'", "Tru", "e", "'_", "}_", ")_", "\\u\\u\\uNL\\u\\u\\u_", "}_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "fluen", "t", "\\u", "content", "s", ".", "placehold", "er", "'_", ":_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "'", "Meta", "'_", ":_", "{_", "'", "unique", "\\u", "tog", "ether", "'_", ":_", "\"(", "('", "parent", "\\u", "type", "',", " ", "'", "parent", "\\u", "id", "',", " ", "'", "slot", "'),)\"_", ",_", "'", "object\\u", "name", "'_", ":_", "'", "Place", "holder", "'_", "}_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "u", "'", "id", "'_", ":_", "(_", "'", "django", ".", "db", ".", "model", "s", ".", "fields", ".", "Auto", "Field", "'_", ",_", "[_", "]_", ",_", "{_", "'", "primary", "\\u", "key", "'_", ":_", "'", "Tru", "e", "'_", "}_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "parent", "\\u", "id", "'_", ":_", "(_", "'", "django", ".", "db", ".", "model", "s", ".", "fields", ".", "Integer", "Field", "'_", ",_", "[_", "]_", ",_", "{_", "'", "null", "'_", ":_", "'", "Tru", "e", "'_", "}_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "parent", "\\u", "type", "'_", ":_", "(_", "'", "django", ".", "db", ".", "model", "s", ".", "fields", ".", "relate", "d", ".", "Fore", "ign", "Key", "'_", ",_", "[_", "]_", ",_", "{_", "'", "to", "'_", ":_", "u", "\"", "orm", "['", "contenttype", "s", ".", "Conten", "t", "Type", "']\"_", ",_", "'", "null", "'_", ":_", "'", "Tru", "e", "'_", ",_", "'", "blank", "'_", ":_", "'", "Tru", "e", "'_", "}_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "role", "'_", ":_", "(_", "'", "django", ".", "db", ".", "model", "s", ".", "fields", ".", "Char", "Field", "'_", ",_", "[_", "]_", ",_", "{_", "'", "default", "'_", ":_", "\"'", "m", "'\"_", ",_", "'", "max", "\\u", "length", "'_", ":_", "'", "1", "'_", "}_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "slot", "'_", ":_", "(_", "'", "django", ".", "db", ".", "model", "s", ".", "fields", ".", "Sl", "ug", "Field", "'_", ",_", "[_", "]_", ",_", "{_", "'", "max", "\\u", "length", "'_", ":_", "'", "50", "'_", "}_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "title", "'_", ":_", "(_", "'", "django", ".", "db", ".", "model", "s", ".", "fields", ".", "Char", "Field", "'_", ",_", "[_", "]_", ",_", "{_", "'", "max", "\\u", "length", "'_", ":_", "'", "255", "'_", ",_", "'", "blank", "'_", ":_", "'", "Tru", "e", "'_", "}_", ")_", "\\u\\u\\uNL\\u\\u\\u_", "}_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "u", "'", "shared", "content", ".", "shared", "content", "'_", ":_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "'", "Meta", "'_", ":_", "{_", "'", "object\\u", "name", "'_", ":_", "'", "Share", "d", "Conten", "t", "'_", "}_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "u", "'", "id", "'_", ":_", "(_", "'", "django", ".", "db", ".", "model", "s", ".", "fields", ".", "Auto", "Field", "'_", ",_", "[_", "]_", ",_", "{_", "'", "primary", "\\u", "key", "'_", ":_", "'", "Tru", "e", "'_", "}_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "slug", "'_", ":_", "(_", "'", "django", ".", "db", ".", "model", "s", ".", "fields", ".", "Sl", "ug", "Field", "'_", ",_", "[_", "]_", ",_", "{_", "'", "unique", "'_", ":_", "'", "Tru", "e", "'_", ",_", "'", "max", "\\u", "length", "'_", ":_", "'", "50", "'_", "}_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "title", "'_", ":_", "(_", "'", "django", ".", "db", ".", "model", "s", ".", "fields", ".", "Char", "Field", "'_", ",_", "[_", "]_", ",_", "{_", "'", "max", "\\u", "length", "'_", ":_", "'", "200", "'_", "}_", ")_", "\\u\\u\\uNL\\u\\u\\u_", "}_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "u", "'", "shared", "content", ".", "shared", "content", "\\u", "translatio", "n", "'_", ":_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "'", "Meta", "'_", ":_", "{_", "'", "unique", "\\u", "tog", "ether", "'_", ":_", "\"[", "('", "language", "\\u", "code", "',", " ", "'", "master", "')]\"_", ",_", "'", "object\\u", "name", "'_", ":_", "'", "Share", "d", "Conten", "t", "\\u", "Translat", "ion", "'_", "}_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "u", "'", "id", "'_", ":_", "(_", "'", "django", ".", "db", ".", "model", "s", ".", "fields", ".", "Auto", "Field", "'_", ",_", "[_", "]_", ",_", "{_", "'", "primary", "\\u", "key", "'_", ":_", "'", "Tru", "e", "'_", "}_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "language", "\\u", "code", "'_", ":_", "(_", "'", "django", ".", "db", ".", "model", "s", ".", "fields", ".", "Char", "Field", "'_", ",_", "[_", "]_", ",_", "{_", "'", "max", "\\u", "length", "'_", ":_", "'", "15", "'_", ",_", "'", "db", "\\u", "index", "'_", ":_", "'", "Tru", "e", "'_", "}_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "master", "'_", ":_", "(_", "'", "django", ".", "db", ".", "model", "s", ".", "fields", ".", "relate", "d", ".", "Fore", "ign", "Key", "'_", ",_", "[_", "]_", ",_", "{_", "'", "relate", "d\\u", "name", "'_", ":_", "\"'", "translatio", "ns", "'\"_", ",_", "'", "null", "'_", ":_", "'", "Tru", "e", "'_", ",_", "'", "to", "'_", ":_", "u", "\"", "orm", "['", "shared", "content", ".", "Share", "d", "Conten", "t", "']\"_", "}_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "title", "'_", ":_", "(_", "'", "django", ".", "db", ".", "model", "s", ".", "fields", ".", "Char", "Field", "'_", ",_", "[_", "]_", ",_", "{_", "'", "max", "\\u", "length", "'_", ":_", "'", "200", "'_", "}_", ")_", "\\u\\u\\uNL\\u\\u\\u_", "}_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "u", "'", "shared", "content", ".", "shared", "content", "item", "'_", ":_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "'", "Meta", "'_", ":_", "{_", "'", "orderi", "ng", "'_", ":_", "\"(", "'", "placehold", "er", "',", " ", "'", "sort", "\\u", "order", "')\"_", ",_", "'", "object\\u", "name", "'_", ":_", "'", "Share", "d", "Conten", "t", "Item", "'_", ",_", "'", "db", "\\u", "table", "'_", ":_", "\"", "u", "'", "content", "item", "\\u", "shared", "content", "\\u", "shared", "content", "item", "'\"_", ",_", "'\\u", "ormbase", "s", "'_", ":_", "[_", "'", "fluen", "t", "\\u", "content", "s", ".", "Conten", "t", "Item", "'_", "]_", "}_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "u", "'", "content", "item", "\\u", "ptr", "'_", ":_", "(_", "'", "django", ".", "db", ".", "model", "s", ".", "fields", ".", "relate", "d", ".", "One", "To", "One", "Field", "'_", ",_", "[_", "]_", ",_", "{_", "'", "to", "'_", ":_", "\"", "orm", "['", "fluen", "t", "\\u", "content", "s", ".", "Conten", "t", "Item", "']\"_", ",_", "'", "unique", "'_", ":_", "'", "Tru", "e", "'_", ",_", "'", "primary", "\\u", "key", "'_", ":_", "'", "Tru", "e", "'_", "}_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "shared", "\\u", "content", "'_", ":_", "(_", "'", "django", ".", "db", ".", "model", "s", ".", "fields", ".", "relate", "d", ".", "Fore", "ign", "Key", "'_", ",_", "[_", "]_", ",_", "{_", "'", "relate", "d\\u", "name", "'_", ":_", "\"'", "shared", "\\u", "content", "\\u", "items", "'\"_", ",_", "'", "to", "'_", ":_", "u", "\"", "orm", "['", "shared", "content", ".", "Share", "d", "Conten", "t", "']\"_", "}_", ")_", "\\u\\u\\uNL\\u\\u\\u_", "}_", "\\u\\u\\uNL\\u\\u\\u_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "complete", "\\u", "apps_", "=_", "[_", "'", "shared", "content", "'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "symmetric", "al_", "=_", "True_", "[SEP]_", "class_", "Migration_", "(_", "Data", "Migration_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "def_", "forwards_", "(_", "self_", ",_", "orm_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "db_", "._", "execute_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "'", "INSERT", " ", "INT", "O", " ", "shared", "content", "\\u", "shared", "content", "\\u", "translatio", "n", "(", "title", ",", " ", "language", "\\u", "code", ",", " ", "master", "\\u", "id", ")'_", "\\u\\u\\uNL\\u\\u\\u_", "'", " ", "SELECT", " ", "title", ",", " ", "%", "s", ",", " ", "id", " ", "FROM", " ", "shared", "content", "\\u", "shared", "content", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "[_", "appse", "ttings_", "._", "FLU", "ENT", "\\u", "CONTE", "NTS", "\\u", "DEF", "AUL", "T", "\\u", "LANGUAGE", "\\u", "CODE_", "]_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Migration_", "(_", "Data", "Migration_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "backwards_", "(_", "self_", ",_", "orm_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Convert", " ", "all", " ", "fields", " ", "back", " ", "to", " ", "the", " ", "single", "-", "language", " ", "table", "._", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "for_", "shared", "content_", "in_", "orm_", "[_", "'", "shared", "content", ".", "Share", "d", "Conten", "t", "'_", "]_", "._", "objects_", "._", "all_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "translations_", "=_", "orm_", "[_", "'", "shared", "content", ".", "Share", "d", "Conten", "t", "\\u", "Translat", "ion", "'_", "]_", "._", "objects_", "._", "filter_", "(_", "master", "\\u", "id_", "=_", "shared", "content_", "._", "id_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Tr", "y", " ", "default", " ", "translation_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "translation_", "=_", "translations_", "._", "get_", "(_", "language", "\\u", "code_", "=_", "appse", "ttings_", "._", "FLU", "ENT", "\\u", "CONTE", "NTS", "\\u", "DEF", "AUL", "T", "\\u", "LANGUAGE", "\\u", "CODE_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "Object", "Do", "es", "Not", "Exist_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Tr", "y", " ", "internal", " ", "fallback_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "translation_", "=_", "translations_", "._", "get_", "(_", "language", "\\u", "code", "\\u\\u", "in_", "=_", "(_", "'", "en", "-", "us", "'_", ",_", "'", "en", "'_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "Object", "Do", "es", "Not", "Exist_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Hop", "e", " ", "there", " ", "is", " ", "a", " ", "single", " ", "translation_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "translation_", "=_", "translations_", "._", "get_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u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, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 ]
Unreachable code
goFrendiAsgard/kokoropy/applications/routes.py
[ { "content": "#####################################################################################\n# Configuration name : FIRST_TIME\n# Default value : True\n# Alternative value : True, False\n# If you have modify something, and want to disable kokoropy's default home page, \n# just set this to False\n#####################################################################################\nFIRST_TIME = True\n\n#####################################################################################\n# Configuration name : CUSTOM_ERROR\n# Default value : False\n# Alternative value : True, False\n# If you want to enable custom error, end let your visitor see the \n# sarcastic-human word instead of any informative-for-developer-info \n# such as \"404 Not found\", set this to true\n#####################################################################################\nCUSTOM_ERROR = False\n\n#####################################################################################\n# End of configuration\n#####################################################################################\n\nfrom kokoropy import load_view, base_url\n\n################### These functions are used for routes (url) #######################\n\n\n####################### These functions are used for hooks ##########################\n\n\n####################### These functions are used for errors #########################\n\n\n\nif FIRST_TIME:\n urls = (\n # index\n ('/', index),\n (base_url(), index),\n # getting_started\n (base_url('getting_started'), getting_started)\n )\n\nif CUSTOM_ERROR:\n hooks = (\n ('before_request', before_request),\n ('after_request', after_request)\n )\n \n errors = (\n ('404', error_404),\n ('403', error_403),\n ('500', error_500)\n )\n", "metadata": "root", "header": "['module', '___EOS___']", "index": 0 } ]
[ { "span": "hooks = (\n ('before_request', before_request),\n ('after_request', after_request)\n )", "start_line": 95, "start_column": 4, "end_line": 98, "end_column": 5 } ]
[]
1
true
[ "[CLS]_", "Unrea", "chab", "le_", "code_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "###########", "###########", "###########", "###########", "###########", "###########", "###########", "######", "##", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Configura", "tion", " ", "name", " ", " ", " ", ":", " ", "FIR", "ST", "\\u", "TIME_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Default", " ", "value", " ", " ", " ", " ", ":", " ", "True_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Alternative", " ", "value", " ", " ", " ", " ", ":", " ", "Tru", "e", ",", " ", "False_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "If", " ", "you", " ", "have", " ", "modif", "y", " ", "somet", "hing", ",", " ", "and", " ", "want", " ", "to", " ", "disable", " ", "ko", "kor", "opy", "'", "s", " ", "default", " ", "home", " ", "page", ",", " _", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "just", " ", "set", " ", "this", " ", "to", " ", "False_", "\\u\\u\\uNL\\u\\u\\u_", "###########", "###########", "###########", "###########", "###########", "###########", "###########", "######", "##", "_", "\\u\\u\\uNL\\u\\u\\u_", "FIR", "ST", "\\u", "TIME_", "=_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "###########", "###########", "###########", "###########", "###########", "###########", "###########", "######", "##", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Configura", "tion", " ", "name", " ", " ", " ", ":", " ", "CUSTOM", "\\u", "ERROR_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Default", " ", "value", " ", " ", " ", " ", ":", " ", "False_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Alternative", " ", "value", " ", " ", " ", " ", ":", " ", "Tru", "e", ",", " ", "False_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "If", " ", "you", " ", "want", " ", "to", " ", "enable", " ", "custom", " ", "error", ",", " ", "end", " ", "let", " ", "your", " ", "visitor", " ", "see", " ", "the", " _", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "sar", "cast", "ic", "-", "human", " ", "word", " ", "inst", "ead", " ", "of", " ", "any", " ", "informati", "ve", "-", "for", "-", "developer", "-", "info", " _", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "suc", "h", " ", "as", " ", "\"", "404", " ", "Not", " ", "found", "\",", " ", "set", " ", "this", " ", "to", " ", "true_", "\\u\\u\\uNL\\u\\u\\u_", "###########", "###########", "###########", "###########", "###########", "###########", "###########", "######", "##", "_", "\\u\\u\\uNL\\u\\u\\u_", "CUSTOM", "\\u", "ERROR_", "=_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "###########", "###########", "###########", "###########", "###########", "###########", "###########", "######", "##", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "End", " ", "of", " ", "configuration_", "\\u\\u\\uNL\\u\\u\\u_", "###########", "###########", "###########", "###########", "###########", "###########", "###########", "######", "##", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "from_", "ko", "kor", "opy_", "import_", "load", "\\u", "view_", ",_", "base", "\\u", "url_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "###########", "######", "##", " ", "The", "se", " ", "function", "s", " ", "are", " ", "used", " ", "for", " ", "route", "s", " ", "(", "url", ")", " ", "###########", "###########", "#", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "###########", "###########", "#", " ", "The", "se", " ", "function", "s", " ", "are", " ", "used", " ", "for", " ", "hook", "s", " ", "###########", "###########", "###", "#", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "###########", "###########", "#", " ", "The", "se", " ", "function", "s", " ", "are", " ", "used", " ", "for", " ", "error", "s", " ", "###########", "###########", "###", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "FIR", "ST", "\\u", "TIME_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "urls_", "=_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "index_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "'/'_", ",_", "index_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "base", "\\u", "url_", "(_", ")_", ",_", "index_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "getti", "ng", "\\u", "started_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "base", "\\u", "url_", "(_", "'", "getti", "ng", "\\u", "start", "ed", "'_", ")_", ",_", "getti", "ng", "\\u", "started_", ")_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "CUSTOM", "\\u", "ERROR_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "hooks_", "=_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "'", "bef", "ore", "\\u", "request", "'_", ",_", "bef", "ore", "\\u", "request_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "'", "after", "\\u", "request", "'_", ",_", "after", "\\u", "request_", ")_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "errors_", "=_", "(_", "\\u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, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 ]
Signature mismatch in overriding method
divio/django-cms/cms/templatetags/cms_tags.py
[ { "content": "class CMSEditableObject(InclusionTag):\n \"\"\"\n Templatetag that links a content extracted from a generic django model\n to the model admin changeform.\n \"\"\"\n template = 'cms/toolbar/content.html'\n edit_template = 'cms/toolbar/plugin.html'\n name = 'render_model'\n options = Options(\n Argument('instance'),\n Argument('attribute'),\n Argument('edit_fields', default=None, required=False),\n Argument('language', default=None, required=False),\n Argument('filters', default=None, required=False),\n Argument('view_url', default=None, required=False),\n Argument('view_method', default=None, required=False),\n 'as',\n Argument('varname', required=False, resolve=False),\n )\n\n\n\n\n\n\n\n\n", "metadata": "root.CMSEditableObject", "header": "['module', '___EOS___']", "index": 692 }, { "content": " def __init__(self, parser, tokens):\n self.parser = parser\n super(CMSEditableObject, self).__init__(parser, tokens)", "metadata": "root.CMSEditableObject.__init__", "header": "['class', 'CMSEditableObject', '(', 'InclusionTag', ')', ':', '___EOS___']", "index": 712 }, { "content": " def _is_editable(self, request):\n return (request and hasattr(request, 'toolbar') and\n request.toolbar.edit_mode and\n request.toolbar.show_toolbar)", "metadata": "root.CMSEditableObject._is_editable", "header": "['class', 'CMSEditableObject', '(', 'InclusionTag', ')', ':', '___EOS___']", "index": 716 }, { "content": " def get_template(self, context, **kwargs):\n if self._is_editable(context.get('request', None)):\n return self.edit_template\n return self.template", "metadata": "root.CMSEditableObject.get_template", "header": "['class', 'CMSEditableObject', '(', 'InclusionTag', ')', ':', '___EOS___']", "index": 721 }, { "content": " def render_tag(self, context, **kwargs):\n \"\"\"\n Overridden from InclusionTag to push / pop context to avoid leaks\n \"\"\"\n context.push()\n template = self.get_template(context, **kwargs)\n data = self.get_context(context, **kwargs)\n output = render_to_string(template, flatten_context(data)).strip()\n context.pop()\n if kwargs.get('varname'):\n context[kwargs['varname']] = output\n return ''\n else:\n return output", "metadata": "root.CMSEditableObject.render_tag", "header": "['class', 'CMSEditableObject', '(', 'InclusionTag', ')', ':', '___EOS___']", "index": 726 }, { "content": " def _get_editable_context(self, context, instance, language, edit_fields,\n view_method, view_url, querystring, editmode=True):\n \"\"\"\n Populate the contex with the requested attributes to trigger the changeform\n \"\"\"\n request = context['request']\n if hasattr(request, 'toolbar'):\n lang = request.toolbar.toolbar_language\n else:\n lang = get_language()\n with force_language(lang):\n extra_context = {}\n if edit_fields == 'changelist':\n instance.get_plugin_name = u\"%s %s list\" % (smart_text(_('Edit')), smart_text(instance._meta.verbose_name))\n extra_context['attribute_name'] = 'changelist'\n elif editmode:\n instance.get_plugin_name = u\"%s %s\" % (smart_text(_('Edit')), smart_text(instance._meta.verbose_name))\n if not context.get('attribute_name', None):\n # Make sure CMS.Plugin object will not clash in the frontend.\n extra_context['attribute_name'] = '-'.join(edit_fields) \\\n if not isinstance('edit_fields', six.string_types) else edit_fields\n else:\n instance.get_plugin_name = u\"%s %s\" % (smart_text(_('Add')), smart_text(instance._meta.verbose_name))\n extra_context['attribute_name'] = 'add'\n extra_context['instance'] = instance\n extra_context['generic'] = instance._meta\n # view_method has the precedence and we retrieve the corresponding\n # attribute in the instance class.\n # If view_method refers to a method it will be called passing the\n # request; if it's an attribute, it's stored for later use\n if view_method:\n method = getattr(instance, view_method)\n if callable(method):\n url_base = method(context['request'])\n else:\n url_base = method\n else:\n # The default view_url is the default admin changeform for the\n # current instance\n if not editmode:\n view_url = 'admin:%s_%s_add' % (\n instance._meta.app_label, instance._meta.model_name)\n url_base = reverse(view_url)\n elif not edit_fields:\n if not view_url:\n view_url = 'admin:%s_%s_change' % (\n instance._meta.app_label, instance._meta.model_name)\n if isinstance(instance, Page):\n url_base = reverse(view_url, args=(instance.pk, language))\n else:\n url_base = reverse(view_url, args=(instance.pk,))\n else:\n if not view_url:\n view_url = 'admin:%s_%s_edit_field' % (\n instance._meta.app_label, instance._meta.model_name)\n if view_url.endswith('_changelist'):\n url_base = reverse(view_url)\n else:\n url_base = reverse(view_url, args=(instance.pk, language))\n querystring['edit_fields'] = \",\".join(context['edit_fields'])\n if editmode:\n extra_context['edit_url'] = \"%s?%s\" % (url_base, urlencode(querystring))\n else:\n extra_context['edit_url'] = \"%s\" % url_base\n extra_context['refresh_page'] = True\n # We may be outside the CMS (e.g.: an application which is not attached via Apphook)\n # in this case we may only go back to the home page\n if getattr(context['request'], 'current_page', None):\n extra_context['redirect_on_close'] = context['request'].current_page.get_absolute_url(language)\n else:\n extra_context['redirect_on_close'] = ''\n return extra_context", "metadata": "root.CMSEditableObject._get_editable_context", "header": "['class', 'CMSEditableObject', '(', 'InclusionTag', ')', ':', '___EOS___']", "index": 741 }, { "content": " def _get_content(self, context, instance, attribute, language, filters):\n \"\"\"\n Renders the requested attribute\n \"\"\"\n extra_context = copy(context)\n attr_value = None\n if hasattr(instance, 'lazy_translation_getter'):\n attr_value = instance.lazy_translation_getter(attribute, '')\n if not attr_value:\n attr_value = getattr(instance, attribute, '')\n extra_context['content'] = attr_value\n # This allow the requested item to be a method, a property or an\n # attribute\n if callable(extra_context['content']):\n if isinstance(instance, Page):\n extra_context['content'] = extra_context['content'](language)\n else:\n extra_context['content'] = extra_context['content'](context['request'])\n if filters:\n expression = self.parser.compile_filter(\"content|%s\" % (filters))\n extra_context['content'] = expression.resolve(extra_context)\n return extra_context", "metadata": "root.CMSEditableObject._get_content", "header": "['class', 'CMSEditableObject', '(', 'InclusionTag', ')', ':', '___EOS___']", "index": 814 }, { "content": " def _get_data_context(self, context, instance, attribute, edit_fields,\n language, filters, view_url, view_method):\n \"\"\"\n Renders the requested attribute and attach changeform trigger to it\n\n Uses `_get_empty_context`\n \"\"\"\n if not attribute:\n return context\n attribute = attribute.strip()\n # ugly-ish\n if isinstance(instance, Page):\n if attribute == 'title':\n attribute = 'get_title'\n if not edit_fields:\n edit_fields = 'title'\n elif attribute == 'page_title':\n attribute = 'get_page_title'\n if not edit_fields:\n edit_fields = 'page_title'\n elif attribute == 'menu_title':\n attribute = 'get_menu_title'\n if not edit_fields:\n edit_fields = 'menu_title'\n elif attribute == 'titles':\n attribute = 'get_title'\n if not edit_fields:\n edit_fields = 'title,page_title,menu_title'\n view_url = 'admin:cms_page_edit_title_fields'\n extra_context = copy(context)\n extra_context['attribute_name'] = attribute\n extra_context = self._get_empty_context(extra_context, instance,\n edit_fields, language, view_url,\n view_method)\n extra_context.update(self._get_content(extra_context, instance, attribute,\n language, filters))\n # content is for non-edit template content.html\n # rendered_content is for edit template plugin.html\n # in this templatetag both hold the same content\n extra_context['content'] = mark_safe(extra_context['content'])\n extra_context['rendered_content'] = extra_context['content']\n return extra_context", "metadata": "root.CMSEditableObject._get_data_context", "header": "['class', 'CMSEditableObject', '(', 'InclusionTag', ')', ':', '___EOS___']", "index": 837 }, { "content": " def _get_empty_context(self, context, instance, edit_fields, language,\n view_url, view_method, editmode=True):\n \"\"\"\n Inject in a copy of the context the data requested to trigger the edit.\n\n `content` and `rendered_content` is emptied.\n \"\"\"\n if not language:\n language = get_language_from_request(context['request'])\n # This allow the requested item to be a method, a property or an\n # attribute\n if not instance and editmode:\n return context\n extra_context = copy(context)\n # ugly-ish\n if instance and isinstance(instance, Page):\n if edit_fields == 'titles':\n edit_fields = 'title,page_title,menu_title'\n view_url = 'admin:cms_page_edit_title_fields'\n if edit_fields == 'changelist':\n view_url = 'admin:%s_%s_changelist' % (\n instance._meta.app_label, instance._meta.model_name)\n querystring = OrderedDict((('language', language),))\n if edit_fields:\n extra_context['edit_fields'] = edit_fields.strip().split(\",\")\n # If the toolbar is not enabled the following part is just skipped: it\n # would cause a perfomance hit for no reason\n if self._is_editable(context.get('request', None)):\n extra_context.update(self._get_editable_context(\n extra_context, instance, language, edit_fields, view_method,\n view_url, querystring, editmode))\n # content is for non-edit template content.html\n # rendered_content is for edit template plugin.html\n # in this templatetag both hold the same content\n extra_context['content'] = ''\n extra_context['rendered_content'] = ''\n return extra_context", "metadata": "root.CMSEditableObject._get_empty_context", "header": "['class', 'CMSEditableObject', '(', 'InclusionTag', ')', ':', '___EOS___']", "index": 880 }, { "content": " def get_context(self, context, instance, attribute, edit_fields,\n language, filters, view_url, view_method, varname):\n \"\"\"\n Uses _get_data_context to render the requested attributes\n \"\"\"\n extra_context = self._get_data_context(context, instance, attribute,\n edit_fields, language, filters,\n view_url, view_method)\n extra_context['render_model'] = True\n return extra_context", "metadata": "root.CMSEditableObject.get_context", "header": "['class', 'CMSEditableObject', '(', 'InclusionTag', ')', ':', '___EOS___']", "index": 918 }, { "content": "class CMSEditableObjectIcon(CMSEditableObject):\n \"\"\"\n Templatetag that links a content extracted from a generic django model\n to the model admin changeform.\n\n The output of this templatetag is just an icon to trigger the changeform.\n \"\"\"\n name = 'render_model_icon'\n options = Options(\n Argument('instance'),\n Argument('edit_fields', default=None, required=False),\n Argument('language', default=None, required=False),\n Argument('view_url', default=None, required=False),\n Argument('view_method', default=None, required=False),\n 'as',\n Argument('varname', required=False, resolve=False),\n )\n", "metadata": "root.CMSEditableObjectIcon", "header": "['module', '___EOS___']", "index": 931 }, { "content": " def get_context(self, context, instance, edit_fields, language,\n view_url, view_method, varname):\n \"\"\"\n Uses _get_empty_context and adds the `render_model_icon` variable.\n \"\"\"\n extra_context = self._get_empty_context(context, instance, edit_fields,\n language, view_url, view_method)\n extra_context['render_model_icon'] = True\n return extra_context", "metadata": "root.CMSEditableObjectIcon.get_context", "header": "['class', 'CMSEditableObjectIcon', '(', 'CMSEditableObject', ')', ':', '___EOS___']", "index": 949 }, { "content": "class CMSEditableObjectAdd(CMSEditableObject):\n \"\"\"\n Templatetag that links a content extracted from a generic django model\n to the model admin changeform.\n\n The output of this templatetag is just an icon to trigger the changeform.\n \"\"\"\n name = 'render_model_add'\n options = Options(\n Argument('instance'),\n Argument('language', default=None, required=False),\n Argument('view_url', default=None, required=False),\n Argument('view_method', default=None, required=False),\n 'as',\n Argument('varname', required=False, resolve=False),\n )\n", "metadata": "root.CMSEditableObjectAdd", "header": "['module', '___EOS___']", "index": 961 }, { "content": " def get_context(self, context, instance, language,\n view_url, view_method, varname):\n \"\"\"\n Uses _get_empty_context and adds the `render_model_icon` variable.\n \"\"\"\n if isinstance(instance, Model) and not instance.pk:\n instance.pk = 0\n extra_context = self._get_empty_context(context, instance, None,\n language, view_url, view_method,\n editmode=False)\n extra_context['render_model_add'] = True\n return extra_context", "metadata": "root.CMSEditableObjectAdd.get_context", "header": "['class', 'CMSEditableObjectAdd', '(', 'CMSEditableObject', ')', ':', '___EOS___']", "index": 978 }, { "content": "class CMSEditableObjectAddBlock(CMSEditableObject):\n \"\"\"\n Templatetag that links arbitrary content to the addform for the specified\n model (based on the provided model instance).\n \"\"\"\n name = 'render_model_add_block'\n options = Options(\n Argument('instance'),\n Argument('language', default=None, required=False),\n Argument('view_url', default=None, required=False),\n Argument('view_method', default=None, required=False),\n 'as',\n Argument('varname', required=False, resolve=False),\n blocks=[('endrender_model_add_block', 'nodelist')],\n )\n\n", "metadata": "root.CMSEditableObjectAddBlock", "header": "['module', '___EOS___']", "index": 993 }, { "content": " def render_tag(self, context, **kwargs):\n \"\"\"\n Renders the block and then inject the resulting HTML in the template\n context\n \"\"\"\n context.push()\n template = self.get_template(context, **kwargs)\n data = self.get_context(context, **kwargs)\n data['content'] = mark_safe(kwargs['nodelist'].render(data))\n data['rendered_content'] = data['content']\n output = render_to_string(template, flatten_context(data))\n context.pop()\n if kwargs.get('varname'):\n context[kwargs['varname']] = output\n return ''\n else:\n return output", "metadata": "root.CMSEditableObjectAddBlock.render_tag", "header": "['class', 'CMSEditableObjectAddBlock', '(', 'CMSEditableObject', ')', ':', '___EOS___']", "index": 1009 }, { "content": " def get_context(self, context, instance, language,\n view_url, view_method, varname, nodelist):\n \"\"\"\n Uses _get_empty_context and adds the `render_model_icon` variable.\n \"\"\"\n if isinstance(instance, Model) and not instance.pk:\n instance.pk = 0\n extra_context = self._get_empty_context(context, instance, None,\n language, view_url, view_method,\n editmode=False)\n extra_context['render_model_add'] = True\n return extra_context", "metadata": "root.CMSEditableObjectAddBlock.get_context", "header": "['class', 'CMSEditableObjectAddBlock', '(', 'CMSEditableObject', ')', ':', '___EOS___']", "index": 1027 }, { "content": "class CMSEditableObjectBlock(CMSEditableObject):\n \"\"\"\n Templatetag that links a content extracted from a generic django model\n to the model admin changeform.\n\n The rendered content is to be specified in the enclosed block.\n \"\"\"\n name = 'render_model_block'\n options = Options(\n Argument('instance'),\n Argument('edit_fields', default=None, required=False),\n Argument('language', default=None, required=False),\n Argument('view_url', default=None, required=False),\n Argument('view_method', default=None, required=False),\n 'as',\n Argument('varname', required=False, resolve=False),\n blocks=[('endrender_model_block', 'nodelist')],\n )\n\n", "metadata": "root.CMSEditableObjectBlock", "header": "['module', '___EOS___']", "index": 1042 }, { "content": " def render_tag(self, context, **kwargs):\n \"\"\"\n Renders the block and then inject the resulting HTML in the template\n context\n \"\"\"\n context.push()\n template = self.get_template(context, **kwargs)\n data = self.get_context(context, **kwargs)\n data['content'] = mark_safe(kwargs['nodelist'].render(data))\n data['rendered_content'] = data['content']\n output = render_to_string(template, flatten_context(data))\n context.pop()\n if kwargs.get('varname'):\n context[kwargs['varname']] = output\n return ''\n else:\n return output", "metadata": "root.CMSEditableObjectBlock.render_tag", "header": "['class', 'CMSEditableObjectBlock', '(', 'CMSEditableObject', ')', ':', '___EOS___']", "index": 1061 }, { "content": " def get_context(self, context, instance, edit_fields, language,\n view_url, view_method, varname, nodelist):\n \"\"\"\n Uses _get_empty_context and adds the `instance` object to the local\n context. Context here is to be intended as the context of the nodelist\n in the block.\n \"\"\"\n extra_context = self._get_empty_context(context, instance, edit_fields,\n language, view_url, view_method)\n extra_context['instance'] = instance\n extra_context['render_model_block'] = True\n return extra_context", "metadata": "root.CMSEditableObjectBlock.get_context", "header": "['class', 'CMSEditableObjectBlock', '(', 'CMSEditableObject', ')', ':', '___EOS___']", "index": 1079 } ]
[ { "span": "def get_context(self, context, instance, edit_fields, language,\n view_url, view_method, varname):", "start_line": 949, "start_column": 4, "end_line": 950, "end_column": 52 }, { "span": "def get_context(self, context, instance, language,\n view_url, view_method, varname):", "start_line": 978, "start_column": 4, "end_line": 979, "end_column": 52 }, { "span": "def get_context(self, context, instance, language,\n view_url, view_method, varname, nodelist):", "start_line": 1027, "start_column": 4, "end_line": 1028, "end_column": 62 }, { "span": "def get_context(self, context, instance, edit_fields, language,\n view_url, view_method, varname, nodelist):", "start_line": 1079, "start_column": 4, "end_line": 1080, "end_column": 62 } ]
[ { "span": "def get_context(self, context, instance, attribute, edit_fields,\n language, filters, view_url, view_method, varname):", "start_line": 918, "start_column": 4, "end_line": 919, "end_column": 71 } ]
1
false
[ "[CLS]_", "Signature_", "mismatch_", "in_", "overrid", "ing_", "method_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "class_", "CMS", "Editable", "Object_", "(_", "Incl", "usion", "Tag_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Templa", "tet", "ag", " ", "tha", "t", " ", "link", "s", " ", "a", " ", "content", " ", "extracted", " ", "from", " ", "a", " ", "gener", "ic", " ", "django", " ", "model", "\\", "10", ";", " ", " ", " ", " ", "to", " ", "the", " ", "model", " ", "admin", " ", "change", "form", ".", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "template_", "=_", "'", "cms", "/", "toolb", "ar", "/", "content", ".", "html", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "edit", "\\u", "template_", "=_", "'", "cms", "/", "toolb", "ar", "/", "plugin", ".", "html", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "name_", "=_", "'", "render", "\\u", "model", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "options_", "=_", "Options_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "Argument_", "(_", "'", "instance", "'_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "Argument_", "(_", "'", "attribute", "'_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "Argument_", "(_", "'", "edit", "\\u", "fields", "'_", ",_", "default_", "=_", "None_", ",_", "required_", "=_", "False_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "Argument_", "(_", "'", "language", "'_", ",_", "default_", "=_", "None_", ",_", "required_", "=_", "False_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "Argument_", "(_", "'", "filter", "s", "'_", ",_", "default_", "=_", "None_", ",_", "required_", "=_", "False_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "Argument_", "(_", "'", "view", "\\u", "url", "'_", ",_", "default_", "=_", "None_", ",_", "required_", "=_", "False_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "Argument_", "(_", "'", "view", "\\u", "method", "'_", ",_", "default_", "=_", "None_", ",_", "required_", "=_", "False_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "as", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "Argument_", "(_", "'", "varname", "'_", ",_", "required_", "=_", "False_", ",_", "resolve_", "=_", "False_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "[SEP]_", "class_", "CMS", "Editable", "Object_", "(_", "Incl", "usion", "Tag_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "\\u\\u", "init\\u\\u_", "(_", "self_", ",_", "parser_", ",_", "tokens_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "parser_", "=_", "parser_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "super_", "(_", "CMS", "Editable", "Object_", ",_", "self_", ")_", "._", "\\u\\u", "init\\u\\u_", "(_", "parser_", ",_", "tokens_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "CMS", "Editable", "Object_", "(_", "Incl", "usion", "Tag_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "\\u", "is", "\\u", "editable_", "(_", "self_", ",_", "request_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "(_", "request_", "and_", "hasattr_", "(_", "request_", ",_", "'", "toolb", "ar", "'_", ")_", "and_", "\\u\\u\\uNL\\u\\u\\u_", "request_", "._", "toolbar_", "._", "edit", "\\u", "mode_", "and_", "\\u\\u\\uNL\\u\\u\\u_", "request_", "._", "toolbar_", "._", "show", "\\u", "toolbar_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "CMS", "Editable", "Object_", "(_", "Incl", "usion", "Tag_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "get", "\\u", "template_", "(_", "self_", ",_", "context_", ",_", "**_", "kwargs_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "self_", "._", "\\u", "is", "\\u", "editable_", "(_", "context_", "._", "get_", "(_", "'", "request", "'_", ",_", "None_", ")_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "self_", "._", "edit", "\\u", "template_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "self_", "._", "template_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "CMS", "Editable", "Object_", "(_", "Incl", "usion", "Tag_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "render", "\\u", "tag_", "(_", "self_", ",_", "context_", ",_", "**_", "kwargs_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Over", "rid", "den", " ", "from", " ", "Incl", "usion", "Ta", "g", " ", "to", " ", "push", " ", "/", " ", "pop", " ", "context", " ", "to", " ", "avoid", " ", "leak", "s", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "context_", "._", "push_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "template_", "=_", "self_", "._", "get", "\\u", "template_", "(_", "context_", ",_", "**_", "kwargs_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "data_", "=_", "self_", "._", "get", "\\u", "context_", "(_", "context_", ",_", "**_", "kwargs_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "output_", "=_", "render", "\\u", "to", "\\u", "string_", "(_", "template_", ",_", "flat", "ten", "\\u", "context_", "(_", "data_", ")_", ")_", "._", "strip_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "context_", "._", "pop_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "kwargs_", "._", "get_", "(_", "'", "varname", "'_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "context_", "[_", "kwargs_", "[_", "'", "varname", "'_", "]_", "]_", "=_", "output_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "output_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "CMS", "Editable", "Object_", "(_", "Incl", "usion", "Tag_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "\\u", "get", "\\u", "edita", "ble", "\\u", "context_", "(_", "self_", ",_", "context_", ",_", "instance_", ",_", "language_", ",_", "edit", "\\u", "fields_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "view", "\\u", "method_", ",_", "view", "\\u", "url_", ",_", "querystring", "_", ",_", "edit", "mode_", "=_", "True_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Populate", " ", "the", " ", "conte", "x", " ", "with", " ", "the", " ", "request", "ed", " ", "attribute", "s", " ", "to", " ", "trigger", " ", "the", " ", "change", "form", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "request_", "=_", "context_", "[_", "'", "request", "'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "hasattr_", "(_", "request_", ",_", "'", "toolb", "ar", "'_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "lang_", "=_", "request_", "._", "toolbar_", "._", "toolb", "ar", "\\u", "language_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "lang_", "=_", "get", "\\u", "language_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "with_", "force", "\\u", "language_", "(_", "lang_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "extra", "\\u", "context_", "=_", "{_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "edit", "\\u", "fields_", "==_", "'", "changeli", "st", "'_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "instance_", "._", "get", "\\u", "plugin", "\\u", "name_", "=_", "u", "\"%", "s", " ", "%", "s", " ", "list", "\"_", "%_", "(_", "smart", "\\u", "text_", "(_", "\\u_", "(_", "'", "Edit", "'_", ")_", ")_", ",_", "smart", "\\u", "text_", "(_", "instance_", "._", "\\u", "meta_", "._", "verbo", "se", "\\u", "name_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "extra", "\\u", "context_", "[_", "'", "attribute", "\\u", "name", "'_", "]_", "=_", "'", "changeli", "st", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "edit", "mode_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "instance_", "._", "get", "\\u", "plugin", "\\u", "name_", "=_", "u", "\"%", "s", " ", "%", "s", "\"_", "%_", "(_", "smart", "\\u", "text_", "(_", "\\u_", "(_", "'", "Edit", "'_", ")_", ")_", ",_", "smart", "\\u", "text_", "(_", "instance_", "._", "\\u", "meta_", "._", "verbo", "se", "\\u", "name_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "not_", "context_", "._", "get_", "(_", "'", "attribute", "\\u", "name", "'_", ",_", "None_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Make", " ", "sure", " ", "CMS", ".", "Plug", "in", " ", "object", " ", "will", " ", "not", " ", "clas", "h", " ", "in", " ", "the", " ", "front", "end", "._", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "extra", "\\u", "context_", "[_", "'", "attribute", "\\u", "name", "'_", "]_", "=_", "'-'_", "._", "join_", "(_", "edit", "\\u", "fields_", ")_", "if_", "not_", "isinstance_", "(_", "'", "edit", "\\u", "fields", "'_", ",_", "six_", "._", "string", "\\u", "types_", ")_", "else_", "edit", "\\u", "fields_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "instance_", "._", "get", "\\u", "plugin", "\\u", "name_", "=_", "u", "\"%", "s", " ", "%", "s", "\"_", "%_", "(_", "smart", "\\u", "text_", "(_", "\\u_", "(_", "'", "Add", "'_", ")_", ")_", ",_", "smart", "\\u", "text_", "(_", "instance_", "._", "\\u", "meta_", "._", "verbo", "se", "\\u", "name_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "extra", "\\u", "context_", "[_", "'", "attribute", "\\u", "name", "'_", "]_", "=_", "'", "add", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "extra", "\\u", "context_", "[_", "'", "instance", "'_", "]_", "=_", "instance_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "extra", "\\u", "context_", "[_", "'", "gener", "ic", "'_", "]_", "=_", "instance_", "._", "\\u", "meta_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "view", "\\u", "method", " ", "has", " ", "the", " ", "preceden", "ce", " ", "and", " ", "we", " ", "retrieve", " ", "the", " ", "correspond", "ing_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "attribute", " ", "in", " ", "the", " ", "instance", " ", "class", "._", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "If", " ", "view", "\\u", "method", " ", "refer", "s", " ", "to", " ", "a", " ", "method", " ", "it", " ", "will", " ", "be", " ", "call", "ed", " ", "passi", "ng", " ", "the_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "request", ";", " ", "if", " ", "it", "'", "s", " ", "an", " ", "attribute", ",", " ", "it", "'", "s", " ", "store", "d", " ", "for", " ", "late", "r", " ", "use_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "view", "\\u", "method_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "method_", "=_", "getattr_", "(_", "instance_", ",_", "view", "\\u", "method_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "callable_", "(_", "method_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "url", "\\u", "base_", "=_", "method_", "(_", "context_", "[_", "'", "request", "'_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "url", "\\u", "base_", "=_", "method_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "The", " ", "default", " ", "view", "\\u", "url", " ", "is", " ", "the", " ", "default", " ", "admin", " ", "change", "form", " ", "for", " ", "the_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "current", " ", "instance_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "not_", "edit", "mode_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "view", "\\u", "url_", "=_", "'", "admin", ":", "%", "s", "\\u", "%", "s", "\\u", "add", "'_", "%_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "instance_", "._", "\\u", "meta_", "._", "app", "\\u", "label_", ",_", "instance_", "._", "\\u", "meta_", "._", "model", "\\u", "name_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "url", "\\u", "base_", "=_", "reverse_", "(_", "view", "\\u", "url_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "not_", "edit", "\\u", "fields_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "if_", "not_", "view", "\\u", "url_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "view", "\\u", "url_", "=_", "'", "admin", ":", "%", "s", "\\u", "%", "s", "\\u", "change", "'_", "%_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "instance_", "._", "\\u", "meta_", "._", "app", "\\u", "label_", ",_", "instance_", "._", "\\u", "meta_", "._", "model", "\\u", "name_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "isinstance_", "(_", "instance_", ",_", "Page_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "url", "\\u", "base_", "=_", "reverse_", "(_", "view", "\\u", "url_", ",_", "args_", "=_", "(_", "instance_", "._", "pk_", ",_", "language_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "url", "\\u", "base_", "=_", "reverse_", "(_", "view", "\\u", "url_", ",_", "args_", "=_", "(_", "instance_", "._", "pk_", ",_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "if_", "not_", "view", "\\u", "url_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "view", "\\u", "url_", "=_", "'", "admin", ":", "%", "s", "\\u", "%", "s", "\\u", "edit", "\\u", "field", "'_", "%_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "instance_", "._", "\\u", "meta_", "._", "app", "\\u", "label_", ",_", "instance_", "._", "\\u", "meta_", "._", "model", "\\u", "name_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "view", "\\u", "url_", "._", "endswith_", "(_", "'\\u", "changeli", "st", "'_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "url", "\\u", "base_", "=_", "reverse_", "(_", "view", "\\u", "url_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "url", "\\u", "base_", "=_", "reverse_", "(_", "view", "\\u", "url_", ",_", "args_", "=_", "(_", "instance_", "._", "pk_", ",_", "language_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "querystring", "_", "[_", "'", "edit", "\\u", "fields", "'_", "]_", "=_", "\",\"_", "._", "join_", "(_", "context_", "[_", "'", "edit", "\\u", "fields", "'_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "edit", "mode_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "extra", "\\u", "context_", "[_", "'", "edit", "\\u", "url", "'_", "]_", "=_", "\"%", "s", "?", "%", "s", "\"_", "%_", "(_", "url", "\\u", "base_", ",_", "urlencode_", "(_", "querystring", "_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "extra", "\\u", "context_", "[_", "'", "edit", "\\u", "url", "'_", "]_", "=_", "\"%", "s", "\"_", "%_", "url", "\\u", "base_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "extra", "\\u", "context_", "[_", "'", "refre", "sh", "\\u", "page", "'_", "]_", "=_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "We", " ", "may", " ", "be", " ", "outsi", "de", " ", "the", " ", "CMS", " ", "(", "e", ".", "g", ".:", " ", "an", " ", "applica", "tion", " ", "whi", "ch", " ", "is", " ", "not", " ", "attache", "d", " ", "via", " ", "App", "hook", ")_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "in", " ", "this", " ", "case", " ", "we", " ", "may", " ", "only", " ", "go", " ", "back", " ", "to", " ", "the", " ", "home", " ", "page_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "getattr_", "(_", "context_", "[_", "'", "request", "'_", "]_", ",_", "'", "current", "\\u", "page", "'_", ",_", "None_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "extra", "\\u", "context_", "[_", "'", "redirec", "t", "\\u", "on", "\\u", "close", "'_", "]_", "=_", "context_", "[_", "'", "request", "'_", "]_", "._", "current", "\\u", "page_", "._", "get", "\\u", "abs", "olute", "\\u", "url_", "(_", "language_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "extra", "\\u", "context_", "[_", "'", "redirec", "t", "\\u", "on", "\\u", "close", "'_", "]_", "=_", "''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "extra", "\\u", "context_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "CMS", "Editable", "Object_", "(_", "Incl", "usion", "Tag_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "\\u", "get", "\\u", "content_", "(_", "self_", ",_", "context_", ",_", "instance_", ",_", "attribute_", ",_", "language_", ",_", "filters_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Render", "s", " ", "the", " ", "request", "ed", " ", "attribute", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "extra", "\\u", "context_", "=_", "copy_", "(_", "context_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "attr", "\\u", "value_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "hasattr_", "(_", "instance_", ",_", "'", "lazy", "\\u", "translatio", "n", "\\u", "getter", "'_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "attr", "\\u", "value_", "=_", "instance_", "._", "lazy", "\\u", "translatio", "n", "\\u", "getter_", "(_", "attribute_", ",_", "''_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "not_", "attr", "\\u", "value_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "attr", "\\u", "value_", "=_", "getattr_", "(_", "instance_", ",_", "attribute_", ",_", "''_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "extra", "\\u", "context_", "[_", "'", "content", "'_", "]_", "=_", "attr", "\\u", "value_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Thi", "s", " ", "allow", " ", "the", " ", "request", "ed", " ", "item", " ", "to", " ", "be", " ", "a", " ", "method", ",", " ", "a", " ", "property", " ", "or", " ", "an_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "attribute_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "callable_", "(_", "extra", "\\u", "context_", "[_", "'", "content", "'_", "]_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "isinstance_", "(_", "instance_", ",_", "Page_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "extra", "\\u", "context_", "[_", "'", "content", "'_", "]_", "=_", "extra", "\\u", "context_", "[_", "'", "content", "'_", "]_", "(_", "language_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "extra", "\\u", "context_", "[_", "'", "content", "'_", "]_", "=_", "extra", "\\u", "context_", "[_", "'", "content", "'_", "]_", "(_", "context_", "[_", "'", "request", "'_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "filters_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "expression_", "=_", "self_", "._", "parser_", "._", "compile", "\\u", "filter_", "(_", "\"", "content", "|", "%", "s", "\"_", "%_", "(_", "filters_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "extra", "\\u", "context_", "[_", "'", "content", "'_", "]_", "=_", "expression_", "._", "resolve_", "(_", "extra", "\\u", "context_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "extra", "\\u", "context_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "CMS", "Editable", "Object_", "(_", "Incl", "usion", "Tag_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "\\u", "get", "\\u", "data\\u", "context_", "(_", "self_", ",_", "context_", ",_", "instance_", ",_", "attribute_", ",_", "edit", "\\u", "fields_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "language_", ",_", "filters_", ",_", "view", "\\u", "url_", ",_", "view", "\\u", "method_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Render", "s", " ", "the", " ", "request", "ed", " ", "attribute", " ", "and", " ", "attach", " ", "change", "form", " ", "trigger", " ", "to", " ", "it", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "Us", "es", " ", "`\\u", "get", "\\u", "empty", "\\u", "context", "`", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "not_", "attribute_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "context_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "attribute_", "=_", "attribute_", "._", "strip_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "ug", "ly", "-", "ish_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "isinstance_", "(_", "instance_", ",_", "Page_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "attribute_", "==_", "'", "title", "'_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "attribute_", "=_", "'", "get", "\\u", "title", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "not_", "edit", "\\u", "fields_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "edit", "\\u", "fields_", "=_", "'", "title", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "attribute_", "==_", "'", "page", "\\u", "title", "'_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "attribute_", "=_", "'", "get", "\\u", "page", "\\u", "title", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "not_", "edit", "\\u", "fields_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "edit", "\\u", "fields_", "=_", "'", "page", "\\u", "title", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "attribute_", "==_", "'", "menu", "\\u", "title", "'_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "attribute_", "=_", "'", "get", "\\u", "menu", "\\u", "title", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "not_", "edit", "\\u", "fields_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "edit", "\\u", "fields_", "=_", "'", "menu", "\\u", "title", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "attribute_", "==_", "'", "titles", "'_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "attribute_", "=_", "'", "get", "\\u", "title", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "not_", "edit", "\\u", "fields_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "edit", "\\u", "fields_", "=_", "'", "title", ",", "page", "\\u", "title", ",", "menu", "\\u", "title", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "view", "\\u", "url_", "=_", "'", "admin", ":", "cms", "\\u", "page", "\\u", "edit", "\\u", "title", "\\u", "fields", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "extra", "\\u", "context_", "=_", "copy_", "(_", "context_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "extra", "\\u", "context_", "[_", "'", "attribute", "\\u", "name", "'_", "]_", "=_", "attribute_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "extra", "\\u", "context_", "=_", "self_", "._", "\\u", "get", "\\u", "empty", "\\u", "context_", "(_", "extra", "\\u", "context_", ",_", "instance_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "edit", "\\u", "fields_", ",_", "language_", ",_", "view", "\\u", "url_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "view", "\\u", "method_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "extra", "\\u", "context_", "._", "update_", "(_", "self_", "._", "\\u", "get", "\\u", "content_", "(_", "extra", "\\u", "context_", ",_", "instance_", ",_", "attribute_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "language_", ",_", "filters_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "content", " ", "is", " ", "for", " ", "non", "-", "edit", " ", "template", " ", "content", ".", "html_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "render", "ed", "\\u", "content", " ", "is", " ", "for", " ", "edit", " ", "template", " ", "plugin", ".", "html_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "in", " ", "this", " ", "templatet", "ag", " ", "bot", "h", " ", "hold", " ", "the", " ", "same", " ", "content_", "\\u\\u\\uNL\\u\\u\\u_", "extra", "\\u", "context_", "[_", "'", "content", "'_", "]_", "=_", "mark", "\\u", "safe_", "(_", "extra", "\\u", "context_", "[_", "'", "content", "'_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "extra", "\\u", "context_", "[_", "'", "render", "ed", "\\u", "content", "'_", "]_", "=_", "extra", "\\u", "context_", "[_", "'", "content", "'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "extra", "\\u", "context_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "CMS", "Editable", "Object_", "(_", "Incl", "usion", "Tag_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "\\u", "get", "\\u", "empty", "\\u", "context_", "(_", "self_", ",_", "context_", ",_", "instance_", ",_", "edit", "\\u", "fields_", ",_", "language_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "view", "\\u", "url_", ",_", "view", "\\u", "method_", ",_", "edit", "mode_", "=_", "True_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Inject", " ", "in", " ", "a", " ", "copy", " ", "of", " ", "the", " ", "context", " ", "the", " ", "data", " ", "request", "ed", " ", "to", " ", "trigger", " ", "the", " ", "edit", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "`", "content", "`", " ", "and", " ", "`", "render", "ed", "\\u", "content", "`", " ", "is", " ", "emp", "tied", ".", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "not_", "language_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "language_", "=_", "get", "\\u", "language", "\\u", "from", "\\u", "request_", "(_", "context_", "[_", "'", "request", "'_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Thi", "s", " ", "allow", " ", "the", " ", "request", "ed", " ", "item", " ", "to", " ", "be", " ", "a", " ", "method", ",", " ", "a", " ", "property", " ", "or", " ", "an_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "attribute_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "not_", "instance_", "and_", "edit", "mode_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "context_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "extra", "\\u", "context_", "=_", "copy_", "(_", "context_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "ug", "ly", "-", "ish_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "instance_", "and_", "isinstance_", "(_", "instance_", ",_", "Page_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "edit", "\\u", "fields_", "==_", "'", "titles", "'_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "edit", "\\u", "fields_", "=_", "'", "title", ",", "page", "\\u", "title", ",", "menu", "\\u", "title", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "view", "\\u", "url_", "=_", "'", "admin", ":", "cms", "\\u", "page", "\\u", "edit", "\\u", "title", "\\u", "fields", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "edit", "\\u", "fields_", "==_", "'", "changeli", "st", "'_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "view", "\\u", "url_", "=_", "'", "admin", ":", "%", "s", "\\u", "%", "s", "\\u", "changeli", "st", "'_", "%_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "instance_", "._", "\\u", "meta_", "._", "app", "\\u", "label_", ",_", "instance_", "._", "\\u", "meta_", "._", "model", "\\u", "name_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "querystring", "_", "=_", "Order", "ed", "Dict_", "(_", "(_", "(_", "'", "language", "'_", ",_", "language_", ")_", ",_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "edit", "\\u", "fields_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "extra", "\\u", "context_", "[_", "'", "edit", "\\u", "fields", "'_", "]_", "=_", "edit", "\\u", "fields_", "._", "strip_", "(_", ")_", "._", "split_", "(_", "\",\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "If", " ", "the", " ", "toolb", "ar", " ", "is", " ", "not", " ", "enable", "d", " ", "the", " ", "follow", "ing", " ", "part", " ", "is", " ", "just", " ", "skip", "ped", ":", " ", "it_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "wou", "ld", " ", "caus", "e", " ", "a", " ", "perf", "oma", "nce", " ", "hit", " ", "for", " ", "no", " ", "reason_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "self_", "._", "\\u", "is", "\\u", "editable_", "(_", "context_", "._", "get_", "(_", "'", "request", "'_", ",_", "None_", ")_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "extra", "\\u", "context_", "._", "update_", "(_", "self_", "._", "\\u", "get", "\\u", "edita", "ble", "\\u", "context_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "extra", "\\u", "context_", ",_", "instance_", ",_", "language_", ",_", "edit", "\\u", "fields_", ",_", "view", "\\u", "method_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "view", "\\u", "url_", ",_", "querystring", "_", ",_", "edit", "mode_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "content", " ", "is", " ", "for", " ", "non", "-", "edit", " ", "template", " ", "content", ".", "html_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "render", "ed", "\\u", "content", " ", "is", " ", "for", " ", "edit", " ", "template", " ", "plugin", ".", "html_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "in", " ", "this", " ", "templatet", "ag", " ", "bot", "h", " ", "hold", " ", "the", " ", "same", " ", "content_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "extra", "\\u", "context_", "[_", "'", "content", "'_", "]_", "=_", "''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "extra", "\\u", "context_", "[_", "'", "render", "ed", "\\u", "content", "'_", "]_", "=_", "''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "extra", "\\u", "context_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "CMS", "Editable", "Object_", "(_", "Incl", "usion", "Tag_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "get", "\\u", "context_", "(_", "self_", ",_", "context_", ",_", "instance_", ",_", "attribute_", ",_", "edit", "\\u", "fields_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "language_", ",_", "filters_", ",_", "view", "\\u", "url_", ",_", "view", "\\u", "method_", ",_", "varname_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Us", "es", " ", "\\u", "get", "\\u", "data\\u", "context", " ", "to", " ", "render", " ", "the", " ", "request", "ed", " ", "attribute", "s", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "extra", "\\u", "context_", "=_", "self_", "._", "\\u", "get", "\\u", "data\\u", "context_", "(_", "context_", ",_", "instance_", ",_", "attribute_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "edit", "\\u", "fields_", ",_", "language_", ",_", "filters_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "view", "\\u", "url_", ",_", "view", "\\u", "method_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "extra", "\\u", "context_", "[_", "'", "render", "\\u", "model", "'_", "]_", "=_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "extra", "\\u", "context_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "class_", "CMS", "Editable", "Object", "Icon_", "(_", "CMS", "Editable", "Object_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Templa", "tet", "ag", " ", "tha", "t", " ", "link", "s", " ", "a", " ", "content", " ", "extracted", " ", "from", " ", "a", " ", "gener", "ic", " ", "django", " ", "model", "\\", "10", ";", " ", " ", " ", " ", "to", " ", "the", " ", "model", " ", "admin", " ", "change", "form", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "The", " ", "output", " ", "of", " ", "this", " ", "templatet", "ag", " ", "is", " ", "just", " ", "an", " ", "icon", " ", "to", " ", "trigger", " ", "the", " ", "change", "form", ".", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "name_", "=_", "'", "render", "\\u", "model", "\\u", "icon", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "options_", "=_", "Options_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "Argument_", "(_", "'", "instance", "'_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "Argument_", "(_", "'", "edit", "\\u", "fields", "'_", ",_", "default_", "=_", "None_", ",_", "required_", "=_", "False_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "Argument_", "(_", "'", "language", "'_", ",_", "default_", "=_", "None_", ",_", "required_", "=_", "False_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "Argument_", "(_", "'", "view", "\\u", "url", "'_", ",_", "default_", "=_", "None_", ",_", "required_", "=_", "False_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "Argument_", "(_", "'", "view", "\\u", "method", "'_", ",_", "default_", "=_", "None_", ",_", "required_", "=_", "False_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "as", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "Argument_", "(_", "'", "varname", "'_", ",_", "required_", "=_", "False_", ",_", "resolve_", "=_", "False_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "[SEP]_", "class_", "CMS", "Editable", "Object", "Icon_", "(_", "CMS", "Editable", "Object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "get", "\\u", "context_", "(_", "self_", ",_", "context_", ",_", "instance_", ",_", "edit", "\\u", "fields_", ",_", "language_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "view", "\\u", "url_", ",_", "view", "\\u", "method_", ",_", "varname_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Us", "es", " ", "\\u", "get", "\\u", "empty", "\\u", "context", " ", "and", " ", "adds", " ", "the", " ", "`", "render", "\\u", "model", "\\u", "icon", "`", " ", "variab", "le", ".", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "extra", "\\u", "context_", "=_", "self_", "._", "\\u", "get", "\\u", "empty", "\\u", "context_", "(_", "context_", ",_", "instance_", ",_", "edit", "\\u", "fields_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "language_", ",_", "view", "\\u", "url_", ",_", "view", "\\u", "method_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "extra", "\\u", "context_", "[_", "'", "render", "\\u", "model", "\\u", "icon", "'_", "]_", "=_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "extra", "\\u", "context_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "class_", "CMS", "Editable", "Object", "Add_", "(_", "CMS", "Editable", "Object_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Templa", "tet", "ag", " ", "tha", "t", " ", "link", "s", " ", "a", " ", "content", " ", "extracted", " ", "from", " ", "a", " ", "gener", "ic", " ", "django", " ", "model", "\\", "10", ";", " ", " ", " ", " ", "to", " ", "the", " ", "model", " ", "admin", " ", "change", "form", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "The", " ", "output", " ", "of", " ", "this", " ", "templatet", "ag", " ", "is", " ", "just", " ", "an", " ", "icon", " ", "to", " ", "trigger", " ", "the", " ", "change", "form", ".", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "name_", "=_", "'", "render", "\\u", "model", "\\u", "add", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "options_", "=_", "Options_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "Argument_", "(_", "'", "instance", "'_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "Argument_", "(_", "'", "language", "'_", ",_", "default_", "=_", "None_", ",_", "required_", "=_", "False_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "Argument_", "(_", "'", "view", "\\u", "url", "'_", ",_", "default_", "=_", "None_", ",_", "required_", "=_", "False_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "Argument_", "(_", "'", "view", "\\u", "method", "'_", ",_", "default_", "=_", "None_", ",_", "required_", "=_", "False_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "as", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "Argument_", "(_", "'", "varname", "'_", ",_", "required_", "=_", "False_", ",_", "resolve_", "=_", "False_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "[SEP]_", "class_", "CMS", "Editable", "Object", "Add_", "(_", "CMS", "Editable", "Object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "get", "\\u", "context_", "(_", "self_", ",_", "context_", ",_", "instance_", ",_", "language_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "view", "\\u", "url_", ",_", "view", "\\u", "method_", ",_", "varname_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Us", "es", " ", "\\u", "get", "\\u", "empty", "\\u", "context", " ", "and", " ", "adds", " ", "the", " ", "`", "render", "\\u", "model", "\\u", "icon", "`", " ", "variab", "le", ".", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "isinstance_", "(_", "instance_", ",_", "Model_", ")_", "and_", "not_", "instance_", "._", "pk_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "instance_", "._", "pk_", "=_", "0_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "extra", "\\u", "context_", "=_", "self_", "._", "\\u", "get", "\\u", "empty", "\\u", "context_", "(_", "context_", ",_", "instance_", ",_", "None_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "language_", ",_", "view", "\\u", "url_", ",_", "view", "\\u", "method_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "edit", "mode_", "=_", "False_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "extra", "\\u", "context_", "[_", "'", "render", "\\u", "model", "\\u", "add", "'_", "]_", "=_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "extra", "\\u", "context_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "class_", "CMS", "Editable", "Object", "Add", "Block_", "(_", "CMS", "Editable", "Object_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Templa", "tet", "ag", " ", "tha", "t", " ", "link", "s", " ", "arbitra", "ry", " ", "content", " ", "to", " ", "the", " ", "add", "form", " ", "for", " ", "the", " ", "specified", "\\", "10", ";", " ", " ", " ", " ", "model", " ", "(", "based", " ", "on", " ", "the", " ", "provided", " ", "model", " ", "instance", ").", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "name_", "=_", "'", "render", "\\u", "model", "\\u", "add", "\\u", "block", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "options_", "=_", "Options_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "Argument_", "(_", "'", "instance", "'_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "Argument_", "(_", "'", "language", "'_", ",_", "default_", "=_", "None_", ",_", "required_", "=_", "False_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "Argument_", "(_", "'", "view", "\\u", "url", "'_", ",_", "default_", "=_", "None_", ",_", "required_", "=_", "False_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "Argument_", "(_", "'", "view", "\\u", "method", "'_", ",_", "default_", "=_", "None_", ",_", "required_", "=_", "False_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "as", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "Argument_", "(_", "'", "varname", "'_", ",_", "required_", "=_", "False_", ",_", "resolve_", "=_", "False_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "blocks_", "=_", "[_", "(_", "'", "end", "render", "\\u", "model", "\\u", "add", "\\u", "block", "'_", ",_", "'", "nodel", "ist", "'_", ")_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "[SEP]_", "class_", "CMS", "Editable", "Object", "Add", "Block_", "(_", "CMS", "Editable", "Object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "render", "\\u", "tag_", "(_", "self_", ",_", "context_", ",_", "**_", "kwargs_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Render", "s", " ", "the", " ", "block", " ", "and", " ", "then", " ", "inject", " ", "the", " ", "result", "ing", " ", "HTM", "L", " ", "in", " ", "the", " ", "template", "\\", "10", ";", " ", " ", " ", " ", "context", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "context_", "._", "push_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "template_", "=_", "self_", "._", "get", "\\u", "template_", "(_", "context_", ",_", "**_", "kwargs_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "data_", "=_", "self_", "._", "get", "\\u", "context_", "(_", "context_", ",_", "**_", "kwargs_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "data_", "[_", "'", "content", "'_", "]_", "=_", "mark", "\\u", "safe_", "(_", "kwargs_", "[_", "'", "nodel", "ist", "'_", "]_", "._", "render_", "(_", "data_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "data_", "[_", "'", "render", "ed", "\\u", "content", "'_", "]_", "=_", "data_", "[_", "'", "content", "'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "output_", "=_", "render", "\\u", "to", "\\u", "string_", "(_", "template_", ",_", "flat", "ten", "\\u", "context_", "(_", "data_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "context_", "._", "pop_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "kwargs_", "._", "get_", "(_", "'", "varname", "'_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "context_", "[_", "kwargs_", "[_", "'", "varname", "'_", "]_", "]_", "=_", "output_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "output_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "CMS", "Editable", "Object", "Add", "Block_", "(_", "CMS", "Editable", "Object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "get", "\\u", "context_", "(_", "self_", ",_", "context_", ",_", "instance_", ",_", "language_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "view", "\\u", "url_", ",_", "view", "\\u", "method_", ",_", "varname_", ",_", "nodelist_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Us", "es", " ", "\\u", "get", "\\u", "empty", "\\u", "context", " ", "and", " ", "adds", " ", "the", " ", "`", "render", "\\u", "model", "\\u", "icon", "`", " ", "variab", "le", ".", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "isinstance_", "(_", "instance_", ",_", "Model_", ")_", "and_", "not_", "instance_", "._", "pk_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "instance_", "._", "pk_", "=_", "0_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "extra", "\\u", "context_", "=_", "self_", "._", "\\u", "get", "\\u", "empty", "\\u", "context_", "(_", "context_", ",_", "instance_", ",_", "None_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "language_", ",_", "view", "\\u", "url_", ",_", "view", "\\u", "method_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "edit", "mode_", "=_", "False_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "extra", "\\u", "context_", "[_", "'", "render", "\\u", "model", "\\u", "add", "'_", "]_", "=_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "extra", "\\u", "context_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "class_", "CMS", "Editable", "Object", "Block_", "(_", "CMS", "Editable", "Object_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Templa", "tet", "ag", " ", "tha", "t", " ", "link", "s", " ", "a", " ", "content", " ", "extracted", " ", "from", " ", "a", " ", "gener", "ic", " ", "django", " ", "model", "\\", "10", ";", " ", " ", " ", " ", "to", " ", "the", " ", "model", " ", "admin", " ", "change", "form", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "The", " ", "render", "ed", " ", "content", " ", "is", " ", "to", " ", "be", " ", "specified", " ", "in", " ", "the", " ", "enclose", "d", " ", "block", ".", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "name_", "=_", "'", "render", "\\u", "model", "\\u", "block", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "options_", "=_", "Options_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "Argument_", "(_", "'", "instance", "'_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "Argument_", "(_", "'", "edit", "\\u", "fields", "'_", ",_", "default_", "=_", "None_", ",_", "required_", "=_", "False_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "Argument_", "(_", "'", "language", "'_", ",_", "default_", "=_", "None_", ",_", "required_", "=_", "False_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "Argument_", "(_", "'", "view", "\\u", "url", "'_", ",_", "default_", "=_", "None_", ",_", "required_", "=_", "False_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "Argument_", "(_", "'", "view", "\\u", "method", "'_", ",_", "default_", "=_", "None_", ",_", "required_", "=_", "False_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "as", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "Argument_", "(_", "'", "varname", "'_", ",_", "required_", "=_", "False_", ",_", "resolve_", "=_", "False_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "blocks_", "=_", "[_", "(_", "'", "end", "render", "\\u", "model", "\\u", "block", "'_", ",_", "'", "nodel", "ist", "'_", ")_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "[SEP]_", "class_", "CMS", "Editable", "Object", "Block_", "(_", "CMS", "Editable", "Object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "render", "\\u", "tag_", "(_", "self_", ",_", "context_", ",_", "**_", "kwargs_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Render", "s", " ", "the", " ", "block", " ", "and", " ", "then", " ", "inject", " ", "the", " ", "result", "ing", " ", "HTM", "L", " ", "in", " ", "the", " ", "template", "\\", "10", ";", " ", " ", " ", " ", "context", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "context_", "._", "push_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "template_", "=_", "self_", "._", "get", "\\u", "template_", "(_", "context_", ",_", "**_", "kwargs_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "data_", "=_", "self_", "._", "get", "\\u", "context_", "(_", "context_", ",_", "**_", "kwargs_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "data_", "[_", "'", "content", "'_", "]_", "=_", "mark", "\\u", "safe_", "(_", "kwargs_", "[_", "'", "nodel", "ist", "'_", "]_", "._", "render_", "(_", "data_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "data_", "[_", "'", "render", "ed", "\\u", "content", "'_", "]_", "=_", "data_", "[_", "'", "content", "'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "output_", "=_", "render", "\\u", "to", "\\u", "string_", "(_", "template_", ",_", "flat", "ten", "\\u", "context_", "(_", "data_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "context_", "._", "pop_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "kwargs_", "._", "get_", "(_", "'", "varname", "'_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "context_", "[_", "kwargs_", "[_", "'", "varname", "'_", "]_", "]_", "=_", "output_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "output_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "CMS", "Editable", "Object", "Block_", "(_", "CMS", "Editable", "Object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "get", "\\u", "context_", "(_", "self_", ",_", "context_", ",_", "instance_", ",_", "edit", "\\u", "fields_", ",_", "language_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "view", "\\u", "url_", ",_", "view", "\\u", "method_", ",_", "varname_", ",_", "nodelist_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Us", "es", " ", "\\u", "get", "\\u", "empty", "\\u", "context", " ", "and", " ", "adds", " ", "the", " ", "`", "instance", "`", " ", "object", " ", "to", " ", "the", " ", "local", "\\", "10", ";", " ", " ", " ", " ", "context", ".", " ", "Context", " ", "here", " ", "is", " ", "to", " ", "be", " ", "inten", "ded", " ", "as", " ", "the", " ", "context", " ", "of", " ", "the", " ", "nodel", "ist", "\\", "10", ";", " ", " ", " ", " ", "in", " ", "the", " ", "block", ".", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "extra", "\\u", "context_", "=_", "self_", "._", "\\u", "get", "\\u", "empty", "\\u", "context_", "(_", "context_", ",_", "instance_", ",_", "edit", "\\u", "fields_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "language_", ",_", "view", "\\u", "url_", ",_", "view", "\\u", "method_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "extra", "\\u", "context_", "[_", "'", "instance", "'_", "]_", "=_", "instance_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "extra", "\\u", "context_", "[_", "'", "render", "\\u", "model", "\\u", "block", "'_", "]_", "=_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "extra", "\\u", "context_", "\\u\\u\\uNE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, 2, 2, 2, 2 ]
Module is imported more than once
ctuning/ck/ck/repo/module/web/module.py
[ { "content": "#\n# Collective Knowledge (CK web service)\n#\n# See CK LICENSE.txt for licensing details\n# See CK COPYRIGHT.txt for copyright details\n#\n# Developer: Grigori Fursin\n#\n\ncfg={} # Will be updated by CK (meta description of this module)\nwork={} # Will be updated by CK (temporal data)\nck=None # Will be updated by CK (initialized CK kernel) \n\ns_host=''\ns_port=''\n\n# Local settings\nimport os\nimport sys\nimport cgi\nimport urllib\nimport base64\nimport tempfile\n\n# Import various modules while supporting both Python 2.x and 3.x\ntry:\n from http.server import BaseHTTPRequestHandler, HTTPServer\nexcept:\n from BaseHTTPServer import BaseHTTPRequestHandler, HTTPServer\n\ntry:\n import urllib.parse as urlparse\nexcept:\n import urlparse\n\ntry:\n from urllib.parse import quote as urlquote\nexcept:\n from urllib import quote as urlquote\n\ntry:\n from urllib.parse import unquote as urlunquote\nexcept:\n from urllib import unquote as urlunquote\n\n#try:\n# import http.cookies as Cookie\n#except:\n# import Cookie\n\ntry:\n from socketserver import ThreadingMixIn\nexcept:\n from SocketServer import ThreadingMixIn\n\n##############################################################################\n# Initialize module\n\n\n##############################################################################\n# Access CK through CMD (can detach console)\n\n\n##############################################################################\n# Send error to HTTP stream\n\n\n##############################################################################\n# Send error to HTTP stream\n\n\n##############################################################################\n# Process CK web service request (both GET and POST)\n\n\n##############################################################################\n# Class to handle requests in separate threads\n\n\n##############################################################################\n# Class to handle CK web service requests\n\n\n##############################################################################\n# start web service\n\n\n##############################################################################\n# test web\n\n", "metadata": "root", "header": "['module', '___EOS___']", "index": 0 }, { "content": "def process_ck_web_request(i):\n\n \"\"\"\n\n Input: {\n http - Python http object\n }\n\n Output: { None }\n \"\"\"\n\n # http object\n http=i['http']\n\n # Parse GET variables and path\n xget={}\n xpath={'host':'', 'port':'', 'first':'', 'rest':'', 'query':''} # May be used in the future\n\n xt='json'\n\n xpath['host']=i.get('host','')\n xpath['port']=i.get('port','')\n\n # Check GET variables\n if http.path!='':\n http.send_response(200)\n\n a=urlparse.urlparse(http.path)\n xp=a.path\n xr=''\n\n if xp.startswith('/'): xp=xp[1:]\n\n u=xp.find('/')\n if u>=0:\n xr=xp[u+1:]\n xp=xp[:u]\n\n xt=xp\n\n xpath['first']=xp\n xpath['rest']=xr\n xpath['query']=a.query\n b=urlparse.parse_qs(a.query, keep_blank_values=True, )\n\n xget={}\n for k in b:\n# xget[k]=b[k][0]\n xget[k]=urlunquote(b[k][0])\n if sys.version_info[0]<3:\n xget[k]=xget[k].decode('utf8')\n\n # Check POST\n xpost={}\n xpost1={}\n\n try:\n headers = http.headers\n content_type = headers.get('content-type')\n ctype=''\n if content_type != None:\n ctype, pdict = cgi.parse_header(content_type)\n # Python3 cgi.parse_multipart expects boundary to be bytes, not str.\n if sys.version_info[0]<3 and 'boundary' in pdict: \n pdict['boundary'] = pdict['boundary'].encode()\n\n if ctype == 'multipart/form-data':\n if sys.version_info[0]<3:\n xpost1 = cgi.parse_multipart(http.rfile, pdict)\n else:\n xxpost1 = cgi.FieldStorage(fp=http.rfile, headers=headers, environ={'REQUEST_METHOD':'POST'})\n for k in xxpost1.keys():\n xpost1[k]=[xxpost1[k].value]\n elif ctype == 'application/x-www-form-urlencoded':\n length = int(http.headers.get('content-length'))\n s=http.rfile.read(length)\n if sys.version_info[0]>2: s=s.decode('utf8')\n xpost1 = cgi.parse_qs(s, keep_blank_values=1)\n \n except Exception as e:\n bin=b'internal CK web service error [7101] ('+format(e).encode('utf8')+')'\n web_err({'http':http, 'type':xt, 'bin':bin})\n ck.out(ck.cfg['error']+bin.decode('utf8'))\n return\n\n # Post processing\n for k in xpost1:\n v=xpost1[k]\n if k.endswith('[]'): \n k1=k[:-2]\n xpost[k1]=[]\n for l in v:\n xpost[k1].append(urlunquote(l))\n else: \n if k!='file_content':\n xpost[k]=urlunquote(v[0])\n else:\n xpost[k]=v[0]\n\n if k=='file_content':\n fcrt=xpost1.get('file_content_record_to_tmp','')\n if (type(fcrt)==list and len(fcrt)>0 and fcrt[0]=='yes') or fcrt=='yes':\n fd, fn=tempfile.mkstemp(suffix='.tmp', prefix='ck-') # suffix is important - CK will delete such file!\n os.close(fd)\n\n f=open(fn,'wb')\n f.write(xpost[k])\n f.close()\n\n xpost[k+'_uploaded']=fn\n del(xpost[k])\n k+='_uploaded'\n else:\n import base64\n xpost[k+'_base64']=base64.urlsafe_b64encode(xpost[k]).decode('utf8')\n del(xpost[k])\n k+='_base64'\n\n if sys.version_info[0]<3:\n xpost[k]=xpost[k].decode('utf8')\n\n # Prepare input and check if CK json present\n ii=xget\n ii.update(xpost)\n\n cj=ii.get('ck_json','').strip()\n if cj!='':\n r=ck.convert_json_str_to_dict({'str':cj, 'skip_quote_replacement':'yes'})\n if r['return']>0: \n bin=b'internal CK web service error [7102] ('+r['error'].encode('utf8')+b')'\n web_err({'http':http, 'type':xt, 'bin':bin})\n ck.out(ck.cfg['error']+bin.decode('utf8'))\n return\n\n del(ii['ck_json'])\n ii.update(r['dict'])\n\n # Misc parameters\n dc=ii.get('detach_console','')\n act=ii.get('action','')\n\n # Check output type\n if ii.get('out','')!='': \n xt=ii['out']\n\n if xt=='': xt='web'\n\n if xt!='json' and xt!='con' and xt!='web':\n web_out({'http':http, \n 'type':'web', \n 'bin':b'Unknown CK request ('+xt.encode('utf8')+b')!'})\n return\n\n # Prepare temporary output file\n fd, fn=tempfile.mkstemp(prefix='ck-')\n os.close(fd)\n os.remove(fn)\n\n # Check output\n if dc=='yes':\n if ck.cfg.get('forbid_detached_console','')=='yes':\n web_out({'http':http, \n 'type':'web', \n 'bin':b'Detached console is forbidden!'})\n return\n else:\n ii['out_file']=fn\n ii['web']='yes'\n if xt=='json' or xt=='web': \n ii['out']='json_file'\n # else output to console (for remote access for example)\n\n ii['con_encoding']='utf8'\n\n ii['server_host']=s_host\n ii['server_port']=s_port\n\n # Execute command *********************************************************\n if act=='':\n if cfg.get('if_web_action_not_defined','')!='' and cfg.get('if_web_module_not_defined','')!='':\n ii['module_uoa']=cfg['if_web_module_not_defined']\n ii['action']=cfg['if_web_action_not_defined']\n\n r=call_ck(ii)\n\n # Process output\n if r['return']>0:\n if os.path.isfile(fn): os.remove(fn)\n\n bout=r['error']\n\n try: bout=bout.encode('utf-8')\n except Exception as e: pass\n \n web_err({'http':http, \n 'type':xt, \n 'bin':bout})\n return\n\n # If output to console or detached console\n if xt=='con' or dc=='yes': \n if os.path.isfile(fn): os.remove(fn)\n\n bout=r.get('std','').encode('utf8')\n\n web_out({'http':http, 'type':xt, 'bin':bout})\n\n return\n\n # If json or web\n # Try to load output file\n if not os.path.isfile(fn):\n web_err({'http':http, \n 'type':xt, \n 'bin':b'Output json file was not created, see output ('+r['std'].encode('utf8')+b')!'})\n return\n\n r=ck.load_text_file({'text_file':fn, 'keep_as_bin':'yes'})\n if r['return']>0:\n bout=r['error']\n\n try: bout=bout.encode('utf-8')\n except Exception as e: pass\n\n web_err({'http':http, 'type':xt, 'bin':bout})\n\n return\n\n bin=r['bin']\n \n if os.path.isfile(fn): os.remove(fn)\n\n # Process JSON output from file\n fx=''\n\n if sys.version_info[0]>2: bin=bin.decode('utf-8')\n\n ru=ck.convert_json_str_to_dict({'str':bin, 'skip_quote_replacement':'yes'})\n if ru['return']>0:\n bout=ru['error']\n\n try: bout=bout.encode('utf-8')\n except Exception as e: pass\n\n web_err({'http':http, 'type':xt, 'bin':bout})\n\n return\n\n rr=ru['dict']\n if rr['return']>0:\n bout=rr['error']\n\n try: bout=bout.encode('utf-8')\n except Exception as e: pass\n\n web_err({'http':http, 'type':xt, 'bin':bout})\n return\n\n # Check if file was returned\n fr=False\n\n if 'file_content_base64' in rr and rr.get('filename','')!='':\n fr=True\n\n # Check if download\n if (xt=='web' and fr) or (act=='pull' and xt!='json'):\n import base64\n x=rr.get('file_content_base64','')\n\n fx=rr.get('filename','')\n if fx=='': fx=ck.cfg['default_archive_name']\n\n # Fixing Python bug\n if sys.version_info[0]==3 and sys.version_info[1]<3:\n x=x.encode('utf-8')\n else:\n x=str(x)\n bin=base64.urlsafe_b64decode(x) # convert from unicode to str since base64 works on strings\n # should be safe in Python 2.x and 3.x\n\n # Process extension\n fn1, fne = os.path.splitext(fx)\n if fne.startswith('.'): fne=fne[1:]\n if fne!='': xt=fne\n else: xt='unknown'\n else:\n # Check and output html\n if rr.get('html','')!='':\n bin=rr['html'].encode('utf-8')\n else:\n if sys.version_info[0]>2: # Unknown output\n bin=bin.encode('utf-8')\n\n web_out({'http':http, 'type':xt, 'bin':bin, 'filename':fx})\n \n return {'return':0}", "metadata": "root.process_ck_web_request", "header": "['module', '___EOS___']", "index": 271 } ]
[ { "span": "import base64", "start_line": 384, "start_column": 14, "end_line": 384, "end_column": 27 }, { "span": "import base64", "start_line": 537, "start_column": 7, "end_line": 537, "end_column": 20 } ]
[ { "span": "import base64", "start_line": 21, "start_column": 0, "end_line": 21, "end_column": 13 } ]
1
true
[ "[CLS]_", "Module_", "is_", "imported_", "more_", "than_", "once_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "#", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Collecti", "ve", " ", "Knowledge", " ", "(", "CK", " ", "web", " ", "service", ")_", "\\u\\u\\uNL\\u\\u\\u_", "#", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "See", " ", "CK", " ", "LICENSE", ".", "txt", " ", "for", " ", "lice", "nsi", "ng", " ", "details_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "See", " ", "CK", " ", "COPY", "RIG", "HT", ".", "txt", " ", "for", " ", "copyr", "ight", " ", "details_", "\\u\\u\\uNL\\u\\u\\u_", "#", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Dev", "elope", "r", ":", " ", "Gri", "gori", " ", "Fur", "sin_", "\\u\\u\\uNL\\u\\u\\u_", "#", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "cfg_", "=_", "{_", "}_", "#", " ", "Wil", "l", " ", "be", " ", "update", "d", " ", "by", " ", "CK", " ", "(", "meta", " ", "description", " ", "of", " ", "this", " ", "module", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "work_", "=_", "{_", "}_", "#", " ", "Wil", "l", " ", "be", " ", "update", "d", " ", "by", " ", "CK", " ", "(", "tempora", "l", " ", "data", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "ck_", "=_", "None_", "#", " ", "Wil", "l", " ", "be", " ", "update", "d", " ", "by", " ", "CK", " ", "(", "initialize", "d", " ", "CK", " ", "kernel", ")", " _", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "s", "\\u", "host_", "=_", "''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "s", "\\u", "port_", "=_", "''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Local", " ", "settings_", "\\u\\u\\uNL\\u\\u\\u_", "import_", "os_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "sys_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "cgi_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "urllib_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "base64_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "tempfile_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Import", " ", "vari", "ous", " ", "module", "s", " ", "whi", "le", " ", "support", "ing", " ", "bot", "h", " ", "Pyth", "on", " ", "2", ".", "x", " ", "and", " ", "3", ".", "x_", "\\u\\u\\uNL\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "from_", "http_", "._", "server_", "import_", "Base", "HTTP", "Request", "Handler_", ",_", "HTTP", "Server_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "from_", "Base", "HTTP", "Server_", "import_", "Base", "HTTP", "Request", "Handler_", ",_", "HTTP", "Server_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "import_", "urllib_", "._", "parse_", "as_", "urlparse_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "import_", "urlparse_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "from_", "urllib_", "._", "parse_", "import_", "quote_", "as_", "url", "quote_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "from_", "urllib_", "import_", "quote_", "as_", "url", "quote_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "from_", "urllib_", "._", "parse_", "import_", "unquote_", "as_", "urlu", "nq", "uot", "e_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "from_", "urllib_", "import_", "unquote_", "as_", "urlu", "nq", "uot", "e_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", "try", ":_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", " ", " ", "import", " ", "http", ".", "cookie", "s", " ", "as", " ", "Cookie_", "\\u\\u\\uNL\\u\\u\\u_", "#", "except", ":_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", " ", " ", "import", " ", "Cookie_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "from_", "socket", "server_", "import_", "Thread", "ing", "Mix", "In_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "from_", "Sock", "et", "Server_", "import_", "Thread", "ing", "Mix", "In_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "###########", "###########", "###########", "###########", "###########", "###########", "###########", "#", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Initializ", "e", " ", "module_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "###########", "###########", "###########", "###########", "###########", "###########", "###########", "#", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Access", " ", "CK", " ", "through", " ", "CMD", " ", "(", "can", " ", "deta", "ch", " ", "console", ")_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "###########", "###########", "###########", "###########", "###########", "###########", "###########", "#", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Sen", "d", " ", "error", " ", "to", " ", "HTTP", " ", "stream_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "###########", "###########", "###########", "###########", "###########", "###########", "###########", "#", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Sen", "d", " ", "error", " ", "to", " ", "HTTP", " ", "stream_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "###########", "###########", "###########", "###########", "###########", "###########", "###########", "#", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Process", " ", "CK", " ", "web", " ", "service", " ", "request", " ", "(", "bot", "h", " ", "GET", " ", "and", " ", "POST", ")_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "###########", "###########", "###########", "###########", "###########", "###########", "###########", "#", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Class", " ", "to", " ", "handle", " ", "request", "s", " ", "in", " ", "separate", " ", "threads_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "###########", "###########", "###########", "###########", "###########", "###########", "###########", "#", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Class", " ", "to", " ", "handle", " ", "CK", " ", "web", " ", "service", " ", "requests_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "###########", "###########", "###########", "###########", "###########", "###########", "###########", "#", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "start", " ", "web", " ", "service_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "###########", "###########", "###########", "###########", "###########", "###########", "###########", "#", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "test", " ", "web_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "process", "\\u", "ck", "\\u", "web", "\\u", "request_", "(_", "i_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "Inp", "ut", ":", " ", " ", "{", "\\", "10", ";", " ", " ", " ", " ", " ", " ", "http", " ", "-", " ", "Pyth", "on", " ", "http", " ", "object", "\\", "10", ";", " ", " ", " ", " ", "}", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "Output", ":", " ", "{", " ", "Non", "e", " ", "}", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "http", " ", "object_", "\\u\\u\\uNL\\u\\u\\u_", "http_", "=_", "i_", "[_", "'", "http", "'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Pars", "e", " ", "GET", " ", "variab", "les", " ", "and", " ", "path_", "\\u\\u\\uNL\\u\\u\\u_", "xg", "et_", "=_", "{_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "xpath_", "=_", "{_", "'", "host", "'_", ":_", "''_", ",_", "'", "port", "'_", ":_", "''_", ",_", "'", "first", "'_", ":_", "''_", ",_", "'", "rest", "'_", ":_", "''_", ",_", "'", "query", "'_", ":_", "''_", "}_", "#", " ", "Ma", "y", " ", "be", " ", "used", " ", "in", " ", "the", " ", "future_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "xt_", "=_", "'", "json", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "xpath_", "[_", "'", "host", "'_", "]_", "=_", "i_", "._", "get_", "(_", "'", "host", "'_", ",_", "''_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "xpath_", "[_", "'", "port", "'_", "]_", "=_", "i_", "._", "get_", "(_", "'", "port", "'_", ",_", "''_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Check", " ", "GET", " ", "variables_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "http_", "._", "path_", "!=_", "''_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "http_", "._", "send", "\\u", "response_", "(_", "200_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "a_", "=_", "urlparse_", "._", "urlparse_", "(_", "http_", "._", "path_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "xp_", "=_", "a_", "._", "path_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "xr_", "=_", "''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "xp_", "._", "startswith_", "(_", "'/'_", ")_", ":_", "xp_", "=_", "xp_", "[_", "1_", ":_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "u_", "=_", "xp_", "._", "find_", "(_", "'/'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "u_", ">=_", "0_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "xr_", "=_", "xp_", "[_", "u_", "+_", "1_", ":_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "xp_", "=_", "xp_", "[_", ":_", "u_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "xt_", "=_", "xp_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "xpath_", "[_", "'", "first", "'_", "]_", "=_", "xp_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "xpath_", "[_", "'", "rest", "'_", "]_", "=_", "xr_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "xpath_", "[_", "'", "query", "'_", "]_", "=_", "a_", "._", "query_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "b_", "=_", "urlparse_", "._", "parse", "\\u", "qs_", "(_", "a_", "._", "query_", ",_", "keep", "\\u", "blank", "\\u", "values_", "=_", "True_", ",_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "xg", "et_", "=_", "{_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "k_", "in_", "b_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", " ", " ", "xg", "et", "[", "k", "]=", "b", "[", "k", "][", "0", "]_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "xg", "et_", "[_", "k_", "]_", "=_", "urlu", "nq", "uot", "e_", "(_", "b_", "[_", "k_", "]_", "[_", "0_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "sys_", "._", "version", "\\u", "info_", "[_", "0_", "]_", "<_", "3_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "xg", "et_", "[_", "k_", "]_", "=_", "xg", "et_", "[_", "k_", "]_", "._", "decode_", "(_", "'", "utf", "8", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Check", " ", "POST_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "xpo", "st_", "=_", "{_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "xpo", "st1", "_", "=_", "{_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "headers_", "=_", "http_", "._", "headers_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "content", "\\u", "type_", "=_", "headers_", "._", "get_", "(_", "'", "content", "-", "type", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "ctype_", "=_", "''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "content", "\\u", "type_", "!=_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "ctype_", ",_", "pdict", "_", "=_", "cgi_", "._", "parse", "\\u", "header_", "(_", "content", "\\u", "type_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Pyth", "on", "3", " ", "cgi", ".", "parse", "\\u", "multip", "art", " ", "expect", "s", " ", "bound", "ary", " ", "to", " ", "be", " ", "bytes", ",", " ", "not", " ", "str", "._", "\\u\\u\\uNL\\u\\u\\u_", "if_", "sys_", "._", "version", "\\u", "info_", "[_", "0_", "]_", "<_", "3_", "and_", "'", "bound", "ary", "'_", "in_", "pdict", "_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "pdict", "_", "[_", "'", "bound", "ary", "'_", "]_", "=_", "pdict", "_", "[_", "'", "bound", "ary", "'_", "]_", "._", "encode_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "ctype_", "==_", "'", "multip", "art", "/", "form", "-", "data", "'_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "sys_", "._", "version", "\\u", "info_", "[_", "0_", "]_", "<_", "3_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "xpo", "st1", "_", "=_", "cgi_", "._", "parse", "\\u", "multipart_", "(_", "http_", "._", "rfile_", ",_", "pdict", "_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "xx", "post", "1_", "=_", "cgi_", "._", "Field", "Storage_", "(_", "fp_", "=_", "http_", "._", "rfile_", ",_", "headers_", "=_", "headers_", ",_", "environ_", "=_", "{_", "'", "REQUEST", "\\u", "METH", "OD", "'_", ":_", "'", "POST", "'_", "}_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "k_", "in_", "xx", "post", "1_", "._", "keys_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "xpo", "st1", "_", "[_", "k_", "]_", "=_", "[_", "xx", "post", "1_", "[_", "k_", "]_", "._", "value_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "ctype_", "==_", "'", "applica", "tion", "/", "x", "-", "www", "-", "form", "-", "url", "encode", "d", "'_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "length_", "=_", "int_", "(_", "http_", "._", "headers_", "._", "get_", "(_", "'", "content", "-", "length", "'_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "s_", "=_", "http_", "._", "rfile_", "._", "read_", "(_", "length_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "sys_", "._", "version", "\\u", "info_", "[_", "0_", "]_", ">_", "2_", ":_", "s_", "=_", "s_", "._", "decode_", "(_", "'", "utf", "8", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "xpo", "st1", "_", "=_", "cgi_", "._", "parse", "\\u", "qs_", "(_", "s_", ",_", "keep", "\\u", "blank", "\\u", "values_", "=_", "1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "Exception_", "as_", "e_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "bin_", "=_", "b", "'", "internal", " ", "CK", " ", "web", " ", "service", " ", "error", " ", "[", "710", "1", "]", " ", "('_", "+_", "format_", "(_", "e_", ")_", "._", "encode_", "(_", "'", "utf", "8", "'_", ")_", "+_", "')'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "web", "\\u", "err_", "(_", "{_", "'", "http", "'_", ":_", "http_", ",_", "'", "type", "'_", ":_", "xt_", ",_", "'", "bin", "'_", ":_", "bin_", "}_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "ck_", "._", "out_", "(_", "ck_", "._", "cfg_", "[_", "'", "error", "'_", "]_", "+_", "bin_", "._", "decode_", "(_", "'", "utf", "8", "'_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Post", " ", "processing_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "for_", "k_", "in_", "xpo", "st1", "_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "v_", "=_", "xpo", "st1", "_", "[_", "k_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "k_", "._", "endswith_", "(_", "'[]'_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "k1_", "=_", "k_", "[_", ":_", "-_", "2_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "xpo", "st_", "[_", "k1_", "]_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "l_", "in_", "v_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "xpo", "st_", "[_", "k1_", "]_", "._", "append_", "(_", "urlu", "nq", "uot", "e_", "(_", "l_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "k_", "!=_", "'", "file", "\\u", "content", "'_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "xpo", "st_", "[_", "k_", "]_", "=_", "urlu", "nq", "uot", "e_", "(_", "v_", "[_", "0_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "xpo", "st_", "[_", "k_", "]_", "=_", "v_", "[_", "0_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "k_", "==_", "'", "file", "\\u", "content", "'_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "fc", "rt_", "=_", "xpo", "st1", "_", "._", "get_", "(_", "'", "file", "\\u", "content", "\\u", "record", "\\u", "to", "\\u", "tmp", "'_", ",_", "''_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "(_", "type_", "(_", "fc", "rt_", ")_", "==_", "list_", "and_", "len_", "(_", "fc", "rt_", ")_", ">_", "0_", "and_", "fc", "rt_", "[_", "0_", "]_", "==_", "'", "ye", "s", "'_", ")_", "or_", "fc", "rt_", "==_", "'", "ye", "s", "'_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "fd_", ",_", "fn_", "=_", "tempfile_", "._", "mkstemp_", "(_", "suffix_", "=_", "'.", "tmp", "'_", ",_", "prefix_", "=_", "'", "ck", "-'_", ")_", "#", " ", "suff", "ix", " ", "is", " ", "importa", "nt", " ", "-", " ", "CK", " ", "will", " ", "delete", " ", "suc", "h", " ", "file", "!", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "os_", "._", "close_", "(_", "fd_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "f_", "=_", "open_", "(_", "fn_", ",_", "'", "wb", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "f_", "._", "write_", "(_", "xpo", "st_", "[_", "k_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "f_", "._", "close_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "xpo", "st_", "[_", "k_", "+_", "'\\u", "uploade", "d", "'_", "]_", "=_", "fn_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "del_", "(_", "xpo", "st_", "[_", "k_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "k_", "+=_", "'\\u", "uploade", "d", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "import_", "base64_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "xpo", "st_", "[_", "k_", "+_", "'\\u", "base64", "'_", "]_", "=_", "base64_", "._", "urlsafe", "\\u", "b64encode_", "(_", "xpo", "st_", "[_", "k_", "]_", ")_", "._", "decode_", "(_", "'", "utf", "8", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "del_", "(_", "xpo", "st_", "[_", "k_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "k_", "+=_", "'\\u", "base64", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "sys_", "._", "version", "\\u", "info_", "[_", "0_", "]_", "<_", "3_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "xpo", "st_", "[_", "k_", "]_", "=_", "xpo", "st_", "[_", "k_", "]_", "._", "decode_", "(_", "'", "utf", "8", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Prepare", " ", "input", " ", "and", " ", "check", " ", "if", " ", "CK", " ", "json", " ", "present_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "ii_", "=_", "xg", "et_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "ii_", "._", "update_", "(_", "xpo", "st_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "cj_", "=_", "ii_", "._", "get_", "(_", "'", "ck", "\\u", "json", "'_", ",_", "''_", ")_", "._", "strip_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "cj_", "!=_", "''_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "r_", "=_", "ck_", "._", "convert", "\\u", "json", "\\u", "str", "\\u", "to", "\\u", "dict_", "(_", "{_", "'", "str", "'_", ":_", "cj_", ",_", "'", "skip", "\\u", "quote", "\\u", "replace", "ment", "'_", ":_", "'", "ye", "s", "'_", "}_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "r_", "[_", "'", "return", "'_", "]_", ">_", "0_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "bin_", "=_", "b", "'", "internal", " ", "CK", " ", "web", " ", "service", " ", "error", " ", "[", "710", "2", "]", " ", "('_", "+_", "r_", "[_", "'", "error", "'_", "]_", "._", "encode_", "(_", "'", "utf", "8", "'_", ")_", "+_", "b", "')'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "web", "\\u", "err_", "(_", "{_", "'", "http", "'_", ":_", "http_", ",_", "'", "type", "'_", ":_", "xt_", ",_", "'", "bin", "'_", ":_", "bin_", "}_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "ck_", "._", "out_", "(_", "ck_", "._", "cfg_", "[_", "'", "error", "'_", "]_", "+_", "bin_", "._", "decode_", "(_", "'", "utf", "8", "'_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "del_", "(_", "ii_", "[_", "'", "ck", "\\u", "json", "'_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "ii_", "._", "update_", "(_", "r_", "[_", "'", "dict", "'_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Mis", "c", " ", "parameters_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "dc_", "=_", "ii_", "._", "get_", "(_", "'", "deta", "ch", "\\u", "console", "'_", ",_", "''_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "act_", "=_", "ii_", "._", "get_", "(_", "'", "action", "'_", ",_", "''_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Check", " ", "output", " ", "type_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "ii_", "._", "get_", "(_", "'", "out", "'_", ",_", "''_", ")_", "!=_", "''_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "xt_", "=_", "ii_", "[_", "'", "out", "'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "xt_", "==_", "''_", ":_", "xt_", "=_", "'", "web", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "xt_", "!=_", "'", "json", "'_", "and_", "xt_", "!=_", "'", "con", "'_", "and_", "xt_", "!=_", "'", "web", "'_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "web", "\\u", "out_", "(_", "{_", "'", "http", "'_", ":_", "http_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "type", "'_", ":_", "'", "web", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "bin", "'_", ":_", "b", "'", "Un", "know", "n", " ", "CK", " ", "request", " ", "('_", "+_", "xt_", "._", "encode_", "(_", "'", "utf", "8", "'_", ")_", "+_", "b", "')", "!'_", "}_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Prepare", " ", "temporar", "y", " ", "output", " ", "file_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "fd_", ",_", "fn_", "=_", "tempfile_", "._", "mkstemp_", "(_", "prefix_", "=_", "'", "ck", "-'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "os_", "._", "close_", "(_", "fd_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "os_", "._", "remove_", "(_", "fn_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Check", " ", "output_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "dc_", "==_", "'", "ye", "s", "'_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "ck_", "._", "cfg_", "._", "get_", "(_", "'", "for", "bid", "\\u", "detached", "\\u", "console", "'_", ",_", "''_", ")_", "==_", "'", "ye", "s", "'_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "web", "\\u", "out_", "(_", "{_", "'", "http", "'_", ":_", "http_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "type", "'_", ":_", "'", "web", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "bin", "'_", ":_", "b", "'", "Detach", "ed", " ", "console", " ", "is", " ", "forbidden", "!'_", "}_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "ii_", "[_", "'", "out", "\\u", "file", "'_", "]_", "=_", "fn_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "ii_", "[_", "'", "web", "'_", "]_", "=_", "'", "ye", "s", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "xt_", "==_", "'", "json", "'_", "or_", "xt_", "==_", "'", "web", "'_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "ii_", "[_", "'", "out", "'_", "]_", "=_", "'", "json", "\\u", "file", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "else", " ", "output", " ", "to", " ", "console", " ", "(", "for", " ", "remote", " ", "access", " ", "for", " ", "example", ")_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "ii_", "[_", "'", "con", "\\u", "encoding", "'_", "]_", "=_", "'", "utf", "8", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "ii_", "[_", "'", "server", "\\u", "host", "'_", "]_", "=_", "s", "\\u", "host_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "ii_", "[_", "'", "server", "\\u", "port", "'_", "]_", "=_", "s", "\\u", "port_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Execut", "e", " ", "command", " ", "***********", "***********", "***********", "***********", "***********", "**_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "act_", "==_", "''_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "cfg_", "._", "get_", "(_", "'", "if", "\\u", "web", "\\u", "action", "\\u", "not", "\\u", "defin", "ed", "'_", ",_", "''_", ")_", "!=_", "''_", "and_", "cfg_", "._", "get_", "(_", "'", "if", "\\u", "web", "\\u", "module", "\\u", "not", "\\u", "defin", "ed", "'_", ",_", "''_", ")_", "!=_", "''_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "ii_", "[_", "'", "module", "\\u", "uo", "a", "'_", "]_", "=_", "cfg_", "[_", "'", "if", "\\u", "web", "\\u", "module", "\\u", "not", "\\u", "defin", "ed", "'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "ii_", "[_", "'", "action", "'_", "]_", "=_", "cfg_", "[_", "'", "if", "\\u", "web", "\\u", "action", "\\u", "not", "\\u", "defin", "ed", "'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "r_", "=_", "call", "\\u", "ck_", "(_", "ii_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Process", " ", "output_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "r_", "[_", "'", "return", "'_", "]_", ">_", "0_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "os_", "._", "path_", "._", "isfile_", "(_", "fn_", ")_", ":_", "os_", "._", "remove_", "(_", "fn_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "bout", "_", "=_", "r_", "[_", "'", "error", "'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "try_", ":_", "bout", "_", "=_", "bout", "_", "._", "encode_", "(_", "'", "utf", "-", "8", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "except_", "Exception_", "as_", "e_", ":_", "pass_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "web", "\\u", "err_", "(_", "{_", "'", "http", "'_", ":_", "http_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "type", "'_", ":_", "xt_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "bin", "'_", ":_", "bout", "_", "}_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "If", " ", "output", " ", "to", " ", "console", " ", "or", " ", "detached", " ", "console_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "xt_", "==_", "'", "con", "'_", "or_", "dc_", "==_", "'", "ye", "s", "'_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "os_", "._", "path_", "._", "isfile_", "(_", "fn_", ")_", ":_", "os_", "._", "remove_", "(_", "fn_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "bout", "_", "=_", "r_", "._", "get_", "(_", "'", "std", "'_", ",_", "''_", ")_", "._", "encode_", "(_", "'", "utf", "8", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "web", "\\u", "out_", "(_", "{_", "'", "http", "'_", ":_", "http_", ",_", "'", "type", "'_", ":_", "xt_", ",_", "'", "bin", "'_", ":_", "bout", "_", "}_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "return_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "If", " ", "json", " ", "or", " ", "web_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Tr", "y", " ", "to", " ", "load", " ", "output", " ", "file_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "not_", "os_", "._", "path_", "._", "isfile_", "(_", "fn_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "web", "\\u", "err_", "(_", "{_", "'", "http", "'_", ":_", "http_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "type", "'_", ":_", "xt_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "bin", "'_", ":_", "b", "'", "Output", " ", "json", " ", "file", " ", "was", " ", "not", " ", "created", ",", " ", "see", " ", "output", " ", "('_", "+_", "r_", "[_", "'", "std", "'_", "]_", "._", "encode_", "(_", "'", "utf", "8", "'_", ")_", "+_", "b", "')", "!'_", "}_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "r_", "=_", "ck_", "._", "load", "\\u", "text", "\\u", "file_", "(_", "{_", "'", "text", "\\u", "file", "'_", ":_", "fn_", ",_", "'", "keep", "\\u", "as", "\\u", "bin", "'_", ":_", "'", "ye", "s", "'_", "}_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "r_", "[_", "'", "return", "'_", "]_", ">_", "0_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "bout", "_", "=_", "r_", "[_", "'", "error", "'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "try_", ":_", "bout", "_", "=_", "bout", "_", "._", "encode_", "(_", "'", "utf", "-", "8", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "except_", "Exception_", "as_", "e_", ":_", "pass_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "web", "\\u", "err_", "(_", "{_", "'", "http", "'_", ":_", "http_", ",_", "'", "type", "'_", ":_", "xt_", ",_", "'", "bin", "'_", ":_", "bout", "_", "}_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "return_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "bin_", "=_", "r_", "[_", "'", "bin", "'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "os_", "._", "path_", "._", "isfile_", "(_", "fn_", ")_", ":_", "os_", "._", "remove_", "(_", "fn_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Process", " ", "JSO", "N", " ", "output", " ", "from", " ", "file_", "\\u\\u\\uNL\\u\\u\\u_", "fx_", "=_", "''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "sys_", "._", "version", "\\u", "info_", "[_", "0_", "]_", ">_", "2_", ":_", "bin_", "=_", "bin_", "._", "decode_", "(_", "'", "utf", "-", "8", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "ru", "_", "=_", "ck_", "._", "convert", "\\u", "json", "\\u", "str", "\\u", "to", "\\u", "dict_", "(_", "{_", "'", "str", "'_", ":_", "bin_", ",_", "'", "skip", "\\u", "quote", "\\u", "replace", "ment", "'_", ":_", "'", "ye", "s", "'_", "}_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "ru", "_", "[_", "'", "return", "'_", "]_", ">_", "0_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "bout", "_", "=_", "ru", "_", "[_", "'", "error", "'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "try_", ":_", "bout", "_", "=_", "bout", "_", "._", "encode_", "(_", "'", "utf", "-", "8", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "except_", "Exception_", "as_", "e_", ":_", "pass_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "web", "\\u", "err_", "(_", "{_", "'", "http", "'_", ":_", "http_", ",_", "'", "type", "'_", ":_", "xt_", ",_", "'", "bin", "'_", ":_", "bout", "_", "}_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "return_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "rr_", "=_", "ru", "_", "[_", "'", "dict", "'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "rr_", "[_", "'", "return", "'_", "]_", ">_", "0_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "bout", "_", "=_", "rr_", "[_", "'", "error", "'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "try_", ":_", "bout", "_", "=_", "bout", "_", "._", "encode_", "(_", "'", "utf", "-", "8", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "except_", "Exception_", "as_", "e_", ":_", "pass_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "web", "\\u", "err_", "(_", "{_", "'", "http", "'_", ":_", "http_", ",_", "'", "type", "'_", ":_", "xt_", ",_", "'", "bin", "'_", ":_", "bout", "_", "}_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Check", " ", "if", " ", "file", " ", "was", " ", "returned_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "fr_", "=_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "'", "file", "\\u", "content", "\\u", "base64", "'_", "in_", "rr_", "and_", "rr_", "._", "get_", "(_", "'", "filename", "'_", ",_", "''_", ")_", "!=_", "''_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "fr_", "=_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Check", " ", "if", " ", "download_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "(_", "xt_", "==_", "'", "web", "'_", "and_", "fr_", ")_", "or_", "(_", "act_", "==_", "'", "pull", "'_", "and_", "xt_", "!=_", "'", "json", "'_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "import_", "base64_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "x_", "=_", "rr_", "._", "get_", "(_", "'", "file", "\\u", "content", "\\u", "base64", "'_", ",_", "''_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "fx_", "=_", "rr_", "._", "get_", "(_", "'", "filename", "'_", ",_", "''_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "fx_", "==_", "''_", ":_", "fx_", "=_", "ck_", "._", "cfg_", "[_", "'", "default", "\\u", "archive", "\\u", "name", "'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Fix", "ing", " ", "Pyth", "on", " ", "bug_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "sys_", "._", "version", "\\u", "info_", "[_", "0_", "]_", "==_", "3_", "and_", "sys_", "._", "version", "\\u", "info_", "[_", "1_", "]_", "<_", "3_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "x_", "=_", "x_", "._", "encode_", "(_", "'", "utf", "-", "8", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "x_", "=_", "str_", "(_", "x_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "bin_", "=_", "base64_", "._", "urlsafe", "\\u", "b64decode_", "(_", "x_", ")_", "#", " ", "convert", " ", "from", " ", "unicode", " ", "to", " ", "str", " ", "sinc", "e", " ", "base64", " ", "works", " ", "on", " ", "strings_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "shou", "ld", " ", "be", " ", "safe", " ", "in", " ", "Pyth", "on", " ", "2", ".", "x", " ", "and", " ", "3", ".", "x_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Process", " ", "extension_", "\\u\\u\\uNL\\u\\u\\u_", "fn", "1_", ",_", "fn", "e_", "=_", "os_", "._", "path_", "._", "splitext_", "(_", "fx_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "fn", "e_", "._", "startswith_", "(_", "'.'_", ")_", ":_", "fn", "e_", "=_", "fn", "e_", "[_", "1_", ":_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "fn", "e_", "!=_", "''_", ":_", "xt_", "=_", "fn", "e_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "else_", ":_", "xt_", "=_", "'", "unknown", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Check", " ", "and", " ", "output", " ", "html_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "rr_", "._", "get_", "(_", "'", "html", "'_", ",_", "''_", ")_", "!=_", "''_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "bin_", "=_", "rr_", "[_", "'", "html", "'_", "]_", "._", "encode_", "(_", "'", "utf", "-", "8", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "sys_", "._", "version", "\\u", "info_", "[_", "0_", "]_", ">_", "2_", ":_", "#", " ", "Un", "know", "n", " ", "output_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "bin_", "=_", "bin_", "._", "encode_", "(_", "'", "utf", "-", "8", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "web", "\\u", "out_", "(_", "{_", "'", "http", "'_", ":_", "http_", ",_", "'", "type", "'_", ":_", "xt_", ",_", "'", "bin", "'_", ":_", "bin_", ",_", "'", "filename", "'_", ":_", "fx_", "}_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "return_", "{_", "'", "return", "'_", ":_", "0_", "}_",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 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 ]
Imprecise assert
zunzun/pyeq2/UnitTests/Test_ExtendedVersionHandlers.py
[ { "content": " def test_ExtendedVersion_Exponential_WithOffset_2D(self):\n equation = pyeq2.Models_2D.Exponential.Exponential('SSQABS', 'Offset')\n self.assertEqual(equation.extendedVersionHandler.__class__.__name__, 'ExtendedVersionHandler_Offset')\n self.assertEqual(equation.GetDisplayHTML(), 'y = a * exp(bx) + Offset')\n self.assertEqual(equation.GetDisplayName(), 'Exponential With Offset')\n self.assertEqual(equation.GetCoefficientDesignators(), ['a', 'b', 'Offset'])\n self.assertEqual(len(equation.GetDataCacheFunctions()), 1)\n self.assertFalse(equation.CanLinearSolverBeUsedForSSQABS())\n\n pyeq2.dataConvertorService().ConvertAndSortColumnarASCII(DataForUnitTests.asciiDataInColumns_2D, equation, False)\n \n equation.Solve()\n fittingTarget = equation.CalculateAllDataFittingTarget(equation.solvedCoefficients)\n self.assertTrue(fittingTarget <= 0.018)", "metadata": "root.TestExtendedVersionHandlers.test_ExtendedVersion_Exponential_WithOffset_2D", "header": "['class', 'TestExtendedVersionHandlers', '(', 'unittest', '.', 'TestCase', ')', ':', '___EOS___']", "index": 21 }, { "content": " def test_ExtendedVersion_Reciprocal_Exponential_2D(self):\n equation = pyeq2.Models_2D.Exponential.Exponential('SSQABS', 'Reciprocal')\n self.assertEqual(equation.extendedVersionHandler.__class__.__name__, 'ExtendedVersionHandler_Reciprocal')\n self.assertEqual(equation.GetDisplayHTML(), 'y = a * exp(bx)<br>y = 1.0 / y')\n self.assertEqual(equation.GetDisplayName(), 'Reciprocal Exponential')\n self.assertEqual(equation.GetCoefficientDesignators(), ['a', 'b'])\n self.assertEqual(len(equation.GetDataCacheFunctions()), 1)\n self.assertFalse(equation.CanLinearSolverBeUsedForSSQABS())\n\n pyeq2.dataConvertorService().ConvertAndSortColumnarASCII(DataForUnitTests.asciiDataInColumns_2D, equation, False)\n \n equation.Solve()\n fittingTarget = equation.CalculateAllDataFittingTarget(equation.solvedCoefficients)\n self.assertTrue(fittingTarget <= 1.9)", "metadata": "root.TestExtendedVersionHandlers.test_ExtendedVersion_Reciprocal_Exponential_2D", "header": "['class', 'TestExtendedVersionHandlers', '(', 'unittest', '.', 'TestCase', ')', ':', '___EOS___']", "index": 37 }, { "content": " def test_ExtendedVersion_Reciprocal_Exponential_WithOffset_2D(self):\n equation = pyeq2.Models_2D.Exponential.Exponential('SSQABS', 'Reciprocal With Offset')\n self.assertEqual(equation.extendedVersionHandler.__class__.__name__, 'ExtendedVersionHandler_ReciprocalWithOffset')\n self.assertEqual(equation.GetDisplayHTML(), 'y = a * exp(bx)<br>y = 1.0 / y + Offset')\n self.assertEqual(equation.GetDisplayName(), 'Reciprocal Exponential With Offset')\n self.assertEqual(equation.GetCoefficientDesignators(), ['a', 'b', 'Offset'])\n self.assertEqual(len(equation.GetDataCacheFunctions()), 1)\n self.assertFalse(equation.CanLinearSolverBeUsedForSSQABS())\n\n pyeq2.dataConvertorService().ConvertAndSortColumnarASCII(DataForUnitTests.asciiDataInColumns_2D, equation, False)\n \n equation.Solve()\n fittingTarget = equation.CalculateAllDataFittingTarget(equation.solvedCoefficients)\n self.assertTrue(fittingTarget <= 0.018)", "metadata": "root.TestExtendedVersionHandlers.test_ExtendedVersion_Reciprocal_Exponential_WithOffset_2D", "header": "['class', 'TestExtendedVersionHandlers', '(', 'unittest', '.', 'TestCase', ')', ':', '___EOS___']", "index": 53 }, { "content": " def test_ExtendedVersion_Inverse_Exponential_2D(self):\n equation = pyeq2.Models_2D.Exponential.Exponential('SSQABS', 'Inverse')\n self.assertEqual(equation.extendedVersionHandler.__class__.__name__, 'ExtendedVersionHandler_Inverse')\n self.assertEqual(equation.GetDisplayHTML(), 'y = a * exp(bx)<br>y = x / y')\n self.assertEqual(equation.GetDisplayName(), 'Inverse Exponential')\n self.assertEqual(equation.GetCoefficientDesignators(), ['a', 'b'])\n self.assertEqual(len(equation.GetDataCacheFunctions()), 1)\n self.assertFalse(equation.CanLinearSolverBeUsedForSSQABS())\n\n pyeq2.dataConvertorService().ConvertAndSortColumnarASCII(DataForUnitTests.asciiDataInColumns_2D, equation, False)\n \n equation.Solve()\n fittingTarget = equation.CalculateAllDataFittingTarget(equation.solvedCoefficients)\n self.assertTrue(fittingTarget <= 1.6)", "metadata": "root.TestExtendedVersionHandlers.test_ExtendedVersion_Inverse_Exponential_2D", "header": "['class', 'TestExtendedVersionHandlers', '(', 'unittest', '.', 'TestCase', ')', ':', '___EOS___']", "index": 69 }, { "content": " def test_ExtendedVersion_Inverse_Exponential_WithOffset_2D(self):\n equation = pyeq2.Models_2D.Exponential.Exponential('SSQABS', 'Inverse With Offset')\n self.assertEqual(equation.extendedVersionHandler.__class__.__name__, 'ExtendedVersionHandler_InverseWithOffset')\n self.assertEqual(equation.GetDisplayHTML(), 'y = a * exp(bx)<br>y = x / y + Offset')\n self.assertEqual(equation.GetDisplayName(), 'Inverse Exponential With Offset')\n self.assertEqual(equation.GetCoefficientDesignators(), ['a', 'b', 'Offset'])\n self.assertEqual(len(equation.GetDataCacheFunctions()), 1)\n self.assertFalse(equation.CanLinearSolverBeUsedForSSQABS())\n\n pyeq2.dataConvertorService().ConvertAndSortColumnarASCII(DataForUnitTests.asciiDataInColumns_2D, equation, False)\n \n equation.Solve()\n fittingTarget = equation.CalculateAllDataFittingTarget(equation.solvedCoefficients)\n self.assertTrue(fittingTarget <= 0.018)", "metadata": "root.TestExtendedVersionHandlers.test_ExtendedVersion_Inverse_Exponential_WithOffset_2D", "header": "['class', 'TestExtendedVersionHandlers', '(', 'unittest', '.', 'TestCase', ')', ':', '___EOS___']", "index": 85 }, { "content": " def test_ExtendedVersion_Exponential_WithLinearDecay_2D(self):\n equation = pyeq2.Models_2D.Exponential.Exponential('SSQABS', 'Linear Decay')\n self.assertEqual(equation.extendedVersionHandler.__class__.__name__, 'ExtendedVersionHandler_LinearDecay')\n self.assertEqual(equation.GetDisplayHTML(), 'y = a * exp(bx)<br>y = y / x')\n self.assertEqual(equation.GetDisplayName(), 'Exponential With Linear Decay')\n self.assertEqual(equation.GetCoefficientDesignators(), ['a', 'b'])\n self.assertEqual(len(equation.GetDataCacheFunctions()), 1)\n self.assertFalse(equation.CanLinearSolverBeUsedForSSQABS())\n\n pyeq2.dataConvertorService().ConvertAndSortColumnarASCII(DataForUnitTests.asciiDataInColumns_2D, equation, False)\n \n equation.Solve()\n fittingTarget = equation.CalculateAllDataFittingTarget(equation.solvedCoefficients)\n self.assertTrue(fittingTarget <= 2.2)", "metadata": "root.TestExtendedVersionHandlers.test_ExtendedVersion_Exponential_WithLinearDecay_2D", "header": "['class', 'TestExtendedVersionHandlers', '(', 'unittest', '.', 'TestCase', ')', ':', '___EOS___']", "index": 101 }, { "content": " def test_ExtendedVersion_Exponential_WithLinearDecayAndOffset_2D(self):\n equation = pyeq2.Models_2D.Exponential.Exponential('SSQABS', 'Linear Decay And Offset')\n self.assertEqual(equation.extendedVersionHandler.__class__.__name__, 'ExtendedVersionHandler_LinearDecayAndOffset')\n self.assertEqual(equation.GetDisplayHTML(), 'y = a * exp(bx)<br>y = y / x + Offset')\n self.assertEqual(equation.GetDisplayName(), 'Exponential With Linear Decay And Offset')\n self.assertEqual(equation.GetCoefficientDesignators(), ['a', 'b', 'Offset'])\n self.assertEqual(len(equation.GetDataCacheFunctions()), 1)\n self.assertFalse(equation.CanLinearSolverBeUsedForSSQABS())\n\n pyeq2.dataConvertorService().ConvertAndSortColumnarASCII(DataForUnitTests.asciiDataInColumns_2D, equation, False)\n \n equation.Solve()\n fittingTarget = equation.CalculateAllDataFittingTarget(equation.solvedCoefficients)\n self.assertTrue(fittingTarget <= 0.49)", "metadata": "root.TestExtendedVersionHandlers.test_ExtendedVersion_Exponential_WithLinearDecayAndOffset_2D", "header": "['class', 'TestExtendedVersionHandlers', '(', 'unittest', '.', 'TestCase', ')', ':', '___EOS___']", "index": 117 }, { "content": " def test_ExtendedVersion_Exponential_WithLinearGrowth_2D(self):\n equation = pyeq2.Models_2D.Exponential.Exponential('SSQABS', 'Linear Growth')\n self.assertEqual(equation.extendedVersionHandler.__class__.__name__, 'ExtendedVersionHandler_LinearGrowth')\n self.assertEqual(equation.GetDisplayHTML(), 'y = a * exp(bx)<br>y = y * x')\n self.assertEqual(equation.GetDisplayName(), 'Exponential With Linear Growth')\n self.assertEqual(equation.GetCoefficientDesignators(), ['a', 'b'])\n self.assertEqual(len(equation.GetDataCacheFunctions()), 1)\n self.assertFalse(equation.CanLinearSolverBeUsedForSSQABS())\n\n pyeq2.dataConvertorService().ConvertAndSortColumnarASCII(DataForUnitTests.asciiDataInColumns_2D, equation, False)\n \n equation.Solve()\n fittingTarget = equation.CalculateAllDataFittingTarget(equation.solvedCoefficients)\n self.assertTrue(fittingTarget <= 1.6)", "metadata": "root.TestExtendedVersionHandlers.test_ExtendedVersion_Exponential_WithLinearGrowth_2D", "header": "['class', 'TestExtendedVersionHandlers', '(', 'unittest', '.', 'TestCase', ')', ':', '___EOS___']", "index": 133 }, { "content": " def test_ExtendedVersion_Exponential_WithLinearGrowthAndOffset_2D(self):\n equation = pyeq2.Models_2D.Exponential.Exponential('SSQABS', 'Linear Growth And Offset')\n self.assertEqual(equation.extendedVersionHandler.__class__.__name__, 'ExtendedVersionHandler_LinearGrowthAndOffset')\n self.assertEqual(equation.GetDisplayHTML(), 'y = a * exp(bx)<br>y = y * x + Offset')\n self.assertEqual(equation.GetDisplayName(), 'Exponential With Linear Growth And Offset')\n self.assertEqual(equation.GetCoefficientDesignators(), ['a', 'b', 'Offset'])\n self.assertEqual(len(equation.GetDataCacheFunctions()), 1)\n self.assertFalse(equation.CanLinearSolverBeUsedForSSQABS())\n\n pyeq2.dataConvertorService().ConvertAndSortColumnarASCII(DataForUnitTests.asciiDataInColumns_2D, equation, False)\n \n equation.Solve()\n fittingTarget = equation.CalculateAllDataFittingTarget(equation.solvedCoefficients)\n self.assertTrue(fittingTarget <= 0.018)", "metadata": "root.TestExtendedVersionHandlers.test_ExtendedVersion_Exponential_WithLinearGrowthAndOffset_2D", "header": "['class', 'TestExtendedVersionHandlers', '(', 'unittest', '.', 'TestCase', ')', ':', '___EOS___']", "index": 149 }, { "content": " def test_ExtendedVersion_Asymptotic_Exponential_A_WithExponentialGrowth_2D(self):\n equation = pyeq2.Models_2D.Exponential.AsymptoticExponentialA('SSQABS', 'Exponential Growth')\n self.assertEqual(equation.extendedVersionHandler.__class__.__name__, 'ExtendedVersionHandler_ExponentialGrowth')\n self.assertEqual(equation.GetDisplayHTML(), 'y = 1.0 - a<sup>x</sup><br>y = y * (b * exp(x))')\n self.assertEqual(equation.GetDisplayName(), 'Asymptotic Exponential A With Exponential Growth')\n self.assertEqual(equation.GetCoefficientDesignators(), ['a', 'b'])\n self.assertEqual(len(equation.GetDataCacheFunctions()), 2)\n self.assertFalse(equation.CanLinearSolverBeUsedForSSQABS())\n\n pyeq2.dataConvertorService().ConvertAndSortColumnarASCII(DataForUnitTests.asciiDataInColumns_2D, equation, False)\n \n equation.Solve()\n fittingTarget = equation.CalculateAllDataFittingTarget(equation.solvedCoefficients)\n self.assertTrue(fittingTarget <= 21.0)", "metadata": "root.TestExtendedVersionHandlers.test_ExtendedVersion_Asymptotic_Exponential_A_WithExponentialGrowth_2D", "header": "['class', 'TestExtendedVersionHandlers', '(', 'unittest', '.', 'TestCase', ')', ':', '___EOS___']", "index": 165 }, { "content": " def test_ExtendedVersion_Asymptotic_Exponential_A_WithExponentialGrowthAndOffset_2D(self):\n equation = pyeq2.Models_2D.Exponential.AsymptoticExponentialA('SSQABS', 'Exponential Growth And Offset')\n self.assertEqual(equation.extendedVersionHandler.__class__.__name__, 'ExtendedVersionHandler_ExponentialGrowthAndOffset')\n self.assertEqual(equation.GetDisplayHTML(), 'y = 1.0 - a<sup>x</sup><br>y = y * (b * exp(x)) + Offset')\n self.assertEqual(equation.GetDisplayName(), 'Asymptotic Exponential A With Exponential Growth And Offset')\n self.assertEqual(equation.GetCoefficientDesignators(), ['a', 'b', 'Offset'])\n self.assertEqual(len(equation.GetDataCacheFunctions()), 2)\n self.assertFalse(equation.CanLinearSolverBeUsedForSSQABS())\n\n pyeq2.dataConvertorService().ConvertAndSortColumnarASCII(DataForUnitTests.asciiDataInColumns_2D, equation, False)\n \n equation.Solve()\n fittingTarget = equation.CalculateAllDataFittingTarget(equation.solvedCoefficients)\n self.assertTrue(fittingTarget <= 7.0)", "metadata": "root.TestExtendedVersionHandlers.test_ExtendedVersion_Asymptotic_Exponential_A_WithExponentialGrowthAndOffset_2D", "header": "['class', 'TestExtendedVersionHandlers', '(', 'unittest', '.', 'TestCase', ')', ':', '___EOS___']", "index": 181 }, { "content": " def test_ExtendedVersion_Asymptotic_Exponential_A_WithExponentialDecay_2D(self):\n equation = pyeq2.Models_2D.Exponential.AsymptoticExponentialA('SSQABS', 'Exponential Decay')\n self.assertEqual(equation.extendedVersionHandler.__class__.__name__, 'ExtendedVersionHandler_ExponentialDecay')\n self.assertEqual(equation.GetDisplayHTML(), 'y = 1.0 - a<sup>x</sup><br>y = y / (b * exp(x))')\n self.assertEqual(equation.GetDisplayName(), 'Asymptotic Exponential A With Exponential Decay')\n self.assertEqual(equation.GetCoefficientDesignators(), ['a', 'b'])\n self.assertEqual(len(equation.GetDataCacheFunctions()), 2)\n self.assertFalse(equation.CanLinearSolverBeUsedForSSQABS())\n\n pyeq2.dataConvertorService().ConvertAndSortColumnarASCII(DataForUnitTests.asciiDataInColumns_2D, equation, False)\n \n equation.Solve()\n fittingTarget = equation.CalculateAllDataFittingTarget(equation.solvedCoefficients)\n self.assertTrue(fittingTarget <= 1.9)", "metadata": "root.TestExtendedVersionHandlers.test_ExtendedVersion_Asymptotic_Exponential_A_WithExponentialDecay_2D", "header": "['class', 'TestExtendedVersionHandlers', '(', 'unittest', '.', 'TestCase', ')', ':', '___EOS___']", "index": 197 }, { "content": " def test_ExtendedVersion_Asymptotic_Exponential_A_WithExponentialDecayAndOffset_2D(self):\n equation = pyeq2.Models_2D.Exponential.AsymptoticExponentialA('SSQABS', 'Exponential Decay And Offset')\n self.assertEqual(equation.extendedVersionHandler.__class__.__name__, 'ExtendedVersionHandler_ExponentialDecayAndOffset')\n self.assertEqual(equation.GetDisplayHTML(), 'y = 1.0 - a<sup>x</sup><br>y = y / (b * exp(x)) + Offset')\n self.assertEqual(equation.GetDisplayName(), 'Asymptotic Exponential A With Exponential Decay And Offset')\n self.assertEqual(equation.GetCoefficientDesignators(), ['a', 'b', 'Offset'])\n self.assertEqual(len(equation.GetDataCacheFunctions()), 2)\n self.assertFalse(equation.CanLinearSolverBeUsedForSSQABS())\n\n pyeq2.dataConvertorService().ConvertAndSortColumnarASCII(DataForUnitTests.asciiDataInColumns_2D, equation, False)\n \n equation.Solve()\n fittingTarget = equation.CalculateAllDataFittingTarget(equation.solvedCoefficients)\n self.assertTrue(fittingTarget <= 0.017)", "metadata": "root.TestExtendedVersionHandlers.test_ExtendedVersion_Asymptotic_Exponential_A_WithExponentialDecayAndOffset_2D", "header": "['class', 'TestExtendedVersionHandlers', '(', 'unittest', '.', 'TestCase', ')', ':', '___EOS___']", "index": 213 } ]
[ { "span": "self.assertTrue(fittingTarget <= 0.018)", "start_line": 34, "start_column": 8, "end_line": 34, "end_column": 47 }, { "span": "self.assertTrue(fittingTarget <= 1.9)", "start_line": 50, "start_column": 8, "end_line": 50, "end_column": 45 }, { "span": "self.assertTrue(fittingTarget <= 0.018)", "start_line": 66, "start_column": 8, "end_line": 66, "end_column": 47 }, { "span": "self.assertTrue(fittingTarget <= 1.6)", "start_line": 82, "start_column": 8, "end_line": 82, "end_column": 45 }, { "span": "self.assertTrue(fittingTarget <= 0.018)", "start_line": 98, "start_column": 8, "end_line": 98, "end_column": 47 }, { "span": "self.assertTrue(fittingTarget <= 2.2)", "start_line": 114, "start_column": 8, "end_line": 114, "end_column": 45 }, { "span": "self.assertTrue(fittingTarget <= 0.49)", "start_line": 130, "start_column": 8, "end_line": 130, "end_column": 46 }, { "span": "self.assertTrue(fittingTarget <= 1.6)", "start_line": 146, "start_column": 8, "end_line": 146, "end_column": 45 }, { "span": "self.assertTrue(fittingTarget <= 0.018)", "start_line": 162, "start_column": 8, "end_line": 162, "end_column": 47 }, { "span": "self.assertTrue(fittingTarget <= 21.0)", "start_line": 178, "start_column": 8, "end_line": 178, "end_column": 46 }, { "span": "self.assertTrue(fittingTarget <= 7.0)", "start_line": 194, "start_column": 8, "end_line": 194, "end_column": 45 }, { "span": "self.assertTrue(fittingTarget <= 1.9)", "start_line": 210, "start_column": 8, "end_line": 210, "end_column": 45 }, { "span": "self.assertTrue(fittingTarget <= 0.017)", "start_line": 226, "start_column": 8, "end_line": 226, "end_column": 47 } ]
[]
1
true
[ "[CLS]_", "Imp", "reci", "se_", "assert_", "[SEP]_", "class_", "Test", "Extend", "ed", "Version", "Handlers_", "(_", "unittest_", "._", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "def_", "test\\u", "Extend", "ed", "Version", "\\u", "Expo", "nent", "ial", "\\u", "With", "Off", "set\\u", "2", "D_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "equation_", "=_", "pye", "q2_", "._", "Model", "s", "\\u", "2", "D_", "._", "Expo", "nent", "ial_", "._", "Expo", "nent", "ial_", "(_", "'", "SS", "QA", "BS", "'_", ",_", "'", "Off", "set", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "equation_", "._", "extend", "ed", "Version", "Handler_", "._", "\\u\\u", "class\\u\\u_", "._", "\\u\\u", "name\\u\\u_", ",_", "'", "Extend", "ed", "Version", "Handle", "r", "\\u", "Off", "set", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "equation_", "._", "Get", "Display", "HTML_", "(_", ")_", ",_", "'", "y", " ", "=", " ", "a", " ", "*", " ", "exp", "(", "bx", ")", " ", "+", " ", "Off", "set", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "equation_", "._", "Get", "Display", "Name_", "(_", ")_", ",_", "'", "Expo", "nent", "ial", " ", "With", " ", "Off", "set", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "equation_", "._", "Get", "Coeff", "icient", "Designat", "ors_", "(_", ")_", ",_", "[_", "'", "a", "'_", ",_", "'", "b", "'_", ",_", "'", "Off", "set", "'_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "len_", "(_", "equation_", "._", "Get", "Data", "Cache", "Functions_", "(_", ")_", ")_", ",_", "1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "False_", "(_", "equation_", "._", "Can", "Linea", "r", "Solve", "r", "Be", "Us", "ed", "For", "SS", "QA", "BS", "_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "pye", "q2_", "._", "data", "Convert", "or", "Service_", "(_", ")_", "._", "Convert", "And", "Sort", "Colum", "nar", "ASCII", "_", "(_", "Data", "For", "Unit", "Tests_", "._", "ascii", "Data", "In", "Colum", "ns", "\\u", "2", "D_", ",_", "equation_", ",_", "False_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "equation_", "._", "Solve", "_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "fitting", "Target_", "=_", "equation_", "._", "Calculat", "e", "All", "Data", "Fitt", "ing", "Target_", "(_", "equation_", "._", "solved", "Coeff", "icient", "s_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "fitting", "Target_", "<=_", "0.018", "_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Test", "Extend", "ed", "Version", "Handlers_", "(_", "unittest_", "._", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "Extend", "ed", "Version", "\\u", "Recip", "roc", "al", "\\u", "Expo", "nent", "ial", "\\u", "2", "D_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "equation_", "=_", "pye", "q2_", "._", "Model", "s", "\\u", "2", "D_", "._", "Expo", "nent", "ial_", "._", "Expo", "nent", "ial_", "(_", "'", "SS", "QA", "BS", "'_", ",_", "'", "Recip", "roc", "al", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "equation_", "._", "extend", "ed", "Version", "Handler_", "._", "\\u\\u", "class\\u\\u_", "._", "\\u\\u", "name\\u\\u_", ",_", "'", "Extend", "ed", "Version", "Handle", "r", "\\u", "Recip", "roc", "al", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "equation_", "._", "Get", "Display", "HTML_", "(_", ")_", ",_", "'", "y", " ", "=", " ", "a", " ", "*", " ", "exp", "(", "bx", ")<", "br", ">", "y", " ", "=", " ", "1.0", " ", "/", " ", "y", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "equation_", "._", "Get", "Display", "Name_", "(_", ")_", ",_", "'", "Recip", "roc", "al", " ", "Expo", "nent", "ial", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "equation_", "._", "Get", "Coeff", "icient", "Designat", "ors_", "(_", ")_", ",_", "[_", "'", "a", "'_", ",_", "'", "b", "'_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "len_", "(_", "equation_", "._", "Get", "Data", "Cache", "Functions_", "(_", ")_", ")_", ",_", "1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "False_", "(_", "equation_", "._", "Can", "Linea", "r", "Solve", "r", "Be", "Us", "ed", "For", "SS", "QA", "BS", "_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "pye", "q2_", "._", "data", "Convert", "or", "Service_", "(_", ")_", "._", "Convert", "And", "Sort", "Colum", "nar", "ASCII", "_", "(_", "Data", "For", "Unit", "Tests_", "._", "ascii", "Data", "In", "Colum", "ns", "\\u", "2", "D_", ",_", "equation_", ",_", "False_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "equation_", "._", "Solve", "_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "fitting", "Target_", "=_", "equation_", "._", "Calculat", "e", "All", "Data", "Fitt", "ing", "Target_", "(_", "equation_", "._", "solved", "Coeff", "icient", "s_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "fitting", "Target_", "<=_", "1.9", "_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Test", "Extend", "ed", "Version", "Handlers_", "(_", "unittest_", "._", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "Extend", "ed", "Version", "\\u", "Recip", "roc", "al", "\\u", "Expo", "nent", "ial", "\\u", "With", "Off", "set\\u", "2", "D_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "equation_", "=_", "pye", "q2_", "._", "Model", "s", "\\u", "2", "D_", "._", "Expo", "nent", "ial_", "._", "Expo", "nent", "ial_", "(_", "'", "SS", "QA", "BS", "'_", ",_", "'", "Recip", "roc", "al", " ", "With", " ", "Off", "set", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "equation_", "._", "extend", "ed", "Version", "Handler_", "._", "\\u\\u", "class\\u\\u_", "._", "\\u\\u", "name\\u\\u_", ",_", "'", "Extend", "ed", "Version", "Handle", "r", "\\u", "Recip", "roc", "al", "With", "Off", "set", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "equation_", "._", "Get", "Display", "HTML_", "(_", ")_", ",_", "'", "y", " ", "=", " ", "a", " ", "*", " ", "exp", "(", "bx", ")<", "br", ">", "y", " ", "=", " ", "1.0", " ", "/", " ", "y", " ", "+", " ", "Off", "set", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "equation_", "._", "Get", "Display", "Name_", "(_", ")_", ",_", "'", "Recip", "roc", "al", " ", "Expo", "nent", "ial", " ", "With", " ", "Off", "set", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "equation_", "._", "Get", "Coeff", "icient", "Designat", "ors_", "(_", ")_", ",_", "[_", "'", "a", "'_", ",_", "'", "b", "'_", ",_", "'", "Off", "set", "'_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "len_", "(_", "equation_", "._", "Get", "Data", "Cache", "Functions_", "(_", ")_", ")_", ",_", "1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "False_", "(_", "equation_", "._", "Can", "Linea", "r", "Solve", "r", "Be", "Us", "ed", "For", "SS", "QA", "BS", "_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "pye", "q2_", "._", "data", "Convert", "or", "Service_", "(_", ")_", "._", "Convert", "And", "Sort", "Colum", "nar", "ASCII", "_", "(_", "Data", "For", "Unit", "Tests_", "._", "ascii", "Data", "In", "Colum", "ns", "\\u", "2", "D_", ",_", "equation_", ",_", "False_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "equation_", "._", "Solve", "_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "fitting", "Target_", "=_", "equation_", "._", "Calculat", "e", "All", "Data", "Fitt", "ing", "Target_", "(_", "equation_", "._", "solved", "Coeff", "icient", "s_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "fitting", "Target_", "<=_", "0.018", "_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Test", "Extend", "ed", "Version", "Handlers_", "(_", "unittest_", "._", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "Extend", "ed", "Version", "\\u", "Inv", "erse", "\\u", "Expo", "nent", "ial", "\\u", "2", "D_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "equation_", "=_", "pye", "q2_", "._", "Model", "s", "\\u", "2", "D_", "._", "Expo", "nent", "ial_", "._", "Expo", "nent", "ial_", "(_", "'", "SS", "QA", "BS", "'_", ",_", "'", "Inv", "erse", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "equation_", "._", "extend", "ed", "Version", "Handler_", "._", "\\u\\u", "class\\u\\u_", "._", "\\u\\u", "name\\u\\u_", ",_", "'", "Extend", "ed", "Version", "Handle", "r", "\\u", "Inv", "erse", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "equation_", "._", "Get", "Display", "HTML_", "(_", ")_", ",_", "'", "y", " ", "=", " ", "a", " ", "*", " ", "exp", "(", "bx", ")<", "br", ">", "y", " ", "=", " ", "x", " ", "/", " ", "y", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "equation_", "._", "Get", "Display", "Name_", "(_", ")_", ",_", "'", "Inv", "erse", " ", "Expo", "nent", "ial", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "equation_", "._", "Get", "Coeff", "icient", "Designat", "ors_", "(_", ")_", ",_", "[_", "'", "a", "'_", ",_", "'", "b", "'_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "len_", "(_", "equation_", "._", "Get", "Data", "Cache", "Functions_", "(_", ")_", ")_", ",_", "1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "False_", "(_", "equation_", "._", "Can", "Linea", "r", "Solve", "r", "Be", "Us", "ed", "For", "SS", "QA", "BS", "_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "pye", "q2_", "._", "data", "Convert", "or", "Service_", "(_", ")_", "._", "Convert", "And", "Sort", "Colum", "nar", "ASCII", "_", "(_", "Data", "For", "Unit", "Tests_", "._", "ascii", "Data", "In", "Colum", "ns", "\\u", "2", "D_", ",_", "equation_", ",_", "False_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "equation_", "._", "Solve", "_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "fitting", "Target_", "=_", "equation_", "._", "Calculat", "e", "All", "Data", "Fitt", "ing", "Target_", "(_", "equation_", "._", "solved", "Coeff", "icient", "s_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "fitting", "Target_", "<=_", "1.6_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Test", "Extend", "ed", "Version", "Handlers_", "(_", "unittest_", "._", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "Extend", "ed", "Version", "\\u", "Inv", "erse", "\\u", "Expo", "nent", "ial", "\\u", "With", "Off", "set\\u", "2", "D_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "equation_", "=_", "pye", "q2_", "._", "Model", "s", "\\u", "2", "D_", "._", "Expo", "nent", "ial_", "._", "Expo", "nent", "ial_", "(_", "'", "SS", "QA", "BS", "'_", ",_", "'", "Inv", "erse", " ", "With", " ", "Off", "set", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "equation_", "._", "extend", "ed", "Version", "Handler_", "._", "\\u\\u", "class\\u\\u_", "._", "\\u\\u", "name\\u\\u_", ",_", "'", "Extend", "ed", "Version", "Handle", "r", "\\u", "Inv", "erse", "With", "Off", "set", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "equation_", "._", "Get", "Display", "HTML_", "(_", ")_", ",_", "'", "y", " ", "=", " ", "a", " ", "*", " ", "exp", "(", "bx", ")<", "br", ">", "y", " ", "=", " ", "x", " ", "/", " ", "y", " ", "+", " ", "Off", "set", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "equation_", "._", "Get", "Display", "Name_", "(_", ")_", ",_", "'", "Inv", "erse", " ", "Expo", "nent", "ial", " ", "With", " ", "Off", "set", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "equation_", "._", "Get", "Coeff", "icient", "Designat", "ors_", "(_", ")_", ",_", "[_", "'", "a", "'_", ",_", "'", "b", "'_", ",_", "'", "Off", "set", "'_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "len_", "(_", "equation_", "._", "Get", "Data", "Cache", "Functions_", "(_", ")_", ")_", ",_", "1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "False_", "(_", "equation_", "._", "Can", "Linea", "r", "Solve", "r", "Be", "Us", "ed", "For", "SS", "QA", "BS", "_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "pye", "q2_", "._", "data", "Convert", "or", "Service_", "(_", ")_", "._", "Convert", "And", "Sort", "Colum", "nar", "ASCII", "_", "(_", "Data", "For", "Unit", "Tests_", "._", "ascii", "Data", "In", "Colum", "ns", "\\u", "2", "D_", ",_", "equation_", ",_", "False_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "equation_", "._", "Solve", "_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "fitting", "Target_", "=_", "equation_", "._", "Calculat", "e", "All", "Data", "Fitt", "ing", "Target_", "(_", "equation_", "._", "solved", "Coeff", "icient", "s_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "fitting", "Target_", "<=_", "0.018", "_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Test", "Extend", "ed", "Version", "Handlers_", "(_", "unittest_", "._", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "Extend", "ed", "Version", "\\u", "Expo", "nent", "ial", "\\u", "With", "Linea", "r", "Decay", "\\u", "2", "D_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "equation_", "=_", "pye", "q2_", "._", "Model", "s", "\\u", "2", "D_", "._", "Expo", "nent", "ial_", "._", "Expo", "nent", "ial_", "(_", "'", "SS", "QA", "BS", "'_", ",_", "'", "Linea", "r", " ", "Decay", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "equation_", "._", "extend", "ed", "Version", "Handler_", "._", "\\u\\u", "class\\u\\u_", "._", "\\u\\u", "name\\u\\u_", ",_", "'", "Extend", "ed", "Version", "Handle", "r", "\\u", "Linea", "r", "Decay", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "equation_", "._", "Get", "Display", "HTML_", "(_", ")_", ",_", "'", "y", " ", "=", " ", "a", " ", "*", " ", "exp", "(", "bx", ")<", "br", ">", "y", " ", "=", " ", "y", " ", "/", " ", "x", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "equation_", "._", "Get", "Display", "Name_", "(_", ")_", ",_", "'", "Expo", "nent", "ial", " ", "With", " ", "Linea", "r", " ", "Decay", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "equation_", "._", "Get", "Coeff", "icient", "Designat", "ors_", "(_", ")_", ",_", "[_", "'", "a", "'_", ",_", "'", "b", "'_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "len_", "(_", "equation_", "._", "Get", "Data", "Cache", "Functions_", "(_", ")_", ")_", ",_", "1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "False_", "(_", "equation_", "._", "Can", "Linea", "r", "Solve", "r", "Be", "Us", "ed", "For", "SS", "QA", "BS", "_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "pye", "q2_", "._", "data", "Convert", "or", "Service_", "(_", ")_", "._", "Convert", "And", "Sort", "Colum", "nar", "ASCII", "_", "(_", "Data", "For", "Unit", "Tests_", "._", "ascii", "Data", "In", "Colum", "ns", "\\u", "2", "D_", ",_", "equation_", ",_", "False_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "equation_", "._", "Solve", "_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "fitting", "Target_", "=_", "equation_", "._", "Calculat", "e", "All", "Data", "Fitt", "ing", "Target_", "(_", "equation_", "._", "solved", "Coeff", "icient", "s_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "fitting", "Target_", "<=_", "2.2_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Test", "Extend", "ed", "Version", "Handlers_", "(_", "unittest_", "._", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "Extend", "ed", "Version", "\\u", "Expo", "nent", "ial", "\\u", "With", "Linea", "r", "Decay", "And", "Off", "set\\u", "2", "D_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "equation_", "=_", "pye", "q2_", "._", "Model", "s", "\\u", "2", "D_", "._", "Expo", "nent", "ial_", "._", "Expo", "nent", "ial_", "(_", "'", "SS", "QA", "BS", "'_", ",_", "'", "Linea", "r", " ", "Decay", " ", "And", " ", "Off", "set", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "equation_", "._", "extend", "ed", "Version", "Handler_", "._", "\\u\\u", "class\\u\\u_", "._", "\\u\\u", "name\\u\\u_", ",_", "'", "Extend", "ed", "Version", "Handle", "r", "\\u", "Linea", "r", "Decay", "And", "Off", "set", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "equation_", "._", "Get", "Display", "HTML_", "(_", ")_", ",_", "'", "y", " ", "=", " ", "a", " ", "*", " ", "exp", "(", "bx", ")<", "br", ">", "y", " ", "=", " ", "y", " ", "/", " ", "x", " ", "+", " ", "Off", "set", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "equation_", "._", "Get", "Display", "Name_", "(_", ")_", ",_", "'", "Expo", "nent", "ial", " ", "With", " ", "Linea", "r", " ", "Decay", " ", "And", " ", "Off", "set", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "equation_", "._", "Get", "Coeff", "icient", "Designat", "ors_", "(_", ")_", ",_", "[_", "'", "a", "'_", ",_", "'", "b", "'_", ",_", "'", "Off", "set", "'_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "len_", "(_", "equation_", "._", "Get", "Data", "Cache", "Functions_", "(_", ")_", ")_", ",_", "1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "False_", "(_", "equation_", "._", "Can", "Linea", "r", "Solve", "r", "Be", "Us", "ed", "For", "SS", "QA", "BS", "_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "pye", "q2_", "._", "data", "Convert", "or", "Service_", "(_", ")_", "._", "Convert", "And", "Sort", "Colum", "nar", "ASCII", "_", "(_", "Data", "For", "Unit", "Tests_", "._", "ascii", "Data", "In", "Colum", "ns", "\\u", "2", "D_", ",_", "equation_", ",_", "False_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "equation_", "._", "Solve", "_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "fitting", "Target_", "=_", "equation_", "._", "Calculat", "e", "All", "Data", "Fitt", "ing", "Target_", "(_", "equation_", "._", "solved", "Coeff", "icient", "s_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "fitting", "Target_", "<=_", "0.49", "_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Test", "Extend", "ed", "Version", "Handlers_", "(_", "unittest_", "._", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "Extend", "ed", "Version", "\\u", "Expo", "nent", "ial", "\\u", "With", "Linea", "r", "Grow", "th", "\\u", "2", "D_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "equation_", "=_", "pye", "q2_", "._", "Model", "s", "\\u", "2", "D_", "._", "Expo", "nent", "ial_", "._", "Expo", "nent", "ial_", "(_", "'", "SS", "QA", "BS", "'_", ",_", "'", "Linea", "r", " ", "Grow", "th", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "equation_", "._", "extend", "ed", "Version", "Handler_", "._", "\\u\\u", "class\\u\\u_", "._", "\\u\\u", "name\\u\\u_", ",_", "'", "Extend", "ed", "Version", "Handle", "r", "\\u", "Linea", "r", "Grow", "th", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "equation_", "._", "Get", "Display", "HTML_", "(_", ")_", ",_", "'", "y", " ", "=", " ", "a", " ", "*", " ", "exp", "(", "bx", ")<", "br", ">", "y", " ", "=", " ", "y", " ", "*", " ", "x", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "equation_", "._", "Get", "Display", "Name_", "(_", ")_", ",_", "'", "Expo", "nent", "ial", " ", "With", " ", "Linea", "r", " ", "Grow", "th", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "equation_", "._", "Get", "Coeff", "icient", "Designat", "ors_", "(_", ")_", ",_", "[_", "'", "a", "'_", ",_", "'", "b", "'_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "len_", "(_", "equation_", "._", "Get", "Data", "Cache", "Functions_", "(_", ")_", ")_", ",_", "1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "False_", "(_", "equation_", "._", "Can", "Linea", "r", "Solve", "r", "Be", "Us", "ed", "For", "SS", "QA", "BS", "_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "pye", "q2_", "._", "data", "Convert", "or", "Service_", "(_", ")_", "._", "Convert", "And", "Sort", "Colum", "nar", "ASCII", "_", "(_", "Data", "For", "Unit", "Tests_", "._", "ascii", "Data", "In", "Colum", "ns", "\\u", "2", "D_", ",_", "equation_", ",_", "False_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "equation_", "._", "Solve", "_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "fitting", "Target_", "=_", "equation_", "._", "Calculat", "e", "All", "Data", "Fitt", "ing", "Target_", "(_", "equation_", "._", "solved", "Coeff", "icient", "s_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "fitting", "Target_", "<=_", "1.6_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Test", "Extend", "ed", "Version", "Handlers_", "(_", "unittest_", "._", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "Extend", "ed", "Version", "\\u", "Expo", "nent", "ial", "\\u", "With", "Linea", "r", "Grow", "th", "And", "Off", "set\\u", "2", "D_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "equation_", "=_", "pye", "q2_", "._", "Model", "s", "\\u", "2", "D_", "._", "Expo", "nent", "ial_", "._", "Expo", "nent", "ial_", "(_", "'", "SS", "QA", "BS", "'_", ",_", "'", "Linea", "r", " ", "Grow", "th", " ", "And", " ", "Off", "set", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "equation_", "._", "extend", "ed", "Version", "Handler_", "._", "\\u\\u", "class\\u\\u_", "._", "\\u\\u", "name\\u\\u_", ",_", "'", "Extend", "ed", "Version", "Handle", "r", "\\u", "Linea", "r", "Grow", "th", "And", "Off", "set", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "equation_", "._", "Get", "Display", "HTML_", "(_", ")_", ",_", "'", "y", " ", "=", " ", "a", " ", "*", " ", "exp", "(", "bx", ")<", "br", ">", "y", " ", "=", " ", "y", " ", "*", " ", "x", " ", "+", " ", "Off", "set", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "equation_", "._", "Get", "Display", "Name_", "(_", ")_", ",_", "'", "Expo", "nent", "ial", " ", "With", " ", "Linea", "r", " ", "Grow", "th", " ", "And", " ", "Off", "set", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "equation_", "._", "Get", "Coeff", "icient", "Designat", "ors_", "(_", ")_", ",_", "[_", "'", "a", "'_", ",_", "'", "b", "'_", ",_", "'", "Off", "set", "'_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "len_", "(_", "equation_", "._", "Get", "Data", "Cache", "Functions_", "(_", ")_", ")_", ",_", "1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "False_", "(_", "equation_", "._", "Can", "Linea", "r", "Solve", "r", "Be", "Us", "ed", "For", "SS", "QA", "BS", "_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "pye", "q2_", "._", "data", "Convert", "or", "Service_", "(_", ")_", "._", "Convert", "And", "Sort", "Colum", "nar", "ASCII", "_", "(_", "Data", "For", "Unit", "Tests_", "._", "ascii", "Data", "In", "Colum", "ns", "\\u", "2", "D_", ",_", "equation_", ",_", "False_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "equation_", "._", "Solve", "_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "fitting", "Target_", "=_", "equation_", "._", "Calculat", "e", "All", "Data", "Fitt", "ing", "Target_", "(_", "equation_", "._", "solved", "Coeff", "icient", "s_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "fitting", "Target_", "<=_", "0.018", "_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Test", "Extend", "ed", "Version", "Handlers_", "(_", "unittest_", "._", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "Extend", "ed", "Version", "\\u", "As", "ym", "pto", "tic", "\\u", "Expo", "nent", "ial", "\\u", "A", "\\u", "With", "Expo", "nent", "ial", "Grow", "th", "\\u", "2", "D_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "equation_", "=_", "pye", "q2_", "._", "Model", "s", "\\u", "2", "D_", "._", "Expo", "nent", "ial_", "._", "As", "ym", "pto", "tic", "Expo", "nent", "ial", "A_", "(_", "'", "SS", "QA", "BS", "'_", ",_", "'", "Expo", "nent", "ial", " ", "Grow", "th", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "equation_", "._", "extend", "ed", "Version", "Handler_", "._", "\\u\\u", "class\\u\\u_", "._", "\\u\\u", "name\\u\\u_", ",_", "'", "Extend", "ed", "Version", "Handle", "r", "\\u", "Expo", "nent", "ial", "Grow", "th", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "equation_", "._", "Get", "Display", "HTML_", "(_", ")_", ",_", "'", "y", " ", "=", " ", "1.0", " ", "-", " ", "a", "<", "sup", ">", "x", "</", "sup", "><", "br", ">", "y", " ", "=", " ", "y", " ", "*", " ", "(", "b", " ", "*", " ", "exp", "(", "x", "))'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "equation_", "._", "Get", "Display", "Name_", "(_", ")_", ",_", "'", "As", "ym", "pto", "tic", " ", "Expo", "nent", "ial", " ", "A", " ", "With", " ", "Expo", "nent", "ial", " ", "Grow", "th", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "equation_", "._", "Get", "Coeff", "icient", "Designat", "ors_", "(_", ")_", ",_", "[_", "'", "a", "'_", ",_", "'", "b", "'_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "len_", "(_", "equation_", "._", "Get", "Data", "Cache", "Functions_", "(_", ")_", ")_", ",_", "2_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "False_", "(_", "equation_", "._", "Can", "Linea", "r", "Solve", "r", "Be", "Us", "ed", "For", "SS", "QA", "BS", "_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "pye", "q2_", "._", "data", "Convert", "or", "Service_", "(_", ")_", "._", "Convert", "And", "Sort", "Colum", "nar", "ASCII", "_", "(_", "Data", "For", "Unit", "Tests_", "._", "ascii", "Data", "In", "Colum", "ns", "\\u", "2", "D_", ",_", "equation_", ",_", "False_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "equation_", "._", "Solve", "_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "fitting", "Target_", "=_", "equation_", "._", "Calculat", "e", "All", "Data", "Fitt", "ing", "Target_", "(_", "equation_", "._", "solved", "Coeff", "icient", "s_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "fitting", "Target_", "<=_", "21.", "0_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Test", "Extend", "ed", "Version", "Handlers_", "(_", "unittest_", "._", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "Extend", "ed", "Version", "\\u", "As", "ym", "pto", "tic", "\\u", "Expo", "nent", "ial", "\\u", "A", "\\u", "With", "Expo", "nent", "ial", "Grow", "th", "And", "Off", "set\\u", "2", "D_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "equation_", "=_", "pye", "q2_", "._", "Model", "s", "\\u", "2", "D_", "._", "Expo", "nent", "ial_", "._", "As", "ym", "pto", "tic", "Expo", "nent", "ial", "A_", "(_", "'", "SS", "QA", "BS", "'_", ",_", "'", "Expo", "nent", "ial", " ", "Grow", "th", " ", "And", " ", "Off", "set", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "equation_", "._", "extend", "ed", "Version", "Handler_", "._", "\\u\\u", "class\\u\\u_", "._", "\\u\\u", "name\\u\\u_", ",_", "'", "Extend", "ed", "Version", "Handle", "r", "\\u", "Expo", "nent", "ial", "Grow", "th", "And", "Off", "set", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "equation_", "._", "Get", "Display", "HTML_", "(_", ")_", ",_", "'", "y", " ", "=", " ", "1.0", " ", "-", " ", "a", "<", "sup", ">", "x", "</", "sup", "><", "br", ">", "y", " ", "=", " ", "y", " ", "*", " ", "(", "b", " ", "*", " ", "exp", "(", "x", "))", " ", "+", " ", "Off", "set", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "equation_", "._", "Get", "Display", "Name_", "(_", ")_", ",_", "'", "As", "ym", "pto", "tic", " ", "Expo", "nent", "ial", " ", "A", " ", "With", " ", "Expo", "nent", "ial", " ", "Grow", "th", " ", "And", " ", "Off", "set", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "equation_", "._", "Get", "Coeff", "icient", "Designat", "ors_", "(_", ")_", ",_", "[_", "'", "a", "'_", ",_", "'", "b", "'_", ",_", "'", "Off", "set", "'_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "len_", "(_", "equation_", "._", "Get", "Data", "Cache", "Functions_", "(_", ")_", ")_", ",_", "2_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "False_", "(_", "equation_", "._", "Can", "Linea", "r", "Solve", "r", "Be", "Us", "ed", "For", "SS", "QA", "BS", "_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "pye", "q2_", "._", "data", "Convert", "or", "Service_", "(_", ")_", "._", "Convert", "And", "Sort", "Colum", "nar", "ASCII", "_", "(_", "Data", "For", "Unit", "Tests_", "._", "ascii", "Data", "In", "Colum", "ns", "\\u", "2", "D_", ",_", "equation_", ",_", "False_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "equation_", "._", "Solve", "_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "fitting", "Target_", "=_", "equation_", "._", "Calculat", "e", "All", "Data", "Fitt", "ing", "Target_", "(_", "equation_", "._", "solved", "Coeff", "icient", "s_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "fitting", "Target_", "<=_", "7.0_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Test", "Extend", "ed", "Version", "Handlers_", "(_", "unittest_", "._", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "Extend", "ed", "Version", "\\u", "As", "ym", "pto", "tic", "\\u", "Expo", "nent", "ial", "\\u", "A", "\\u", "With", "Expo", "nent", "ial", "Decay", "\\u", "2", "D_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "equation_", "=_", "pye", "q2_", "._", "Model", "s", "\\u", "2", "D_", "._", "Expo", "nent", "ial_", "._", "As", "ym", "pto", "tic", "Expo", "nent", "ial", "A_", "(_", "'", "SS", "QA", "BS", "'_", ",_", "'", "Expo", "nent", "ial", " ", "Decay", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "equation_", "._", "extend", "ed", "Version", "Handler_", "._", "\\u\\u", "class\\u\\u_", "._", "\\u\\u", "name\\u\\u_", ",_", "'", "Extend", "ed", "Version", "Handle", "r", "\\u", "Expo", "nent", "ial", "Decay", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "equation_", "._", "Get", "Display", "HTML_", "(_", ")_", ",_", "'", "y", " ", "=", " ", "1.0", " ", "-", " ", "a", "<", "sup", ">", "x", "</", "sup", "><", "br", ">", "y", " ", "=", " ", "y", " ", "/", " ", "(", "b", " ", "*", " ", "exp", "(", "x", "))'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "equation_", "._", "Get", "Display", "Name_", "(_", ")_", ",_", "'", "As", "ym", "pto", "tic", " ", "Expo", "nent", "ial", " ", "A", " ", "With", " ", "Expo", "nent", "ial", " ", "Decay", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "equation_", "._", "Get", "Coeff", "icient", "Designat", "ors_", "(_", ")_", ",_", "[_", "'", "a", "'_", ",_", "'", "b", "'_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "len_", "(_", "equation_", "._", "Get", "Data", "Cache", "Functions_", "(_", ")_", ")_", ",_", "2_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "False_", "(_", "equation_", "._", "Can", "Linea", "r", "Solve", "r", "Be", "Us", "ed", "For", "SS", "QA", "BS", "_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "pye", "q2_", "._", "data", "Convert", "or", "Service_", "(_", ")_", "._", "Convert", "And", "Sort", "Colum", "nar", "ASCII", "_", "(_", "Data", "For", "Unit", "Tests_", "._", "ascii", "Data", "In", "Colum", "ns", "\\u", "2", "D_", ",_", "equation_", ",_", "False_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "equation_", "._", "Solve", "_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "fitting", "Target_", "=_", "equation_", "._", "Calculat", "e", "All", "Data", "Fitt", "ing", "Target_", "(_", "equation_", "._", "solved", "Coeff", "icient", "s_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "fitting", "Target_", "<=_", "1.9", "_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Test", "Extend", "ed", "Version", "Handlers_", "(_", "unittest_", "._", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "Extend", "ed", "Version", "\\u", "As", "ym", "pto", "tic", "\\u", "Expo", "nent", "ial", "\\u", "A", "\\u", "With", "Expo", "nent", "ial", "Decay", "And", "Off", "set\\u", "2", "D_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "equation_", "=_", "pye", "q2_", "._", "Model", "s", "\\u", "2", "D_", "._", "Expo", "nent", "ial_", "._", "As", "ym", "pto", "tic", "Expo", "nent", "ial", "A_", "(_", "'", "SS", "QA", "BS", "'_", ",_", "'", "Expo", "nent", "ial", " ", "Decay", " ", "And", " ", "Off", "set", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "equation_", "._", "extend", "ed", "Version", "Handler_", "._", "\\u\\u", "class\\u\\u_", "._", "\\u\\u", "name\\u\\u_", ",_", "'", "Extend", "ed", "Version", "Handle", "r", "\\u", "Expo", "nent", "ial", "Decay", "And", "Off", "set", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "equation_", "._", "Get", "Display", "HTML_", "(_", ")_", ",_", "'", "y", " ", "=", " ", "1.0", " ", "-", " ", "a", "<", "sup", ">", "x", "</", "sup", "><", "br", ">", "y", " ", "=", " ", "y", " ", "/", " ", "(", "b", " ", "*", " ", "exp", "(", "x", "))", " ", "+", " ", "Off", "set", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "equation_", "._", "Get", "Display", "Name_", "(_", ")_", ",_", "'", "As", "ym", "pto", "tic", " ", "Expo", "nent", "ial", " ", "A", " ", "With", " ", "Expo", "nent", "ial", " ", "Decay", " ", "And", " ", "Off", "set", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "equation_", "._", "Get", "Coeff", "icient", "Designat", "ors_", "(_", ")_", ",_", "[_", "'", "a", "'_", ",_", "'", "b", "'_", ",_", "'", "Off", "set", "'_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "len_", "(_", "equation_", "._", "Get", "Data", "Cache", "Functions_", "(_", ")_", ")_", ",_", "2_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "False_", "(_", "equation_", "._", "Can", "Linea", "r", "Solve", "r", "Be", "Us", "ed", "For", "SS", "QA", "BS", "_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "pye", "q2_", "._", "data", "Convert", "or", "Service_", "(_", ")_", "._", "Convert", "And", "Sort", "Colum", "nar", "ASCII", "_", "(_", "Data", "For", "Unit", "Tests_", "._", "ascii", "Data", "In", "Colum", "ns", "\\u", "2", "D_", ",_", "equation_", ",_", "False_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "equation_", "._", "Solve", "_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "fitting", "Target_", "=_", "equation_", "._", "Calculat", "e", "All", "Data", "Fitt", "ing", "Target_", "(_", "equation_", "._", "solved", "Coeff", "icient", "s_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "fitting", "Target_", "<=_", "0.01", "7_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_" ]
[ 4, 4, 4, 4, 4, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2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, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2 ]
Unused import
adieu/python-openid/examples/server.py
[ { "content": "#!/usr/bin/env python\n\n__copyright__ = 'Copyright 2005-2008, Janrain, Inc.'\n\nfrom BaseHTTPServer import HTTPServer, BaseHTTPRequestHandler\nfrom urlparse import urlparse\n\nimport time\nimport Cookie\nimport cgi\nimport cgitb\nimport sys\n\n\ntry:\n import openid\nexcept ImportError:\n sys.stderr.write(\"\"\"\nFailed to import the OpenID library. In order to use this example, you\nmust either install the library (see INSTALL in the root of the\ndistribution) or else add the library to python's import path (the\nPYTHONPATH environment variable).\n\nFor more information, see the README in the root of the library\ndistribution.\"\"\")\n sys.exit(1)\n\nfrom openid.extensions import sreg\nfrom openid.server import server\nfrom openid.store.filestore import FileOpenIDStore\nfrom openid.consumer import discover\n\n\n\n\n\n\nif __name__ == '__main__':\n host = 'localhost'\n data_path = 'sstore'\n port = 8000\n\n try:\n import optparse\n except ImportError:\n pass # Use defaults (for Python 2.2)\n else:\n parser = optparse.OptionParser('Usage:\\n %prog [options]')\n parser.add_option(\n '-d', '--data-path', dest='data_path', default=data_path,\n help='Data directory for storing OpenID consumer state. '\n 'Defaults to \"%default\" in the current directory.')\n parser.add_option(\n '-p', '--port', dest='port', type='int', default=port,\n help='Port on which to listen for HTTP requests. '\n 'Defaults to port %default.')\n parser.add_option(\n '-s', '--host', dest='host', default=host,\n help='Host on which to listen for HTTP requests. '\n 'Also used for generating URLs. Defaults to %default.')\n\n options, args = parser.parse_args()\n if args:\n parser.error('Expected no arguments. Got %r' % args)\n\n host = options.host\n port = options.port\n data_path = options.data_path\n\n main(host, port, data_path)\n", "metadata": "root", "header": "['module', '___EOS___']", "index": 0 }, { "content": "def quoteattr(s):\n qs = cgi.escape(s, 1)\n return '\"%s\"' % (qs,)", "metadata": "root.quoteattr", "header": "['module', '___EOS___']", "index": 13 }, { "content": "class OpenIDHTTPServer(HTTPServer):\n \"\"\"\n http server that contains a reference to an OpenID Server and\n knows its base URL.\n \"\"\"\n", "metadata": "root.OpenIDHTTPServer", "header": "['module', '___EOS___']", "index": 35 }, { "content": " def __init__(self, *args, **kwargs):\n HTTPServer.__init__(self, *args, **kwargs)\n\n if self.server_port != 80:\n self.base_url = ('http://%s:%s/' %\n (self.server_name, self.server_port))\n else:\n self.base_url = 'http://%s/' % (self.server_name,)\n\n self.openid = None\n self.approved = {}\n self.lastCheckIDRequest = {}", "metadata": "root.OpenIDHTTPServer.__init__", "header": "['class', 'OpenIDHTTPServer', '(', 'HTTPServer', ')', ':', '___EOS___']", "index": 40 }, { "content": " def setOpenIDServer(self, oidserver):\n self.openid = oidserver", "metadata": "root.OpenIDHTTPServer.setOpenIDServer", "header": "['class', 'OpenIDHTTPServer', '(', 'HTTPServer', ')', ':', '___EOS___']", "index": 53 }, { "content": "class ServerHandler(BaseHTTPRequestHandler):\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n", "metadata": "root.ServerHandler", "header": "['module', '___EOS___']", "index": 57 }, { "content": " def __init__(self, *args, **kwargs):\n self.user = None\n BaseHTTPRequestHandler.__init__(self, *args, **kwargs)", "metadata": "root.ServerHandler.__init__", "header": "['class', 'ServerHandler', '(', 'BaseHTTPRequestHandler', ')', ':', '___EOS___']", "index": 58 }, { "content": " def do_GET(self):\n try:\n self.parsed_uri = urlparse(self.path)\n self.query = {}\n for k, v in cgi.parse_qsl(self.parsed_uri[4]):\n self.query[k] = v\n\n self.setUser()\n\n path = self.parsed_uri[2].lower()\n\n if path == '/':\n self.showMainPage()\n elif path == '/openidserver':\n self.serverEndPoint(self.query)\n\n elif path == '/login':\n self.showLoginPage('/', '/')\n elif path == '/loginsubmit':\n self.doLogin()\n elif path.startswith('/id/'):\n self.showIdPage(path)\n elif path.startswith('/yadis/'):\n self.showYadis(path[7:])\n elif path == '/serveryadis':\n self.showServerYadis()\n else:\n self.send_response(404)\n self.end_headers()\n\n except (KeyboardInterrupt, SystemExit):\n raise\n except:\n self.send_response(500)\n self.send_header('Content-type', 'text/html')\n self.end_headers()\n self.wfile.write(cgitb.html(sys.exc_info(), context=10))", "metadata": "root.ServerHandler.do_GET", "header": "['class', 'ServerHandler', '(', 'BaseHTTPRequestHandler', ')', ':', '___EOS___']", "index": 63 }, { "content": " def do_POST(self):\n try:\n self.parsed_uri = urlparse(self.path)\n\n self.setUser()\n content_length = int(self.headers['Content-Length'])\n post_data = self.rfile.read(content_length)\n\n self.query = {}\n for k, v in cgi.parse_qsl(post_data):\n self.query[k] = v\n\n path = self.parsed_uri[2]\n if path == '/openidserver':\n self.serverEndPoint(self.query)\n\n elif path == '/allow':\n self.handleAllow(self.query)\n else:\n self.send_response(404)\n self.end_headers()\n\n except (KeyboardInterrupt, SystemExit):\n raise\n except:\n self.send_response(500)\n self.send_header('Content-type', 'text/html')\n self.end_headers()\n self.wfile.write(cgitb.html(sys.exc_info(), context=10))", "metadata": "root.ServerHandler.do_POST", "header": "['class', 'ServerHandler', '(', 'BaseHTTPRequestHandler', ')', ':', '___EOS___']", "index": 101 }, { "content": " def handleAllow(self, query):\n # pretend this next bit is keying off the user's session or something,\n # right?\n request = self.server.lastCheckIDRequest.get(self.user)\n\n if 'yes' in query:\n if 'login_as' in query:\n self.user = self.query['login_as']\n\n if request.idSelect():\n identity = self.server.base_url + 'id/' + query['identifier']\n else:\n identity = request.identity\n\n trust_root = request.trust_root\n if self.query.get('remember', 'no') == 'yes':\n self.server.approved[(identity, trust_root)] = 'always'\n\n response = self.approved(request, identity)\n\n elif 'no' in query:\n response = request.answer(False)\n\n else:\n assert False, 'strange allow post. %r' % (query,)\n\n self.displayResponse(response)", "metadata": "root.ServerHandler.handleAllow", "header": "['class', 'ServerHandler', '(', 'BaseHTTPRequestHandler', ')', ':', '___EOS___']", "index": 131 }, { "content": " def setUser(self):\n cookies = self.headers.get('Cookie')\n if cookies:\n morsel = Cookie.BaseCookie(cookies).get('user')\n if morsel:\n self.user = morsel.value", "metadata": "root.ServerHandler.setUser", "header": "['class', 'ServerHandler', '(', 'BaseHTTPRequestHandler', ')', ':', '___EOS___']", "index": 160 }, { "content": " def isAuthorized(self, identity_url, trust_root):\n if self.user is None:\n return False\n\n if identity_url != self.server.base_url + 'id/' + self.user:\n return False\n\n key = (identity_url, trust_root)\n return self.server.approved.get(key) is not None", "metadata": "root.ServerHandler.isAuthorized", "header": "['class', 'ServerHandler', '(', 'BaseHTTPRequestHandler', ')', ':', '___EOS___']", "index": 167 }, { "content": " def serverEndPoint(self, query):\n try:\n request = self.server.openid.decodeRequest(query)\n except server.ProtocolError, why:\n self.displayResponse(why)\n return\n\n if request is None:\n # Display text indicating that this is an endpoint.\n self.showAboutPage()\n return\n\n if request.mode in [\"checkid_immediate\", \"checkid_setup\"]:\n self.handleCheckIDRequest(request)\n else:\n response = self.server.openid.handleRequest(request)\n self.displayResponse(response)", "metadata": "root.ServerHandler.serverEndPoint", "header": "['class', 'ServerHandler', '(', 'BaseHTTPRequestHandler', ')', ':', '___EOS___']", "index": 177 }, { "content": " def addSRegResponse(self, request, response):\n sreg_req = sreg.SRegRequest.fromOpenIDRequest(request)\n\n # In a real application, this data would be user-specific,\n # and the user should be asked for permission to release\n # it.\n sreg_data = {\n 'nickname':self.user\n }\n\n sreg_resp = sreg.SRegResponse.extractResponse(sreg_req, sreg_data)\n response.addExtension(sreg_resp)", "metadata": "root.ServerHandler.addSRegResponse", "header": "['class', 'ServerHandler', '(', 'BaseHTTPRequestHandler', ')', ':', '___EOS___']", "index": 195 }, { "content": " def approved(self, request, identifier=None):\n response = request.answer(True, identity=identifier)\n self.addSRegResponse(request, response)\n return response", "metadata": "root.ServerHandler.approved", "header": "['class', 'ServerHandler', '(', 'BaseHTTPRequestHandler', ')', ':', '___EOS___']", "index": 208 }, { "content": " def handleCheckIDRequest(self, request):\n is_authorized = self.isAuthorized(request.identity, request.trust_root)\n if is_authorized:\n response = self.approved(request)\n self.displayResponse(response)\n elif request.immediate:\n response = request.answer(False)\n self.displayResponse(response)\n else:\n self.server.lastCheckIDRequest[self.user] = request\n self.showDecidePage(request)", "metadata": "root.ServerHandler.handleCheckIDRequest", "header": "['class', 'ServerHandler', '(', 'BaseHTTPRequestHandler', ')', ':', '___EOS___']", "index": 213 }, { "content": " def displayResponse(self, response):\n try:\n webresponse = self.server.openid.encodeResponse(response)\n except server.EncodingError, why:\n text = why.response.encodeToKVForm()\n self.showErrorPage('<pre>%s</pre>' % cgi.escape(text))\n return\n\n self.send_response(webresponse.code)\n for header, value in webresponse.headers.iteritems():\n self.send_header(header, value)\n self.writeUserHeader()\n self.end_headers()\n\n if webresponse.body:\n self.wfile.write(webresponse.body)", "metadata": "root.ServerHandler.displayResponse", "header": "['class', 'ServerHandler', '(', 'BaseHTTPRequestHandler', ')', ':', '___EOS___']", "index": 225 }, { "content": " def doLogin(self):\n if 'submit' in self.query:\n if 'user' in self.query:\n self.user = self.query['user']\n else:\n self.user = None\n self.redirect(self.query['success_to'])\n elif 'cancel' in self.query:\n self.redirect(self.query['fail_to'])\n else:\n assert 0, 'strange login %r' % (self.query,)", "metadata": "root.ServerHandler.doLogin", "header": "['class', 'ServerHandler', '(', 'BaseHTTPRequestHandler', ')', ':', '___EOS___']", "index": 242 }, { "content": " def redirect(self, url):\n self.send_response(302)\n self.send_header('Location', url)\n self.writeUserHeader()\n\n self.end_headers()", "metadata": "root.ServerHandler.redirect", "header": "['class', 'ServerHandler', '(', 'BaseHTTPRequestHandler', ')', ':', '___EOS___']", "index": 254 }, { "content": " def writeUserHeader(self):\n if self.user is None:\n t1970 = time.gmtime(0)\n expires = time.strftime(\n 'Expires=%a, %d-%b-%y %H:%M:%S GMT', t1970)\n self.send_header('Set-Cookie', 'user=;%s' % expires)\n else:\n self.send_header('Set-Cookie', 'user=%s' % self.user)", "metadata": "root.ServerHandler.writeUserHeader", "header": "['class', 'ServerHandler', '(', 'BaseHTTPRequestHandler', ')', ':', '___EOS___']", "index": 261 }, { "content": " def showAboutPage(self):\n endpoint_url = self.server.base_url + 'openidserver'\n\n def link(url):\n url_attr = quoteattr(url)\n url_text = cgi.escape(url)\n return '<a href=%s><code>%s</code></a>' % (url_attr, url_text)\n\n def term(url, text):\n return '<dt>%s</dt><dd>%s</dd>' % (link(url), text)\n\n resources = [\n (self.server.base_url, \"This example server's home page\"),\n ('http://www.openidenabled.com/',\n 'An OpenID community Web site, home of this library'),\n ('http://www.openid.net/', 'the official OpenID Web site'),\n ]\n\n resource_markup = ''.join([term(url, text) for url, text in resources])\n\n self.showPage(200, 'This is an OpenID server', msg=\"\"\"\\\n <p>%s is an OpenID server endpoint.<p>\n <p>For more information about OpenID, see:</p>\n <dl>\n %s\n </dl>\n \"\"\" % (link(endpoint_url), resource_markup,))", "metadata": "root.ServerHandler.showAboutPage", "header": "['class', 'ServerHandler', '(', 'BaseHTTPRequestHandler', ')', ':', '___EOS___']", "index": 270 }, { "content": " def showErrorPage(self, error_message):\n self.showPage(400, 'Error Processing Request', err='''\\\n <p>%s</p>\n <!--\n\n This is a large comment. It exists to make this page larger.\n That is unfortunately necessary because of the \"smart\"\n handling of pages returned with an error code in IE.\n\n *************************************************************\n *************************************************************\n *************************************************************\n *************************************************************\n *************************************************************\n *************************************************************\n *************************************************************\n *************************************************************\n *************************************************************\n *************************************************************\n *************************************************************\n *************************************************************\n *************************************************************\n *************************************************************\n *************************************************************\n *************************************************************\n *************************************************************\n *************************************************************\n *************************************************************\n *************************************************************\n *************************************************************\n *************************************************************\n *************************************************************\n\n -->\n ''' % error_message)", "metadata": "root.ServerHandler.showErrorPage", "header": "['class', 'ServerHandler', '(', 'BaseHTTPRequestHandler', ')', ':', '___EOS___']", "index": 298 }, { "content": " def showDecidePage(self, request):\n id_url_base = self.server.base_url+'id/'\n # XXX: This may break if there are any synonyms for id_url_base,\n # such as referring to it by IP address or a CNAME.\n assert (request.identity.startswith(id_url_base) or \n request.idSelect()), repr((request.identity, id_url_base))\n expected_user = request.identity[len(id_url_base):]\n\n if request.idSelect(): # We are being asked to select an ID\n msg = '''\\\n <p>A site has asked for your identity. You may select an\n identifier by which you would like this site to know you.\n On a production site this would likely be a drop down list\n of pre-created accounts or have the facility to generate\n a random anonymous identifier.\n </p>\n '''\n fdata = {\n 'id_url_base': id_url_base,\n 'trust_root': request.trust_root,\n }\n form = '''\\\n <form method=\"POST\" action=\"/allow\">\n <table>\n <tr><td>Identity:</td>\n <td>%(id_url_base)s<input type='text' name='identifier'></td></tr>\n <tr><td>Trust Root:</td><td>%(trust_root)s</td></tr>\n </table>\n <p>Allow this authentication to proceed?</p>\n <input type=\"checkbox\" id=\"remember\" name=\"remember\" value=\"yes\"\n /><label for=\"remember\">Remember this\n decision</label><br />\n <input type=\"submit\" name=\"yes\" value=\"yes\" />\n <input type=\"submit\" name=\"no\" value=\"no\" />\n </form>\n '''%fdata\n elif expected_user == self.user:\n msg = '''\\\n <p>A new site has asked to confirm your identity. If you\n approve, the site represented by the trust root below will\n be told that you control identity URL listed below. (If\n you are using a delegated identity, the site will take\n care of reversing the delegation on its own.)</p>'''\n\n fdata = {\n 'identity': request.identity,\n 'trust_root': request.trust_root,\n }\n form = '''\\\n <table>\n <tr><td>Identity:</td><td>%(identity)s</td></tr>\n <tr><td>Trust Root:</td><td>%(trust_root)s</td></tr>\n </table>\n <p>Allow this authentication to proceed?</p>\n <form method=\"POST\" action=\"/allow\">\n <input type=\"checkbox\" id=\"remember\" name=\"remember\" value=\"yes\"\n /><label for=\"remember\">Remember this\n decision</label><br />\n <input type=\"submit\" name=\"yes\" value=\"yes\" />\n <input type=\"submit\" name=\"no\" value=\"no\" />\n </form>''' % fdata\n else:\n mdata = {\n 'expected_user': expected_user,\n 'user': self.user,\n }\n msg = '''\\\n <p>A site has asked for an identity belonging to\n %(expected_user)s, but you are logged in as %(user)s. To\n log in as %(expected_user)s and approve the login request,\n hit OK below. The \"Remember this decision\" checkbox\n applies only to the trust root decision.</p>''' % mdata\n\n fdata = {\n 'identity': request.identity,\n 'trust_root': request.trust_root,\n 'expected_user': expected_user,\n }\n form = '''\\\n <table>\n <tr><td>Identity:</td><td>%(identity)s</td></tr>\n <tr><td>Trust Root:</td><td>%(trust_root)s</td></tr>\n </table>\n <p>Allow this authentication to proceed?</p>\n <form method=\"POST\" action=\"/allow\">\n <input type=\"checkbox\" id=\"remember\" name=\"remember\" value=\"yes\"\n /><label for=\"remember\">Remember this\n decision</label><br />\n <input type=\"hidden\" name=\"login_as\" value=\"%(expected_user)s\"/>\n <input type=\"submit\" name=\"yes\" value=\"yes\" />\n <input type=\"submit\" name=\"no\" value=\"no\" />\n </form>''' % fdata\n\n self.showPage(200, 'Approve OpenID request?', msg=msg, form=form)", "metadata": "root.ServerHandler.showDecidePage", "header": "['class', 'ServerHandler', '(', 'BaseHTTPRequestHandler', ')', ':', '___EOS___']", "index": 334 }, { "content": " def showIdPage(self, path):\n link_tag = '<link rel=\"openid.server\" href=\"%sopenidserver\">' %\\\n self.server.base_url\n yadis_loc_tag = '<meta http-equiv=\"x-xrds-location\" content=\"%s\">'%\\\n (self.server.base_url+'yadis/'+path[4:])\n disco_tags = link_tag + yadis_loc_tag\n ident = self.server.base_url + path[1:]\n\n approved_trust_roots = []\n for (aident, trust_root) in self.server.approved.keys():\n if aident == ident:\n trs = '<li><tt>%s</tt></li>\\n' % cgi.escape(trust_root)\n approved_trust_roots.append(trs)\n\n if approved_trust_roots:\n prepend = '<p>Approved trust roots:</p>\\n<ul>\\n'\n approved_trust_roots.insert(0, prepend)\n approved_trust_roots.append('</ul>\\n')\n msg = ''.join(approved_trust_roots)\n else:\n msg = ''\n\n self.showPage(200, 'An Identity Page', head_extras=disco_tags, msg='''\\\n <p>This is an identity page for %s.</p>\n %s\n ''' % (ident, msg))", "metadata": "root.ServerHandler.showIdPage", "header": "['class', 'ServerHandler', '(', 'BaseHTTPRequestHandler', ')', ':', '___EOS___']", "index": 429 }, { "content": " def showYadis(self, user):\n self.send_response(200)\n self.send_header('Content-type', 'application/xrds+xml')\n self.end_headers()\n\n endpoint_url = self.server.base_url + 'openidserver'\n user_url = self.server.base_url + 'id/' + user\n self.wfile.write(\"\"\"\\\n<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<xrds:XRDS\n xmlns:xrds=\"xri://$xrds\"\n xmlns=\"xri://$xrd*($v*2.0)\">\n <XRD>\n\n <Service priority=\"0\">\n <Type>%s</Type>\n <Type>%s</Type>\n <URI>%s</URI>\n <LocalID>%s</LocalID>\n </Service>\n\n </XRD>\n</xrds:XRDS>\n\"\"\"%(discover.OPENID_2_0_TYPE, discover.OPENID_1_0_TYPE,\n endpoint_url, user_url))", "metadata": "root.ServerHandler.showYadis", "header": "['class', 'ServerHandler', '(', 'BaseHTTPRequestHandler', ')', ':', '___EOS___']", "index": 456 }, { "content": " def showServerYadis(self):\n self.send_response(200)\n self.send_header('Content-type', 'application/xrds+xml')\n self.end_headers()\n\n endpoint_url = self.server.base_url + 'openidserver'\n self.wfile.write(\"\"\"\\\n<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<xrds:XRDS\n xmlns:xrds=\"xri://$xrds\"\n xmlns=\"xri://$xrd*($v*2.0)\">\n <XRD>\n\n <Service priority=\"0\">\n <Type>%s</Type>\n <URI>%s</URI>\n </Service>\n\n </XRD>\n</xrds:XRDS>\n\"\"\"%(discover.OPENID_IDP_2_0_TYPE, endpoint_url,))", "metadata": "root.ServerHandler.showServerYadis", "header": "['class', 'ServerHandler', '(', 'BaseHTTPRequestHandler', ')', ':', '___EOS___']", "index": 482 }, { "content": " def showMainPage(self):\n yadis_tag = '<meta http-equiv=\"x-xrds-location\" content=\"%s\">'%\\\n (self.server.base_url + 'serveryadis')\n if self.user:\n openid_url = self.server.base_url + 'id/' + self.user\n user_message = \"\"\"\\\n <p>You are logged in as %s. Your OpenID identity URL is\n <tt><a href=%s>%s</a></tt>. Enter that URL at an OpenID\n consumer to test this server.</p>\n \"\"\" % (self.user, quoteattr(openid_url), openid_url)\n else:\n user_message = \"\"\"\\\n <p>This server uses a cookie to remember who you are in\n order to simulate a standard Web user experience. You are\n not <a href='/login'>logged in</a>.</p>\"\"\"\n\n self.showPage(200, 'Main Page', head_extras = yadis_tag, msg='''\\\n <p>This is a simple OpenID server implemented using the <a\n href=\"http://openid.schtuff.com/\">Python OpenID\n library</a>.</p>\n\n %s\n\n <p>To use this server with a consumer, the consumer must be\n able to fetch HTTP pages from this web server. If this\n computer is behind a firewall, you will not be able to use\n OpenID consumers outside of the firewall with it.</p>\n\n <p>The URL for this server is <a href=%s><tt>%s</tt></a>.</p>\n ''' % (user_message, quoteattr(self.server.base_url), self.server.base_url))", "metadata": "root.ServerHandler.showMainPage", "header": "['class', 'ServerHandler', '(', 'BaseHTTPRequestHandler', ')', ':', '___EOS___']", "index": 504 }, { "content": " def showLoginPage(self, success_to, fail_to):\n self.showPage(200, 'Login Page', form='''\\\n <h2>Login</h2>\n <p>You may log in with any name. This server does not use\n passwords because it is just a sample of how to use the OpenID\n library.</p>\n <form method=\"GET\" action=\"/loginsubmit\">\n <input type=\"hidden\" name=\"success_to\" value=\"%s\" />\n <input type=\"hidden\" name=\"fail_to\" value=\"%s\" />\n <input type=\"text\" name=\"user\" value=\"\" />\n <input type=\"submit\" name=\"submit\" value=\"Log In\" />\n <input type=\"submit\" name=\"cancel\" value=\"Cancel\" />\n </form>\n ''' % (success_to, fail_to))", "metadata": "root.ServerHandler.showLoginPage", "header": "['class', 'ServerHandler', '(', 'BaseHTTPRequestHandler', ')', ':', '___EOS___']", "index": 535 }, { "content": " def showPage(self, response_code, title,\n head_extras='', msg=None, err=None, form=None):\n\n if self.user is None:\n user_link = '<a href=\"/login\">not logged in</a>.'\n else:\n user_link = 'logged in as <a href=\"/id/%s\">%s</a>.<br /><a href=\"/loginsubmit?submit=true&success_to=/login\">Log out</a>' % \\\n (self.user, self.user)\n\n body = ''\n\n if err is not None:\n body += '''\\\n <div class=\"error\">\n %s\n </div>\n ''' % err\n\n if msg is not None:\n body += '''\\\n <div class=\"message\">\n %s\n </div>\n ''' % msg\n\n if form is not None:\n body += '''\\\n <div class=\"form\">\n %s\n </div>\n ''' % form\n\n contents = {\n 'title': 'Python OpenID Server Example - ' + title,\n 'head_extras': head_extras,\n 'body': body,\n 'user_link': user_link,\n }\n\n self.send_response(response_code)\n self.writeUserHeader()\n self.send_header('Content-type', 'text/html')\n self.end_headers()\n\n self.wfile.write('''<html>\n <head>\n <title>%(title)s</title>\n %(head_extras)s\n </head>\n <style type=\"text/css\">\n h1 a:link {\n color: black;\n text-decoration: none;\n }\n h1 a:visited {\n color: black;\n text-decoration: none;\n }\n h1 a:hover {\n text-decoration: underline;\n }\n body {\n font-family: verdana,sans-serif;\n width: 50em;\n margin: 1em;\n }\n div {\n padding: .5em;\n }\n table {\n margin: none;\n padding: none;\n }\n .banner {\n padding: none 1em 1em 1em;\n width: 100%%;\n }\n .leftbanner {\n text-align: left;\n }\n .rightbanner {\n text-align: right;\n font-size: smaller;\n }\n .error {\n border: 1px solid #ff0000;\n background: #ffaaaa;\n margin: .5em;\n }\n .message {\n border: 1px solid #2233ff;\n background: #eeeeff;\n margin: .5em;\n }\n .form {\n border: 1px solid #777777;\n background: #ddddcc;\n margin: .5em;\n margin-top: 1em;\n padding-bottom: 0em;\n }\n dd {\n margin-bottom: 0.5em;\n }\n </style>\n <body>\n <table class=\"banner\">\n <tr>\n <td class=\"leftbanner\">\n <h1><a href=\"/\">Python OpenID Server Example</a></h1>\n </td>\n <td class=\"rightbanner\">\n You are %(user_link)s\n </td>\n </tr>\n </table>\n%(body)s\n </body>\n</html>\n''' % contents)", "metadata": "root.ServerHandler.showPage", "header": "['class', 'ServerHandler', '(', 'BaseHTTPRequestHandler', ')', ':', '___EOS___']", "index": 550 }, { "content": "def main(host, port, data_path):\n addr = (host, port)\n httpserver = OpenIDHTTPServer(addr, ServerHandler)\n\n # Instantiate OpenID consumer store and OpenID consumer. If you\n # were connecting to a database, you would create the database\n # connection and instantiate an appropriate store here.\n store = FileOpenIDStore(data_path)\n oidserver = server.Server(store, httpserver.base_url + 'openidserver')\n\n httpserver.setOpenIDServer(oidserver)\n\n print 'Server running at:'\n print httpserver.base_url\n httpserver.serve_forever()", "metadata": "root.main", "header": "['module', '___EOS___']", "index": 672 } ]
[ { "span": "import openid", "start_line": 18, "start_column": 4, "end_line": 18, "end_column": 17 } ]
[]
1
false
[ "[CLS]_", "Un", "used_", "import_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "#!", "/", "usr", "/", "bin", "/", "env", " ", "python_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u", "copyright\\u\\u_", "=_", "'", "Copy", "right", " ", "2005", "-", "2008", ",", " ", "Jan", "rain", ",", " ", "Inc", ".'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "from_", "Base", "HTTP", "Server_", "import_", "HTTP", "Server_", ",_", "Base", "HTTP", "Request", "Handler_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "urlparse_", "import_", "urlparse_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "import_", "time_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "Cookie_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "cgi_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "cgi", "tb_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "sys_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "import_", "openid", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "Import", "Error_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "sys_", "._", "stderr_", "._", "write_", "(_", "\"\"\"", "\\", "10", ";", "Fail", "ed", " ", "to", " ", "import", " ", "the", " ", "Open", "ID", " ", "librar", "y", ".", " ", "In", " ", "order", " ", "to", " ", "use", " ", "this", " ", "example", ",", " ", "you", "\\", "10", ";", "must", " ", "eit", "her", " ", "install", " ", "the", " ", "librar", "y", " ", "(", "see", " ", "INSTA", "LL", " ", "in", " ", "the", " ", "root", " ", "of", " ", "the", "\\", "10", ";", "distribu", "tion", ")", " ", "or", " ", "else", " ", "add", " ", "the", " ", "librar", "y", " ", "to", " ", "python", "'", "s", " ", "import", " ", "path", " ", "(", "the", "\\", "10", ";", "PYTHON", "PATH", " ", "environ", "ment", " ", "variab", "le", ").", "\\", "10", ";", "\\", "10", ";", "For", " ", "more", " ", "informati", "on", ",", " ", "see", " ", "the", " ", "READ", "ME", " ", "in", " ", "the", " ", "root", " ", "of", " ", "the", " ", "librar", "y", "\\", "10", ";", "distribu", "tion", ".\"\"\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "sys_", "._", "exit_", "(_", "1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "from_", "openid", "_", "._", "extensions_", "import_", "sre", "g_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "openid", "_", "._", "server_", "import_", "server_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "openid", "_", "._", "store_", "._", "filest", "ore_", "import_", "File", "Open", "IDS", "tore_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "openid", "_", "._", "consumer_", "import_", "discover_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "\\u\\u", "name\\u\\u_", "==_", "'\\u", "\\u", "main", "\\u\\u'_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "host_", "=_", "'", "local", "host", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "data\\u", "path_", "=_", "'", "sst", "ore", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "port_", "=_", "8000_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "import_", "optparse_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "Import", "Error_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "pass_", "#", " ", "Us", "e", " ", "default", "s", " ", "(", "for", " ", "Pyth", "on", " ", "2.2", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "parser_", "=_", "optparse_", "._", "Optio", "n", "Parser_", "(_", "'", "Us", "age", ":\\\\", "n", " ", "%", "prog", " ", "[", "options", "]'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "parser_", "._", "add", "\\u", "option_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "'-", "d", "'_", ",_", "'--", "data", "-", "path", "'_", ",_", "dest_", "=_", "'", "data\\u", "path", "'_", ",_", "default_", "=_", "data\\u", "path_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "help_", "=_", "'", "Data", " ", "director", "y", " ", "for", " ", "stor", "ing", " ", "Open", "ID", " ", "consume", "r", " ", "state", ".", " ", "'_", "\\u\\u\\uNL\\u\\u\\u_", "'", "Default", "s", " ", "to", " ", "\"%", "default", "\"", " ", "in", " ", "the", " ", "current", " ", "director", "y", ".'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "parser_", "._", "add", "\\u", "option_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "'-", "p", "'_", ",_", "'--", "port", "'_", ",_", "dest_", "=_", "'", "port", "'_", ",_", "type_", "=_", "'", "int", "'_", ",_", "default_", "=_", "port_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "help_", "=_", "'", "Port", " ", "on", " ", "whi", "ch", " ", "to", " ", "listen", " ", "for", " ", "HTTP", " ", "request", "s", ".", " ", "'_", "\\u\\u\\uNL\\u\\u\\u_", "'", "Default", "s", " ", "to", " ", "port", " ", "%", "default", ".'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "parser_", "._", "add", "\\u", "option_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "'-", "s", "'_", ",_", "'--", "host", "'_", ",_", "dest_", "=_", "'", "host", "'_", ",_", "default_", "=_", "host_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "help_", "=_", "'", "Host", " ", "on", " ", "whi", "ch", " ", "to", " ", "listen", " ", "for", " ", "HTTP", " ", "request", "s", ".", " ", "'_", "\\u\\u\\uNL\\u\\u\\u_", "'", "Al", "so", " ", "used", " ", "for", " ", "generat", "ing", " ", "URL", "s", ".", " ", "Default", "s", " ", "to", " ", "%", "default", ".'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "options_", ",_", "args_", "=_", "parser_", "._", "parse", "\\u", "args_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "args_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "parser_", "._", "error_", "(_", "'", "Expect", "ed", " ", "no", " ", "argu", "ment", "s", ".", " ", "Got", " ", "%", "r", "'_", "%_", "args_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "host_", "=_", "options_", "._", "host_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "port_", "=_", "options_", "._", "port_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "data\\u", "path_", "=_", "options_", "._", "data\\u", "path_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "main_", "(_", "host_", ",_", "port_", ",_", "data\\u", "path_", ")_", "\\u\\u\\uDEDENT\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "quote", "attr_", "(_", "s_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "qs_", "=_", "cgi_", "._", "escape_", "(_", "s_", ",_", "1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "'\"", "%", "s", "\"'_", "%_", "(_", "qs_", ",_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "class_", "Open", "ID", "HTTP", "Server_", "(_", "HTTP", "Server_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "http", " ", "server", " ", "tha", "t", " ", "contain", "s", " ", "a", " ", "reference", " ", "to", " ", "an", " ", "Open", "ID", " ", "Server", " ", "and", "\\", "10", ";", " ", " ", " ", " ", "knows", " ", "its", " ", "base", " ", "URL", ".", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "[SEP]_", "class_", "Open", "ID", "HTTP", "Server_", "(_", "HTTP", "Server_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "\\u\\u", "init\\u\\u_", "(_", "self_", ",_", "*_", "args_", ",_", "**_", "kwargs_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "HTTP", "Server_", "._", "\\u\\u", "init\\u\\u_", "(_", "self_", ",_", "*_", "args_", ",_", "**_", "kwargs_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "self_", "._", "server", "\\u", "port_", "!=_", "80_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "base", "\\u", "url_", "=_", "(_", "'", "http", "://", "%", "s", ":", "%", "s", "/'_", "%_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "self_", "._", "server", "\\u", "name_", ",_", "self_", "._", "server", "\\u", "port_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "base", "\\u", "url_", "=_", "'", "http", "://", "%", "s", "/'_", "%_", "(_", "self_", "._", "server", "\\u", "name_", ",_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "openid", "_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "approved", "_", "=_", "{_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "last", "Check", "ID", "Request_", "=_", "{_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Open", "ID", "HTTP", "Server_", "(_", "HTTP", "Server_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "set", "Open", "IDS", "erver_", "(_", "self_", ",_", "oids", "erver_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "openid", "_", "=_", "oids", "erver_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "class_", "Server", "Handler_", "(_", "Base", "HTTP", "Request", "Handler_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "[SEP]_", "class_", "Server", "Handler_", "(_", "Base", "HTTP", "Request", "Handler_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "def_", "\\u\\u", "init\\u\\u_", "(_", "self_", ",_", "*_", "args_", ",_", "**_", "kwargs_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "user_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "Base", "HTTP", "Request", "Handler_", "._", "\\u\\u", "init\\u\\u_", "(_", "self_", ",_", "*_", "args_", ",_", "**_", "kwargs_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Server", "Handler_", "(_", "Base", "HTTP", "Request", "Handler_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "do", "\\u", "GET_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "parsed", "\\u", "uri_", "=_", "urlparse_", "(_", "self_", "._", "path_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "query_", "=_", "{_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "k_", ",_", "v_", "in_", "cgi_", "._", "parse", "\\u", "qs", "l_", "(_", "self_", "._", "parsed", "\\u", "uri_", "[_", "4_", "]_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "query_", "[_", "k_", "]_", "=_", "v_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "set", "User_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "path_", "=_", "self_", "._", "parsed", "\\u", "uri_", "[_", "2_", "]_", "._", "lower_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "path_", "==_", "'/'_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "show", "Main", "Page_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "path_", "==_", "'/", "openid", "server", "'_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "server", "End", "Point_", "(_", "self_", "._", "query_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "path_", "==_", "'/", "login", "'_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "show", "Logi", "n", "Page_", "(_", "'/'_", ",_", "'/'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "path_", "==_", "'/", "login", "submit", "'_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "do", "Login_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "path_", "._", "startswith_", "(_", "'/", "id", "/'_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "show", "Id", "Page_", "(_", "path_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "path_", "._", "startswith_", "(_", "'/", "ya", "dis", "/'_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "show", "Ya", "dis_", "(_", "path_", "[_", "7_", ":_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "path_", "==_", "'/", "server", "ya", "dis", "'_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "show", "Server", "Ya", "dis_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "send", "\\u", "response_", "(_", "404_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "end", "\\u", "headers_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "(_", "Key", "board", "Interrupt_", ",_", "System", "Exit_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "raise_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "send", "\\u", "response_", "(_", "500_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "send", "\\u", "header_", "(_", "'", "Conten", "t", "-", "type", "'_", ",_", "'", "text", "/", "html", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "end", "\\u", "headers_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "wfile_", "._", "write_", "(_", "cgi", "tb_", "._", "html_", "(_", "sys_", "._", "exc", "\\u", "info_", "(_", ")_", ",_", "context_", "=_", "10_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Server", "Handler_", "(_", "Base", "HTTP", "Request", "Handler_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "do", "\\u", "POST_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "parsed", "\\u", "uri_", "=_", "urlparse_", "(_", "self_", "._", "path_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "set", "User_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "content", "\\u", "length_", "=_", "int_", "(_", "self_", "._", "headers_", "[_", "'", "Conten", "t", "-", "Length", "'_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "post", "\\u", "data_", "=_", "self_", "._", "rfile_", "._", "read_", "(_", "content", "\\u", "length_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "query_", "=_", "{_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "k_", ",_", "v_", "in_", "cgi_", "._", "parse", "\\u", "qs", "l_", "(_", "post", "\\u", "data_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "query_", "[_", "k_", "]_", "=_", "v_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "path_", "=_", "self_", "._", "parsed", "\\u", "uri_", "[_", "2_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "path_", "==_", "'/", "openid", "server", "'_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "server", "End", "Point_", "(_", "self_", "._", "query_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "path_", "==_", "'/", "allow", "'_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "handle", "All", "ow_", "(_", "self_", "._", "query_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "send", "\\u", "response_", "(_", "404_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "end", "\\u", "headers_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "(_", "Key", "board", "Interrupt_", ",_", "System", "Exit_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "raise_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "send", "\\u", "response_", "(_", "500_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "send", "\\u", "header_", "(_", "'", "Conten", "t", "-", "type", "'_", ",_", "'", "text", "/", "html", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "end", "\\u", "headers_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "wfile_", "._", "write_", "(_", "cgi", "tb_", "._", "html_", "(_", "sys_", "._", "exc", "\\u", "info_", "(_", ")_", ",_", "context_", "=_", "10_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Server", "Handler_", "(_", "Base", "HTTP", "Request", "Handler_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "handle", "All", "ow_", "(_", "self_", ",_", "query_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "prete", "nd", " ", "this", " ", "next", " ", "bit", " ", "is", " ", "key", "ing", " ", "off", " ", "the", " ", "user", "'", "s", " ", "session", " ", "or", " ", "somet", "hing", ",_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "right", "?", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "request_", "=_", "self_", "._", "server_", "._", "last", "Check", "ID", "Request_", "._", "get_", "(_", "self_", "._", "user_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "'", "ye", "s", "'_", "in_", "query_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "'", "login", "\\u", "as", "'_", "in_", "query_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "user_", "=_", "self_", "._", "query_", "[_", "'", "login", "\\u", "as", "'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "request_", "._", "id", "Select_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "identity_", "=_", "self_", "._", "server_", "._", "base", "\\u", "url_", "+_", "'", "id", "/'_", "+_", "query_", "[_", "'", "identifi", "er", "'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "identity_", "=_", "request_", "._", "identity_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "trust", "\\u", "root_", "=_", "request_", "._", "trust", "\\u", "root_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "self_", "._", "query_", "._", "get_", "(_", "'", "remember", "'_", ",_", "'", "no", "'_", ")_", "==_", "'", "ye", "s", "'_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "server_", "._", "approved", "_", "[_", "(_", "identity_", ",_", "trust", "\\u", "root_", ")_", "]_", "=_", "'", "alw", "ay", "s", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "response_", "=_", "self_", "._", "approved", "_", "(_", "request_", ",_", "identity_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "'", "no", "'_", "in_", "query_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "response_", "=_", "request_", "._", "answer_", "(_", "False_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "assert_", "False_", ",_", "'", "stran", "ge", " ", "allow", " ", "post", ".", " ", " ", "%", "r", "'_", "%_", "(_", "query_", ",_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "display", "Response_", "(_", "response_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Server", "Handler_", "(_", "Base", "HTTP", "Request", "Handler_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "set", "User_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "cookies_", "=_", "self_", "._", "headers_", "._", "get_", "(_", "'", "Cooki", "e", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "cookies_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "mor", "sel_", "=_", "Cookie_", "._", "Base", "Cookie_", "(_", "cookies_", ")_", "._", "get_", "(_", "'", "user", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "mor", "sel_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "user_", "=_", "mor", "sel_", "._", "value_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Server", "Handler_", "(_", "Base", "HTTP", "Request", "Handler_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "is", "Authorized", "_", "(_", "self_", ",_", "identi", "ty", "\\u", "url_", ",_", "trust", "\\u", "root_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "self_", "._", "user_", "is_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "identi", "ty", "\\u", "url_", "!=_", "self_", "._", "server_", "._", "base", "\\u", "url_", "+_", "'", "id", "/'_", "+_", "self_", "._", "user_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "key_", "=_", "(_", "identi", "ty", "\\u", "url_", ",_", "trust", "\\u", "root_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "self_", "._", "server_", "._", "approved", "_", "._", "get_", "(_", "key_", ")_", "is_", "not_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Server", "Handler_", "(_", "Base", "HTTP", "Request", "Handler_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "server", "End", "Point_", "(_", "self_", ",_", "query_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "request_", "=_", "self_", "._", "server_", "._", "openid", "_", "._", "decode", "Request_", "(_", "query_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "server_", "._", "Proto", "col", "Error_", ",_", "why_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "display", "Response_", "(_", "why_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "request_", "is_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Display", " ", "text", " ", "indicati", "ng", " ", "tha", "t", " ", "this", " ", "is", " ", "an", " ", "endpoint", "._", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "show", "Abo", "ut", "Page_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "request_", "._", "mode_", "in_", "[_", "\"", "check", "id", "\\u", "immediate", "\"_", ",_", "\"", "check", "id", "\\u", "setup", "\"_", "]_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "handle", "Check", "ID", "Request_", "(_", "request_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "response_", "=_", "self_", "._", "server_", "._", "openid", "_", "._", "handle", "Request_", "(_", "request_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "display", "Response_", "(_", "response_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Server", "Handler_", "(_", "Base", "HTTP", "Request", "Handler_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "add", "SR", "eg", "Response_", "(_", "self_", ",_", "request_", ",_", "response_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "sre", "g", "\\u", "req_", "=_", "sre", "g_", "._", "SR", "eg", "Request_", "._", "from", "Open", "ID", "Request_", "(_", "request_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "In", " ", "a", " ", "real", " ", "applica", "tion", ",", " ", "this", " ", "data", " ", "wou", "ld", " ", "be", " ", "user", "-", "specific", ",_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "and", " ", "the", " ", "user", " ", "shou", "ld", " ", "be", " ", "ask", "ed", " ", "for", " ", "permissi", "on", " ", "to", " ", "release_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "it", "._", "\\u\\u\\uNL\\u\\u\\u_", "sre", "g", "\\u", "data_", "=_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "'", "nick", "name", "'_", ":_", "self_", "._", "user_", "\\u\\u\\uNL\\u\\u\\u_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "sre", "g", "\\u", "resp_", "=_", "sre", "g_", "._", "SR", "eg", "Response_", "._", "extract", "Response_", "(_", "sre", "g", "\\u", "req_", ",_", "sre", "g", "\\u", "data_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "response_", "._", "add", "Extension_", "(_", "sre", "g", "\\u", "resp_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Server", "Handler_", "(_", "Base", "HTTP", "Request", "Handler_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "approved", "_", "(_", "self_", ",_", "request_", ",_", "identifier_", "=_", "None_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "response_", "=_", "request_", "._", "answer_", "(_", "True_", ",_", "identity_", "=_", "identifier_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "add", "SR", "eg", "Response_", "(_", "request_", ",_", "response_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "response_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Server", "Handler_", "(_", "Base", "HTTP", "Request", "Handler_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "handle", "Check", "ID", "Request_", "(_", "self_", ",_", "request_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "is", "\\u", "authorized_", "=_", "self_", "._", "is", "Authorized", "_", "(_", "request_", "._", "identity_", ",_", "request_", "._", "trust", "\\u", "root_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "is", "\\u", "authorized_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "response_", "=_", "self_", "._", "approved", "_", "(_", "request_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "display", "Response_", "(_", "response_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "request_", "._", "immediate", "_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "response_", "=_", "request_", "._", "answer_", "(_", "False_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "display", "Response_", "(_", "response_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "server_", "._", "last", "Check", "ID", "Request_", "[_", "self_", "._", "user_", "]_", "=_", "request_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "show", "Deci", "de", "Page_", "(_", "request_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Server", "Handler_", "(_", "Base", "HTTP", "Request", "Handler_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "display", "Response_", "(_", "self_", ",_", "response_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "webr", "esp", "ons", "e_", "=_", "self_", "._", "server_", "._", "openid", "_", "._", "encode", "Response_", "(_", "response_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "server_", "._", "Enco", "ding", "Error_", ",_", "why_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "text_", "=_", "why_", "._", "response_", "._", "encode", "To", "KV", "Form_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "show", "Error", "Page_", "(_", "'<", "pre", ">", "%", "s", "</", "pre", ">'_", "%_", "cgi_", "._", "escape_", "(_", "text_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "send", "\\u", "response_", "(_", "webr", "esp", "ons", "e_", "._", "code_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "header_", ",_", "value_", "in_", "webr", "esp", "ons", "e_", "._", "headers_", "._", "iteritems_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "send", "\\u", "header_", "(_", "header_", ",_", "value_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "write", "User", "Header_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "end", "\\u", "headers_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "webr", "esp", "ons", "e_", "._", "body_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "wfile_", "._", "write_", "(_", "webr", "esp", "ons", "e_", "._", "body_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Server", "Handler_", "(_", "Base", "HTTP", "Request", "Handler_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "do", "Login_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "'", "submit", "'_", "in_", "self_", "._", "query_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "'", "user", "'_", "in_", "self_", "._", "query_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "user_", "=_", "self_", "._", "query_", "[_", "'", "user", "'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "user_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "redirect_", "(_", "self_", "._", "query_", "[_", "'", "success", "\\u", "to", "'_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "'", "cancel", "'_", "in_", "self_", "._", "query_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "redirect_", "(_", "self_", "._", "query_", "[_", "'", "fail", "\\u", "to", "'_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "assert_", "0_", ",_", "'", "stran", "ge", " ", "login", " ", "%", "r", "'_", "%_", "(_", "self_", "._", "query_", ",_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Server", "Handler_", "(_", "Base", "HTTP", "Request", "Handler_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "redirect_", "(_", "self_", ",_", "url_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "send", "\\u", "response_", "(_", "302_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "send", "\\u", "header_", "(_", "'", "Locat", "ion", "'_", ",_", "url_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "write", "User", "Header_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "end", "\\u", "headers_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Server", "Handler_", "(_", "Base", "HTTP", "Request", "Handler_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "write", "User", "Header_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "self_", "._", "user_", "is_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "t1", "970", "_", "=_", "time_", "._", "gmtime_", "(_", "0_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "expires_", "=_", "time_", "._", "strftime_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "'", "Expire", "s", "=", "%", "a", ",", " ", "%", "d", "-%", "b", "-%", "y", " ", "%", "H", ":", "%", "M", ":", "%", "S", " ", "GM", "T", "'_", ",_", "t1", "970", "_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "send", "\\u", "header_", "(_", "'", "Set", "-", "Cooki", "e", "'_", ",_", "'", "user", "=", ";", "%", "s", "'_", "%_", "expires_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "send", "\\u", "header_", "(_", "'", "Set", "-", "Cooki", "e", "'_", ",_", "'", "user", "=", "%", "s", "'_", "%_", "self_", "._", "user_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Server", "Handler_", "(_", "Base", "HTTP", "Request", "Handler_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "show", "Abo", "ut", "Page_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "endpoint", "\\u", "url_", "=_", "self_", "._", "server_", "._", "base", "\\u", "url_", "+_", "'", "openid", "server", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "link_", "(_", "url_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "url", "\\u", "attr_", "=_", "quote", "attr_", "(_", "url_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "url", "\\u", "text_", "=_", "cgi_", "._", "escape_", "(_", "url_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "'<", "a", " ", "href", "=", "%", "s", "><", "code", ">", "%", "s", "</", "code", "><", "/", "a", ">'_", "%_", "(_", "url", "\\u", "attr_", ",_", "url", "\\u", "text_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "term_", "(_", "url_", ",_", "text_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "'<", "dt", ">", "%", "s", "</", "dt", "><", "dd", ">", "%", "s", "</", "dd", ">'_", "%_", "(_", "link_", "(_", "url_", ")_", ",_", "text_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "resources_", "=_", "[_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "self_", "._", "server_", "._", "base", "\\u", "url_", ",_", "\"", "Thi", "s", " ", "example", " ", "server", "'", "s", " ", "home", " ", "page", "\"_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "'", "http", "://", "www", ".", "openid", "enable", "d", ".", "com", "/'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "An", " ", "Open", "ID", " ", "communi", "ty", " ", "Web", " ", "site", ",", " ", "home", " ", "of", " ", "this", " ", "librar", "y", "'_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "'", "http", "://", "www", ".", "openid", ".", "net", "/'_", ",_", "'", "the", " ", "official", " ", "Open", "ID", " ", "Web", " ", "site", "'_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "resource", "\\u", "markup_", "=_", "''_", "._", "join_", "(_", "[_", "term_", "(_", "url_", ",_", "text_", ")_", "for_", "url_", ",_", "text_", "in_", "resources_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "show", "Page_", "(_", "200_", ",_", "'", "Thi", "s", " ", "is", " ", "an", " ", "Open", "ID", " ", "server", "'_", ",_", "msg_", "=_", "\"\"\"", "\\\\", "\\", "10", ";", " ", " ", " ", " ", "<", "p", ">", "%", "s", " ", "is", " ", "an", " ", "Open", "ID", " ", "server", " ", "endpoint", ".", "<", "p", ">", "\\", "10", ";", " ", " ", " ", " ", "<", "p", ">", "For", " ", "more", " ", "informati", "on", " ", "abo", "ut", " ", "Open", "ID", ",", " ", "see", ":", "</", "p", ">", "\\", "10", ";", " ", " ", " ", " ", "<", "dl", ">", "\\", "10", ";", " ", " ", " ", " ", "%", "s", "\\", "10", ";", " ", " ", " ", " ", "</", "dl", ">", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "%_", "(_", "link_", "(_", "endpoint", "\\u", "url_", ")_", ",_", "resource", "\\u", "markup_", ",_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Server", "Handler_", "(_", "Base", "HTTP", "Request", "Handler_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "show", "Error", "Page_", "(_", "self_", ",_", "error", "\\u", "message_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "show", "Page_", "(_", "400_", ",_", "'", "Error", " ", "Process", "ing", " ", "Request", "'_", ",_", "err_", "=_", "'''", "\\\\", "\\", "10", ";", " ", " ", " ", " ", "<", "p", ">", "%", "s", "</", "p", ">", "\\", "10", ";", " ", " ", " ", " ", "<!", "--", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "Thi", "s", " ", "is", " ", "a", " ", "large", " ", "comment", ".", " ", " ", "It", " ", "exist", "s", " ", "to", " ", "make", " ", "this", " ", "page", " ", "large", "r", ".", "\\", "10", ";", " ", " ", " ", " ", "Tha", "t", " ", "is", " ", "unfo", "rtu", "nat", "el", "y", " ", "necessar", "y", " ", "bec", "aus", "e", " ", "of", " ", "the", " ", "\"", "smart", "\"", "\\", "10", ";", " ", " ", " ", " ", "handling", " ", "of", " ", "page", "s", " ", "return", "ed", " ", "with", " ", "an", " ", "error", " ", "code", " ", "in", " ", "IE", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "***********", "***********", "***********", "***********", "***********", "*****", "*", "\\", "10", ";", " ", " ", " ", " ", "***********", "***********", "***********", "***********", "***********", "*****", "*", "\\", "10", ";", " ", " ", " ", " ", "***********", "***********", "***********", "***********", "***********", "*****", "*", "\\", "10", ";", " ", " ", " ", " ", "***********", "***********", "***********", "***********", "***********", "*****", "*", "\\", "10", ";", " ", " ", " ", " ", "***********", "***********", "***********", "***********", "***********", "*****", "*", "\\", "10", ";", " ", " ", " ", " ", "***********", "***********", "***********", "***********", "***********", "*****", "*", "\\", "10", ";", " ", " ", " ", " ", "***********", "***********", "***********", "***********", "***********", "*****", "*", "\\", "10", ";", " ", " ", " ", " ", "***********", "***********", "***********", "***********", "***********", "*****", "*", "\\", "10", ";", " ", " ", " ", " ", "***********", "***********", "***********", "***********", "***********", "*****", "*", "\\", "10", ";", " ", " ", " ", " ", "***********", "***********", "***********", "***********", "***********", "*****", "*", "\\", "10", ";", " ", " ", " ", " ", "***********", "***********", "***********", "***********", "***********", "*****", "*", "\\", "10", ";", " ", " ", " ", " ", "***********", "***********", "***********", "***********", "***********", "*****", "*", "\\", "10", ";", " ", " ", " ", " ", "***********", "***********", "***********", "***********", "***********", "*****", "*", "\\", "10", ";", " ", " ", " ", " ", "***********", "***********", "***********", "***********", "***********", "*****", "*", "\\", "10", ";", " ", " ", " ", " ", "***********", "***********", "***********", "***********", "***********", "*****", "*", "\\", "10", ";", " ", " ", " ", " ", "***********", "***********", "***********", "***********", "***********", "*****", "*", "\\", "10", ";", " ", " ", " ", " ", "***********", "***********", "***********", "***********", "***********", "*****", "*", "\\", "10", ";", " ", " ", " ", " ", "***********", "***********", "***********", "***********", "***********", "*****", "*", "\\", "10", ";", " ", " ", " ", " ", "***********", "***********", "***********", "***********", "***********", "*****", "*", "\\", "10", ";", " ", " ", " ", " ", "***********", "***********", "***********", "***********", "***********", "*****", "*", "\\", "10", ";", " ", " ", " ", " ", "***********", "***********", "***********", "***********", "***********", "*****", "*", "\\", "10", ";", " ", " ", " ", " ", "***********", "***********", "***********", "***********", "***********", "*****", "*", "\\", "10", ";", " ", " ", " ", " ", "***********", "***********", "***********", "***********", "***********", "*****", "*", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "-->", "\\", "10", ";", " ", " ", " ", " ", "'''_", "%_", "error", "\\u", "message_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Server", "Handler_", "(_", "Base", "HTTP", "Request", "Handler_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "show", "Deci", "de", "Page_", "(_", "self_", ",_", "request_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "id", "\\u", "url", "\\u", "base_", "=_", "self_", "._", "server_", "._", "base", "\\u", "url_", "+_", "'", "id", "/'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "XX", "X", ":", " ", "Thi", "s", " ", "may", " ", "break", " ", "if", " ", "there", " ", "are", " ", "any", " ", "synonyms", " ", "for", " ", "id", "\\u", "url", "\\u", "base", ",_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "suc", "h", " ", "as", " ", "refer", "ring", " ", "to", " ", "it", " ", "by", " ", "IP", " ", "address", " ", "or", " ", "a", " ", "CNA", "ME", "._", "\\u\\u\\uNL\\u\\u\\u_", "assert_", "(_", "request_", "._", "identity_", "._", "startswith_", "(_", "id", "\\u", "url", "\\u", "base_", ")_", "or_", "\\u\\u\\uNL\\u\\u\\u_", "request_", "._", "id", "Select_", "(_", ")_", ")_", ",_", "repr_", "(_", "(_", "request_", "._", "identity_", ",_", "id", "\\u", "url", "\\u", "base_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "expected", "\\u", "user_", "=_", "request_", "._", "identity_", "[_", "len_", "(_", "id", "\\u", "url", "\\u", "base_", ")_", ":_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "request_", "._", "id", "Select_", "(_", ")_", ":_", "#", " ", "We", " ", "are", " ", "bei", "ng", " ", "ask", "ed", " ", "to", " ", "select", " ", "an", " ", "ID_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "msg_", "=_", "'''", "\\\\", "\\", "10", ";", " ", " ", " ", " ", "<", "p", ">", "A", " ", "site", " ", "has", " ", "ask", "ed", " ", "for", " ", "your", " ", "identi", "ty", ".", " ", " ", "You", " ", "may", " ", "select", " ", "an", "\\", "10", ";", " ", " ", " ", " ", "identifi", "er", " ", "by", " ", "whi", "ch", " ", "you", " ", "wou", "ld", " ", "like", " ", "this", " ", "site", " ", "to", " ", "know", " ", "you", ".", "\\", "10", ";", " ", " ", " ", " ", "On", " ", "a", " ", "producti", "on", " ", "site", " ", "this", " ", "wou", "ld", " ", "like", "ly", " ", "be", " ", "a", " ", "drop", " ", "down", " ", "list", "\\", "10", ";", " ", " ", " ", " ", "of", " ", "pre", "-", "created", " ", "account", "s", " ", "or", " ", "have", " ", "the", " ", "facilit", "y", " ", "to", " ", "generat", "e", "\\", "10", ";", " ", " ", " ", " ", "a", " ", "random", " ", "anonym", "ous", " ", "identifi", "er", ".", "\\", "10", ";", " ", " ", " ", " ", "</", "p", ">", "\\", "10", ";", " ", " ", " ", " ", "'''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "fdata", "_", "=_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "'", "id", "\\u", "url", "\\u", "base", "'_", ":_", "id", "\\u", "url", "\\u", "base_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "trust", "\\u", "root", "'_", ":_", "request_", "._", "trust", "\\u", "root_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "form_", "=_", "'''", "\\\\", "\\", "10", ";", " ", " ", " ", " ", "<", "form", " ", "method", "=\"", "POST", "\"", " ", "action", "=\"", "/", "allow", "\">", "\\", "10", ";", " ", " ", " ", " ", "<", "table", ">", "\\", "10", ";", " ", " ", " ", " ", " ", " ", "<", "tr", "><", "td", ">", "Ident", "it", "y", ":", "</", "td", ">", "\\", "10", ";", " ", " ", " ", " ", " ", "<", "td", ">", "%", "(", "id", "\\u", "url", "\\u", "base", ")", "s", "<", "input", " ", "type", "='", "text", "'", " ", "name", "='", "identifi", "er", "'><", "/", "td", "><", "/", "tr", ">", "\\", "10", ";", " ", " ", " ", " ", " ", " ", "<", "tr", "><", "td", ">", "Trust", " ", "Roo", "t", ":", "</", "td", "><", "td", ">", "%", "(", "trust", "\\u", "root", ")", "s", "</", "td", "><", "/", "tr", ">", "\\", "10", ";", " ", " ", " ", " ", "</", "table", ">", "\\", "10", ";", " ", " ", " ", " ", "<", "p", ">", "All", "ow", " ", "this", " ", "authenticat", "ion", " ", "to", " ", "proceed", "?<", "/", "p", ">", "\\", "10", ";", " ", " ", " ", " ", "<", "input", " ", "type", "=\"", "checkb", "ox", "\"", " ", "id", "=\"", "remember", "\"", " ", "name", "=\"", "remember", "\"", " ", "value", "=\"", "ye", "s", "\"", "\\", "10", ";", " ", " ", " ", " ", "/>", "<", "label", " ", "for", "=\"", "remember", "\">", "Reme", "mber", " ", "this", "\\", "10", ";", " ", " ", " ", " ", "decision", "</", "label", "><", "br", " ", "/>", "\\", "10", ";", " ", " ", " ", " ", "<", "input", " ", "type", "=\"", "submit", "\"", " ", "name", "=\"", "ye", "s", "\"", " ", "value", "=\"", "ye", "s", "\"", " ", "/>", "\\", "10", ";", " ", " ", " ", " ", "<", "input", " ", "type", "=\"", "submit", "\"", " ", "name", "=\"", "no", "\"", " ", "value", "=\"", "no", "\"", " ", "/>", "\\", "10", ";", " ", " ", " ", " ", "</", "form", ">", "\\", "10", ";", " ", " ", " ", " ", "'''_", "%_", "fdata", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "expected", "\\u", "user_", "==_", "self_", "._", "user_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "msg_", "=_", "'''", "\\\\", "\\", "10", ";", " ", " ", " ", " ", "<", "p", ">", "A", " ", "new", " ", "site", " ", "has", " ", "ask", "ed", " ", "to", " ", "confirm", " ", "your", " ", "identi", "ty", ".", " ", " ", "If", " ", "you", "\\", "10", ";", " ", " ", " ", " ", "approve", ",", " ", "the", " ", "site", " ", "represent", "ed", " ", "by", " ", "the", " ", "trust", " ", "root", " ", "belo", "w", " ", "will", "\\", "10", ";", " ", " ", " ", " ", "be", " ", "tol", "d", " ", "tha", "t", " ", "you", " ", "control", " ", "identi", "ty", " ", "URL", " ", "liste", "d", " ", "belo", "w", ".", " ", "(", "If", "\\", "10", ";", " ", " ", " ", " ", "you", " ", "are", " ", "usi", "ng", " ", "a", " ", "delegate", "d", " ", "identi", "ty", ",", " ", "the", " ", "site", " ", "will", " ", "take", "\\", "10", ";", " ", " ", " ", " ", "care", " ", "of", " ", "reversi", "ng", " ", "the", " ", "delegat", "ion", " ", "on", " ", "its", " ", "own", ".)", "</", "p", ">'''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "fdata", "_", "=_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "'", "identi", "ty", "'_", ":_", "request_", "._", "identity_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "trust", "\\u", "root", "'_", ":_", "request_", "._", "trust", "\\u", "root_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "form_", "=_", "'''", "\\\\", "\\", "10", ";", " ", " ", " ", " ", "<", "table", ">", "\\", "10", ";", " ", " ", " ", " ", " ", " ", "<", "tr", "><", "td", ">", "Ident", "it", "y", ":", "</", "td", "><", "td", ">", "%", "(", "identi", "ty", ")", "s", "</", "td", "><", "/", "tr", ">", "\\", "10", ";", " ", " ", " ", " ", " ", " ", "<", "tr", "><", "td", ">", "Trust", " ", "Roo", "t", ":", "</", "td", "><", "td", ">", "%", "(", "trust", "\\u", "root", ")", "s", "</", "td", "><", "/", "tr", ">", "\\", "10", ";", " ", " ", " ", " ", "</", "table", ">", "\\", "10", ";", " ", " ", " ", " ", "<", "p", ">", "All", "ow", " ", "this", " ", "authenticat", "ion", " ", "to", " ", "proceed", "?<", "/", "p", ">", "\\", "10", ";", " ", " ", " ", " ", "<", "form", " ", "method", "=\"", "POST", "\"", " ", "action", "=\"", "/", "allow", "\">", "\\", "10", ";", " ", " ", " ", " ", " ", " ", "<", "input", " ", "type", "=\"", "checkb", "ox", "\"", " ", "id", "=\"", "remember", "\"", " ", "name", "=\"", "remember", "\"", " ", "value", "=\"", "ye", "s", "\"", "\\", "10", ";", " ", " ", " ", " ", " ", " ", "/>", "<", "label", " ", "for", "=\"", "remember", "\">", "Reme", "mber", " ", "this", "\\", "10", ";", " ", " ", " ", " ", " ", " ", "decision", "</", "label", "><", "br", " ", "/>", "\\", "10", ";", " ", " ", " ", " ", " ", " ", "<", "input", " ", "type", "=\"", "submit", "\"", " ", "name", "=\"", "ye", "s", "\"", " ", "value", "=\"", "ye", "s", "\"", " ", "/>", "\\", "10", ";", " ", " ", " ", " ", " ", " ", "<", "input", " ", "type", "=\"", "submit", "\"", " ", "name", "=\"", "no", "\"", " ", "value", "=\"", "no", "\"", " ", "/>", "\\", "10", ";", " ", " ", " ", " ", "</", "form", ">'''_", "%_", "fdata", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "mdat", "a_", "=_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "'", "expected", "\\u", "user", "'_", ":_", "expected", "\\u", "user_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "user", "'_", ":_", "self_", "._", "user_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "msg_", "=_", "'''", "\\\\", "\\", "10", ";", " ", " ", " ", " ", "<", "p", ">", "A", " ", "site", " ", "has", " ", "ask", "ed", " ", "for", " ", "an", " ", "identi", "ty", " ", "belonging", " ", "to", "\\", "10", ";", " ", " ", " ", " ", "%", "(", "expected", "\\u", "user", ")", "s", ",", " ", "but", " ", "you", " ", "are", " ", "logged", " ", "in", " ", "as", " ", "%", "(", "user", ")", "s", ".", " ", " ", "To", "\\", "10", ";", " ", " ", " ", " ", "log", " ", "in", " ", "as", " ", "%", "(", "expected", "\\u", "user", ")", "s", " ", "and", " ", "approve", " ", "the", " ", "login", " ", "request", ",", "\\", "10", ";", " ", " ", " ", " ", "hit", " ", "OK", " ", "belo", "w", ".", " ", " ", "The", " ", "\"", "Reme", "mber", " ", "this", " ", "decision", "\"", " ", "checkb", "ox", "\\", "10", ";", " ", " ", " ", " ", "appli", "es", " ", "only", " ", "to", " ", "the", " ", "trust", " ", "root", " ", "decision", ".", "</", "p", ">'''_", "%_", "mdat", "a_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "fdata", "_", "=_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "'", "identi", "ty", "'_", ":_", "request_", "._", "identity_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "trust", "\\u", "root", "'_", ":_", "request_", "._", "trust", "\\u", "root_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "expected", "\\u", "user", "'_", ":_", "expected", "\\u", "user_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "form_", "=_", "'''", "\\\\", "\\", "10", ";", " ", " ", " ", " ", "<", "table", ">", "\\", "10", ";", " ", " ", " ", " ", " ", " ", "<", "tr", "><", "td", ">", "Ident", "it", "y", ":", "</", "td", "><", "td", ">", "%", "(", "identi", "ty", ")", "s", "</", "td", "><", "/", "tr", ">", "\\", "10", ";", " ", " ", " ", " ", " ", " ", "<", "tr", "><", "td", ">", "Trust", " ", "Roo", "t", ":", "</", "td", "><", "td", ">", "%", "(", "trust", "\\u", "root", ")", "s", "</", "td", "><", "/", "tr", ">", "\\", "10", ";", " ", " ", " ", " ", "</", "table", ">", "\\", "10", ";", " ", " ", " ", " ", "<", "p", ">", "All", "ow", " ", "this", " ", "authenticat", "ion", " ", "to", " ", "proceed", "?<", "/", "p", ">", "\\", "10", ";", " ", " ", " ", " ", "<", "form", " ", "method", "=\"", "POST", "\"", " ", "action", "=\"", "/", "allow", "\">", "\\", "10", ";", " ", " ", " ", " ", " ", " ", "<", "input", " ", "type", "=\"", "checkb", "ox", "\"", " ", "id", "=\"", "remember", "\"", " ", "name", "=\"", "remember", "\"", " ", "value", "=\"", "ye", "s", "\"", "\\", "10", ";", " ", " ", " ", " ", " ", " ", "/>", "<", "label", " ", "for", "=\"", "remember", "\">", "Reme", "mber", " ", "this", "\\", "10", ";", " ", " ", " ", " ", " ", " ", "decision", "</", "label", "><", "br", " ", "/>", "\\", "10", ";", " ", " ", " ", " ", " ", " ", "<", "input", " ", "type", "=\"", "hidden", "\"", " ", "name", "=\"", "login", "\\u", "as", "\"", " ", "value", "=\"", "%", "(", "expected", "\\u", "user", ")", "s", "\"/>", "\\", "10", ";", " ", " ", " ", " ", " ", " ", "<", "input", " ", "type", "=\"", "submit", "\"", " ", "name", "=\"", "ye", "s", "\"", " ", "value", "=\"", "ye", "s", "\"", " ", "/>", "\\", "10", ";", " ", " ", " ", " ", " ", " ", "<", "input", " ", "type", "=\"", "submit", "\"", " ", "name", "=\"", "no", "\"", " ", "value", "=\"", "no", "\"", " ", "/>", "\\", "10", ";", " ", " ", " ", " ", "</", "form", ">'''_", "%_", "fdata", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "show", "Page_", "(_", "200_", ",_", "'", "Appro", "ve", " ", "Open", "ID", " ", "request", "?'_", ",_", "msg_", "=_", "msg_", ",_", "form_", "=_", "form_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Server", "Handler_", "(_", "Base", "HTTP", "Request", "Handler_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "show", "Id", "Page_", "(_", "self_", ",_", "path_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "link", "\\u", "tag_", "=_", "'<", "link", " ", "rel", "=\"", "openid", ".", "server", "\"", " ", "href", "=\"", "%", "sop", "eni", "dse", "rver", "\">'_", "%_", "self_", "._", "server_", "._", "base", "\\u", "url_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "ya", "dis", "\\u", "loc", "\\u", "tag_", "=_", "'<", "meta", " ", "http", "-", "equiv", "=\"", "x", "-", "xr", "ds", "-", "location", "\"", " ", "content", "=\"", "%", "s", "\">'_", "%_", "(_", "self_", "._", "server_", "._", "base", "\\u", "url_", "+_", "'", "ya", "dis", "/'_", "+_", "path_", "[_", "4_", ":_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "disco", "\\u", "tags_", "=_", "link", "\\u", "tag_", "+_", "ya", "dis", "\\u", "loc", "\\u", "tag_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "ident_", "=_", "self_", "._", "server_", "._", "base", "\\u", "url_", "+_", "path_", "[_", "1_", ":_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "approved", "\\u", "trust", "\\u", "roots_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "(_", "aid", "ent_", ",_", "trust", "\\u", "root_", ")_", "in_", "self_", "._", "server_", "._", "approved", "_", "._", "keys_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "aid", "ent_", "==_", "ident_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "trs_", "=_", "'<", "li", "><", "tt", ">", "%", "s", "</", "tt", "><", "/", "li", ">\\\\", "n", "'_", "%_", "cgi_", "._", "escape_", "(_", "trust", "\\u", "root_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "approved", "\\u", "trust", "\\u", "roots_", "._", "append_", "(_", "trs_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "approved", "\\u", "trust", "\\u", "roots_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "prepend", "_", "=_", "'<", "p", ">", "Appro", "ved", " ", "trust", " ", "root", "s", ":", "</", "p", ">\\\\", "n", "<", "ul", ">\\\\", "n", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "approved", "\\u", "trust", "\\u", "roots_", "._", "insert_", "(_", "0_", ",_", "prepend", "_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "approved", "\\u", "trust", "\\u", "roots_", "._", "append_", "(_", "'<", "/", "ul", ">\\\\", "n", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "msg_", "=_", "''_", "._", "join_", "(_", "approved", "\\u", "trust", "\\u", "roots_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "msg_", "=_", "''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "show", "Page_", "(_", "200_", ",_", "'", "An", " ", "Ident", "it", "y", " ", "Page", "'_", ",_", "head", "\\u", "extras_", "=_", "disco", "\\u", "tags_", ",_", "msg_", "=_", "'''", "\\\\", "\\", "10", ";", " ", " ", " ", " ", "<", "p", ">", "Thi", "s", " ", "is", " ", "an", " ", "identi", "ty", " ", "page", " ", "for", " ", "%", "s", ".", "</", "p", ">", "\\", "10", ";", " ", " ", " ", " ", "%", "s", "\\", "10", ";", " ", " ", " ", " ", "'''_", "%_", "(_", "ident_", ",_", "msg_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Server", "Handler_", "(_", "Base", "HTTP", "Request", "Handler_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "show", "Ya", "dis_", "(_", "self_", ",_", "user_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "send", "\\u", "response_", "(_", "200_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "send", "\\u", "header_", "(_", "'", "Conten", "t", "-", "type", "'_", ",_", "'", "applica", "tion", "/", "xr", "ds", "+", "xml", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "end", "\\u", "headers_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "endpoint", "\\u", "url_", "=_", "self_", "._", "server_", "._", "base", "\\u", "url_", "+_", "'", "openid", "server", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "user", "\\u", "url_", "=_", "self_", "._", "server_", "._", "base", "\\u", "url_", "+_", "'", "id", "/'_", "+_", "user_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "wfile_", "._", "write_", "(_", "\"\"\"", "\\\\", "\\", "10", ";<", "?", "xml", " ", "version", "=\"", "1.0", "\"", " ", "encoding", "=\"", "UT", "F", "-", "8", "\"?", ">", "\\", "10", ";<", "xr", "ds", ":", "XR", "DS", "\\", "10", ";", " ", " ", " ", " ", "xml", "ns", ":", "xr", "ds", "=\"", "xr", "i", "://", "$", "xr", "ds", "\"", "\\", "10", ";", " ", " ", " ", " ", "xml", "ns", "=\"", "xr", "i", "://", "$", "xr", "d", "*(", "$", "v", "*", "2.0", ")\"", ">", "\\", "10", ";", " ", " ", "<", "XR", "D", ">", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "<", "Service", " ", "priorit", "y", "=\"", "0", "\">", "\\", "10", ";", " ", " ", "<", "Type", ">", "%", "s", "</", "Type", ">", "\\", "10", ";", " ", " ", "<", "Type", ">", "%", "s", "</", "Type", ">", "\\", "10", ";", " ", " ", "<", "URI", ">", "%", "s", "</", "URI", ">", "\\", "10", ";", " ", " ", "<", "Local", "ID", ">", "%", "s", "</", "Local", "ID", ">", "\\", "10", ";", " ", " ", " ", " ", "</", "Service", ">", "\\", "10", ";", "\\", "10", ";", " ", " ", "</", "XR", "D", ">", "\\", "10", ";<", "/", "xr", "ds", ":", "XR", "DS", ">", "\\", "10", ";\"\"\"_", "%_", "(_", "discover_", "._", "OPEN", "ID", "\\u", "2", "\\u", "0", "\\u", "TYPE_", ",_", "discover_", "._", "OPEN", "ID", "\\u", "1", "\\u", "0", "\\u", "TYPE_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "endpoint", "\\u", "url_", ",_", "user", "\\u", "url_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Server", "Handler_", "(_", "Base", "HTTP", "Request", "Handler_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "show", "Server", "Ya", "dis_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "send", "\\u", "response_", "(_", "200_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "send", "\\u", "header_", "(_", "'", "Conten", "t", "-", "type", "'_", ",_", "'", "applica", "tion", "/", "xr", "ds", "+", "xml", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "end", "\\u", "headers_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "endpoint", "\\u", "url_", "=_", "self_", "._", "server_", "._", "base", "\\u", "url_", "+_", "'", "openid", "server", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "wfile_", "._", "write_", "(_", "\"\"\"", "\\\\", "\\", "10", ";<", "?", "xml", " ", "version", "=\"", "1.0", "\"", " ", "encoding", "=\"", "UT", "F", "-", "8", "\"?", ">", "\\", "10", ";<", "xr", "ds", ":", "XR", "DS", "\\", "10", ";", " ", " ", " ", " ", "xml", "ns", ":", "xr", "ds", "=\"", "xr", "i", "://", "$", "xr", "ds", "\"", "\\", "10", ";", " ", " ", " ", " ", "xml", "ns", "=\"", "xr", "i", "://", "$", "xr", "d", "*(", "$", "v", "*", "2.0", ")\"", ">", "\\", "10", ";", " ", " ", "<", "XR", "D", ">", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "<", "Service", " ", "priorit", "y", "=\"", "0", "\">", "\\", "10", ";", " ", " ", "<", "Type", ">", "%", "s", "</", "Type", ">", "\\", "10", ";", " ", " ", "<", "URI", ">", "%", "s", "</", "URI", ">", "\\", "10", ";", " ", " ", " ", " ", "</", "Service", ">", "\\", "10", ";", "\\", "10", ";", " ", " ", "</", "XR", "D", ">", "\\", "10", ";<", "/", "xr", "ds", ":", "XR", "DS", ">", "\\", "10", ";\"\"\"_", "%_", "(_", "discover_", "._", "OPEN", "ID", "\\u", "ID", "P", "\\u", "2", "\\u", "0", "\\u", "TYPE_", ",_", "endpoint", "\\u", "url_", ",_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Server", "Handler_", "(_", "Base", "HTTP", "Request", "Handler_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "show", "Main", "Page_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "ya", "dis", "\\u", "tag_", "=_", "'<", "meta", " ", "http", "-", "equiv", "=\"", "x", "-", "xr", "ds", "-", "location", "\"", " ", "content", "=\"", "%", "s", "\">'_", "%_", "(_", "self_", "._", "server_", "._", "base", "\\u", "url_", "+_", "'", "server", "ya", "dis", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "self_", "._", "user_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "openid", "\\u", "url_", "=_", "self_", "._", "server_", "._", "base", "\\u", "url_", "+_", "'", "id", "/'_", "+_", "self_", "._", "user_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "user", "\\u", "message_", "=_", "\"\"\"", "\\\\", "\\", "10", ";", " ", " ", " ", " ", "<", "p", ">", "You", " ", "are", " ", "logged", " ", "in", " ", "as", " ", "%", "s", ".", " ", "You", "r", " ", "Open", "ID", " ", "identi", "ty", " ", "URL", " ", "is", "\\", "10", ";", " ", " ", " ", " ", "<", "tt", "><", "a", " ", "href", "=", "%", "s", ">", "%", "s", "</", "a", "><", "/", "tt", ">.", " ", "Enter", " ", "tha", "t", " ", "URL", " ", "at", " ", "an", " ", "Open", "ID", "\\", "10", ";", " ", " ", " ", " ", "consume", "r", " ", "to", " ", "test", " ", "this", " ", "server", ".", "</", "p", ">", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "%_", "(_", "self_", "._", "user_", ",_", "quote", "attr_", "(_", "openid", "\\u", "url_", ")_", ",_", "openid", "\\u", "url_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "user", "\\u", "message_", "=_", "\"\"\"", "\\\\", "\\", "10", ";", " ", " ", " ", " ", "<", "p", ">", "Thi", "s", " ", "server", " ", "use", "s", " ", "a", " ", "cookie", " ", "to", " ", "remember", " ", "who", " ", "you", " ", "are", " ", "in", "\\", "10", ";", " ", " ", " ", " ", "order", " ", "to", " ", "simulat", "e", " ", "a", " ", "standard", " ", "Web", " ", "user", " ", "experience", ".", " ", "You", " ", "are", "\\", "10", ";", " ", " ", " ", " ", "not", " ", "<", "a", " ", "href", "='", "/", "login", "'>", "logged", " ", "in", "</", "a", ">.", "</", "p", ">\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "show", "Page_", "(_", "200_", ",_", "'", "Main", " ", "Page", "'_", ",_", "head", "\\u", "extras_", "=_", "ya", "dis", "\\u", "tag_", ",_", "msg_", "=_", "'''", "\\\\", "\\", "10", ";", " ", " ", " ", " ", "<", "p", ">", "Thi", "s", " ", "is", " ", "a", " ", "simple", " ", "Open", "ID", " ", "server", " ", "implemented", " ", "usi", "ng", " ", "the", " ", "<", "a", "\\", "10", ";", " ", " ", " ", " ", "href", "=\"", "http", "://", "openid", ".", "sch", "tuf", "f", ".", "com", "/\"", ">", "Pyth", "on", " ", "Open", "ID", "\\", "10", ";", " ", " ", " ", " ", "librar", "y", "</", "a", ">.", "</", "p", ">", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "%", "s", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "<", "p", ">", "To", " ", "use", " ", "this", " ", "server", " ", "with", " ", "a", " ", "consume", "r", ",", " ", "the", " ", "consume", "r", " ", "must", " ", "be", "\\", "10", ";", " ", " ", " ", " ", "able", " ", "to", " ", "fetch", " ", "HTTP", " ", "page", "s", " ", "from", " ", "this", " ", "web", " ", "server", ".", " ", "If", " ", "this", "\\", "10", ";", " ", " ", " ", " ", "computer", " ", "is", " ", "beh", "ind", " ", "a", " ", "firew", "all", ",", " ", "you", " ", "will", " ", "not", " ", "be", " ", "able", " ", "to", " ", "use", "\\", "10", ";", " ", " ", " ", " ", "Open", "ID", " ", "consumers", " ", "outsi", "de", " ", "of", " ", "the", " ", "firew", "all", " ", "with", " ", "it", ".", "</", "p", ">", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "<", "p", ">", "The", " ", "URL", " ", "for", " ", "this", " ", "server", " ", "is", " ", "<", "a", " ", "href", "=", "%", "s", "><", "tt", ">", "%", "s", "</", "tt", "><", "/", "a", ">.", "</", "p", ">", "\\", "10", ";", " ", " ", " ", " ", "'''_", "%_", "(_", "user", "\\u", "message_", ",_", "quote", "attr_", "(_", "self_", "._", "server_", "._", "base", "\\u", "url_", ")_", ",_", "self_", "._", "server_", "._", "base", "\\u", "url_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Server", "Handler_", "(_", "Base", "HTTP", "Request", "Handler_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "show", "Logi", "n", "Page_", "(_", "self_", ",_", "success", "\\u", "to_", ",_", "fail", "\\u", "to_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "show", "Page_", "(_", "200_", ",_", "'", "Logi", "n", " ", "Page", "'_", ",_", "form_", "=_", "'''", "\\\\", "\\", "10", ";", " ", " ", " ", " ", "<", "h2", ">", "Logi", "n", "</", "h2", ">", "\\", "10", ";", " ", " ", " ", " ", "<", "p", ">", "You", " ", "may", " ", "log", " ", "in", " ", "with", " ", "any", " ", "name", ".", " ", "Thi", "s", " ", "server", " ", "doe", "s", " ", "not", " ", "use", "\\", "10", ";", " ", " ", " ", " ", "passwords", " ", "bec", "aus", "e", " ", "it", " ", "is", " ", "just", " ", "a", " ", "sample", " ", "of", " ", "how", " ", "to", " ", "use", " ", "the", " ", "Open", "ID", "\\", "10", ";", " ", " ", " ", " ", "librar", "y", ".", "</", "p", ">", "\\", "10", ";", " ", " ", " ", " ", "<", "form", " ", "method", "=\"", "GET", "\"", " ", "action", "=\"", "/", "login", "submit", "\">", "\\", "10", ";", " ", " ", "<", "input", " ", "type", "=\"", "hidden", "\"", " ", "name", "=\"", "success", "\\u", "to", "\"", " ", "value", "=\"", "%", "s", "\"", " ", "/>", "\\", "10", ";", " ", " ", "<", "input", " ", "type", "=\"", "hidden", "\"", " ", "name", "=\"", "fail", "\\u", "to", "\"", " ", "value", "=\"", "%", "s", "\"", " ", "/>", "\\", "10", ";", " ", " ", "<", "input", " ", "type", "=\"", "text", "\"", " ", "name", "=\"", "user", "\"", " ", "value", "=\"\"", " ", "/>", "\\", "10", ";", " ", " ", "<", "input", " ", "type", "=\"", "submit", "\"", " ", "name", "=\"", "submit", "\"", " ", "value", "=\"", "Log", " ", "In", "\"", " ", "/>", "\\", "10", ";", " ", " ", "<", "input", " ", "type", "=\"", "submit", "\"", " ", "name", "=\"", "cancel", "\"", " ", "value", "=\"", "Cancel", "\"", " ", "/>", "\\", "10", ";", " ", " ", " ", " ", "</", "form", ">", "\\", "10", ";", " ", " ", " ", " ", "'''_", "%_", "(_", "success", "\\u", "to_", ",_", "fail", "\\u", "to_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Server", "Handler_", "(_", "Base", "HTTP", "Request", "Handler_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "show", "Page_", "(_", "self_", ",_", "response", "\\u", "code_", ",_", "title_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "head", "\\u", "extras_", "=_", "''_", ",_", "msg_", "=_", "None_", ",_", "err_", "=_", "None_", ",_", "form_", "=_", "None_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "self_", "._", "user_", "is_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "user", "\\u", "link_", "=_", "'<", "a", " ", "href", "=\"", "/", "login", "\">", "not", " ", "logged", " ", "in", "</", "a", ">.", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "user", "\\u", "link_", "=_", "'", "logged", " ", "in", " ", "as", " ", "<", "a", " ", "href", "=\"", "/", "id", "/", "%", "s", "\">", "%", "s", "</", "a", ">.", "<", "br", " ", "/>", "<", "a", " ", "href", "=\"", "/", "login", "submit", "?", "submit", "=", "true", "&", "success", "\\u", "to", "=", "/", "login", "\">", "Log", " ", "out", "</", "a", ">'_", "%_", "(_", "self_", "._", "user_", ",_", "self_", "._", "user_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "body_", "=_", "''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "err_", "is_", "not_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "body_", "+=_", "'''", "\\\\", "\\", "10", ";", " ", " ", " ", " ", "<", "div", " ", "class", "=\"", "error", "\">", "\\", "10", ";", " ", " ", " ", " ", " ", " ", "%", "s", "\\", "10", ";", " ", " ", " ", " ", "</", "div", ">", "\\", "10", ";", " ", " ", " ", " ", "'''_", "%_", "err_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "msg_", "is_", "not_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "body_", "+=_", "'''", "\\\\", "\\", "10", ";", " ", " ", " ", " ", "<", "div", " ", "class", "=\"", "message", "\">", "\\", "10", ";", " ", " ", " ", " ", " ", " ", "%", "s", "\\", "10", ";", " ", " ", " ", " ", "</", "div", ">", "\\", "10", ";", " ", " ", " ", " ", "'''_", "%_", "msg_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "form_", "is_", "not_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "body_", "+=_", "'''", "\\\\", "\\", "10", ";", " ", " ", " ", " ", "<", "div", " ", "class", "=\"", "form", "\">", "\\", "10", ";", " ", " ", " ", " ", " ", " ", "%", "s", "\\", "10", ";", " ", " ", " ", " ", "</", "div", ">", "\\", "10", ";", " ", " ", " ", " ", "'''_", "%_", "form_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "contents_", "=_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "'", "title", "'_", ":_", "'", "Pyth", "on", " ", "Open", "ID", " ", "Server", " ", "Exam", "ple", " ", "-", " ", "'_", "+_", "title_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "head", "\\u", "extra", "s", "'_", ":_", "head", "\\u", "extras_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "body", "'_", ":_", "body_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "user", "\\u", "link", "'_", ":_", "user", "\\u", "link_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "send", "\\u", "response_", "(_", "response", "\\u", "code_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "write", "User", "Header_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "send", "\\u", "header_", "(_", "'", "Conten", "t", "-", "type", "'_", ",_", "'", "text", "/", "html", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "end", "\\u", "headers_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "wfile_", "._", "write_", "(_", "'''", "<", "html", ">", "\\", "10", ";", " ", " ", "<", "head", ">", "\\", "10", ";", " ", " ", " ", " ", "<", "title", ">", "%", "(", "title", ")", "s", "</", "title", ">", "\\", "10", ";", " ", " ", " ", " ", "%", "(", "head", "\\u", "extra", "s", ")", "s", "\\", "10", ";", " ", " ", "</", "head", ">", "\\", "10", ";", " ", " ", "<", "style", " ", "type", "=\"", "text", "/", "css", "\">", "\\", "10", ";", " ", " ", "h1", " ", "a", ":", "link", " ", "{", "\\", "10", ";", " ", " ", "color", ":", " ", "black", ";", "\\", "10", ";", " ", " ", "text", "-", "decorat", "ion", ":", " ", "none", ";", "\\", "10", ";", " ", " ", "}", "\\", "10", ";", " ", " ", "h1", " ", "a", ":", "visit", "ed", " ", "{", "\\", "10", ";", " ", " ", "color", ":", " ", "black", ";", "\\", "10", ";", " ", " ", "text", "-", "decorat", "ion", ":", " ", "none", ";", "\\", "10", ";", " ", " ", "}", "\\", "10", ";", " ", " ", "h1", " ", "a", ":", "hover", " ", "{", "\\", "10", ";", " ", " ", "text", "-", "decorat", "ion", ":", " ", "underl", "ine", ";", "\\", "10", ";", " ", " ", "}", "\\", "10", ";", " ", " ", "body", " ", "{", "\\", "10", ";", " ", " ", " ", " ", "font", "-", "famil", "y", ":", " ", "verd", "ana", ",", "san", "s", "-", "seri", "f", ";", "\\", "10", ";", " ", " ", " ", " ", "widt", "h", ":", " ", "50", "em", ";", "\\", "10", ";", " ", " ", " ", " ", "marg", "in", ":", " ", "1e", "m", ";", "\\", "10", ";", " ", " ", "}", "\\", "10", ";", " ", " ", "div", " ", "{", "\\", "10", ";", " ", " ", " ", " ", "padd", "ing", ":", " ", ".5", "em", ";", "\\", "10", ";", " ", " ", "}", "\\", "10", ";", " ", " ", "table", " ", "{", "\\", "10", ";", " ", " ", " ", " ", "marg", "in", ":", " ", "none", ";", "\\", "10", ";", " ", " ", " ", " ", "padd", "ing", ":", " ", "none", ";", "\\", "10", ";", " ", " ", "}", "\\", "10", ";", " ", " ", ".", "banner", " ", "{", "\\", "10", ";", " ", " ", " ", " ", "padd", "ing", ":", " ", "none", " ", "1e", "m", " ", "1e", "m", " ", "1e", "m", ";", "\\", "10", ";", " ", " ", " ", " ", "widt", "h", ":", " ", "100", "%%", ";", "\\", "10", ";", " ", " ", "}", "\\", "10", ";", " ", " ", ".", "left", "banner", " ", "{", "\\", "10", ";", " ", " ", " ", " ", "text", "-", "align", ":", " ", "left", ";", "\\", "10", ";", " ", " ", "}", "\\", "10", ";", " ", " ", ".", "right", "banner", " ", "{", "\\", "10", ";", " ", " ", " ", " ", "text", "-", "align", ":", " ", "right", ";", "\\", "10", ";", " ", " ", " ", " ", "font", "-", "size", ":", " ", "small", "er", ";", "\\", "10", ";", " ", " ", "}", "\\", "10", ";", " ", " ", ".", "error", " ", "{", "\\", "10", ";", " ", " ", " ", " ", "border", ":", " ", "1p", "x", " ", "solid", " ", "#", "ff", "0000", ";", "\\", "10", ";", " ", " ", " ", " ", "background", ":", " ", "#", "ffa", "aaa", ";", "\\", "10", ";", " ", " ", " ", " ", "marg", "in", ":", " ", ".5", "em", ";", "\\", "10", ";", " ", " ", "}", "\\", "10", ";", " ", " ", ".", "message", " ", "{", "\\", "10", ";", " ", " ", " ", " ", "border", ":", " ", "1p", "x", " ", "solid", " ", "#", "223", "3f", "f", ";", "\\", "10", ";", " ", " ", " ", " ", "background", ":", " ", "#", "eeee", "ff", ";", "\\", "10", ";", " ", " ", " ", " ", "marg", "in", ":", " ", ".5", "em", ";", "\\", "10", ";", " ", " ", "}", "\\", "10", ";", " ", " ", ".", "form", " ", "{", "\\", "10", ";", " ", " ", " ", " ", "border", ":", " ", "1p", "x", " ", "solid", " ", "#", "777777", ";", "\\", "10", ";", " ", " ", " ", " ", "background", ":", " ", "#", "ddd", "dcc", ";", "\\", "10", ";", " ", " ", " ", " ", "marg", "in", ":", " ", ".5", "em", ";", "\\", "10", ";", " ", " ", " ", " ", "marg", "in", "-", "top", ":", " ", "1e", "m", ";", "\\", "10", ";", " ", " ", " ", " ", "padd", "ing", "-", "bottom", ":", " ", "0e", "m", ";", "\\", "10", ";", " ", " ", "}", "\\", "10", ";", " ", " ", "dd", " ", "{", "\\", "10", ";", " ", " ", " ", " ", "marg", "in", "-", "bottom", ":", " ", "0.", "5e", "m", ";", "\\", "10", ";", " ", " ", "}", "\\", "10", ";", " ", " ", "</", "style", ">", "\\", "10", ";", " ", " ", "<", "body", ">", "\\", "10", ";", " ", " ", " ", " ", "<", "table", " ", "class", "=\"", "banner", "\">", "\\", "10", ";", " ", " ", "<", "tr", ">", "\\", "10", ";", " ", " ", " ", " ", "<", "td", " ", "class", "=\"", "left", "banner", "\">", "\\", "10", ";", " ", " ", "<", "h1", "><", "a", " ", "href", "=\"", "/\"", ">", "Pyth", "on", " ", "Open", "ID", " ", "Server", " ", "Exam", "ple", "</", "a", "><", "/", "h1", ">", "\\", "10", ";", " ", " ", " ", " ", "</", "td", ">", "\\", "10", ";", " ", " ", " ", " ", "<", "td", " ", "class", "=\"", "right", "banner", "\">", "\\", "10", ";", " ", " ", "You", " ", "are", " ", "%", "(", "user", "\\u", "link", ")", "s", "\\", "10", ";", " ", " ", " ", " ", "</", "td", ">", "\\", "10", ";", " ", " ", "</", "tr", ">", "\\", "10", ";", " ", " ", " ", " ", "</", "table", ">", "\\", "10", ";", "%", "(", "body", ")", "s", "\\", "10", ";", " ", " ", "</", "body", ">", "\\", "10", ";<", "/", "html", ">", "\\", "10", ";'", "''_", "%_", "contents_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "main_", "(_", "host_", ",_", "port_", ",_", "data\\u", "path_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "addr_", "=_", "(_", "host_", ",_", "port_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "https", "erver_", "=_", "Open", "ID", "HTTP", "Server_", "(_", "addr_", ",_", "Server", "Handler_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Instantiate", " ", "Open", "ID", " ", "consume", "r", " ", "store", " ", "and", " ", "Open", "ID", " ", "consume", "r", ".", " ", " ", "If", " ", "you", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "wer", "e", " ", "connecti", "ng", " ", "to", " ", "a", " ", "databa", "se", ",", " ", "you", " ", "wou", "ld", " ", "create", " ", "the", " ", "database_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "connecti", "on", " ", "and", " ", "instantiate", " ", "an", " ", "appropr", "iate", " ", "store", " ", "here", "._", "\\u\\u\\uNL\\u\\u\\u_", "store_", "=_", "File", "Open", "IDS", "tore_", "(_", "data\\u", "path_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "oids", "erver_", "=_", "server_", "._", "Server_", "(_", "store_", ",_", "https", "erver_", "._", "base", "\\u", "url_", "+_", "'", "openid", "server", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "https", "erver_", "._", "set", "Open", "IDS", "erver_", "(_", "oids", "erver_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "print_", "'", "Server", " ", "runn", "ing", " ", "at", ":'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "print_", "https", "erver_", "._", "base", "\\u", "url_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "https", "erver_", "._", "serve", "\\u", "forever_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_" ]
[ 4, 4, 4, 4, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 ]
Unnecessary pass
NeuroVault/NeuroVault/scripts/add_pearson_similarity_metric.py
[ { "content": "'''\nCreated on 30 Jan 2015\n\n@author: vsochat\n'''\nimport os\nimport django\nos.environ.setdefault(\"DJANGO_SETTINGS_MODULE\", \"neurovault.settings\")\ndjango.setup()\n\nfrom neurovault.apps.statmaps.models import Similarity, Comparison, Image\nfrom neurovault.apps.statmaps.tasks import save_voxelwise_pearson_similarity\nfrom django.db import IntegrityError\nimport errno\n\n# First create the image similarity metric\npearson_metric = Similarity(similarity_metric=\"pearson product-moment correlation coefficient\",\n transformation=\"voxelwise\",\n metric_ontology_iri=\"http://webprotege.stanford.edu/RCS8W76v1MfdvskPLiOdPaA\",\n transformation_ontology_iri=\"http://webprotege.stanford.edu/R87C6eFjEftkceScn1GblDL\")\ntry:\n pearson_metric.save()\nexcept IntegrityError as exc:\n print \"A Similarity Metric has already been defined for %s\" %(pearson_metric)\n pass \n\n# Now, we need to generate a \"comparison\" object for all files in the database\n# We will use a celery task (as this will be integrated into upload workflow)\nfor image1 in Image.objects.filter(collection__private=False):\n for image2 in Image.objects.filter(collection__private=False):\n if image1.pk < image2.pk:\n print \"Calculating pearson similarity for images %s and %s\" %(image1,image2)\n save_voxelwise_pearson_similarity(image1.pk,image2.pk)\n", "metadata": "root", "header": "['module', '___EOS___']", "index": 0 } ]
[ { "span": "pass ", "start_line": 24, "start_column": 2, "end_line": 24, "end_column": 6 } ]
[]
1
true
[ "[CLS]_", "Un", "necessar", "y_", "pass_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "'''", "\\", "10", ";", "Creat", "ed", " ", "on", " ", "30", " ", "Jan", " ", "201", "5", "\\", "10", ";", "\\", "10", ";", "@", "author", ":", " ", "vs", "och", "at", "\\", "10", ";'", "''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "os_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "django_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "os_", "._", "environ_", "._", "setdefault_", "(_", "\"", "DJANGO", "\\u", "SETTING", "S", "\\u", "MODUL", "E", "\"_", ",_", "\"", "neuro", "vau", "lt", ".", "settings", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "django_", "._", "setup_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "from_", "neuro", "vault_", "._", "apps_", "._", "stat", "maps_", "._", "models_", "import_", "Simil", "arity_", ",_", "Compari", "son_", ",_", "Image_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "neuro", "vault_", "._", "apps_", "._", "stat", "maps_", "._", "tasks_", "import_", "save", "\\u", "voxel", "wis", "e\\u", "pearson", "\\u", "similarity_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "django_", "._", "db_", "import_", "Int", "egr", "it", "y", "Error_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "errno_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Fi", "rst", " ", "create", " ", "the", " ", "image", " ", "similar", "it", "y", " ", "metric_", "\\u\\u\\uNL\\u\\u\\u_", "pearson", "\\u", "metric_", "=_", "Simil", "arity_", "(_", "similar", "it", "y", "\\u", "metric_", "=_", "\"", "pearson", " ", "product", "-", "moment", " ", "correlation", " ", "coefficient", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "transformation_", "=_", "\"", "voxel", "wis", "e", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "metric", "\\u", "ontology", "\\u", "iri", "_", "=_", "\"", "http", "://", "webp", "rot", "ege", ".", "stan", "for", "d", ".", "edu", "/", "RC", "S", "8", "W", "7", "6", "v1", "Mf", "dv", "sk", "PL", "i", "Od", "Pa", "A", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "transformation", "\\u", "ontology", "\\u", "iri", "_", "=_", "\"", "http", "://", "webp", "rot", "ege", ".", "stan", "for", "d", ".", "edu", "/", "R", "87", "C6", "e", "Fj", "Ef", "tk", "ce", "Sc", "n1", "Gb", "l", "DL", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "pearson", "\\u", "metric_", "._", "save_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "Int", "egr", "it", "y", "Error_", "as_", "exc_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "print_", "\"", "A", " ", "Simil", "arit", "y", " ", "Met", "ric", " ", "has", " ", "alr", "ead", "y", " ", "bee", "n", " ", "defin", "ed", " ", "for", " ", "%", "s", "\"_", "%_", "(_", "pearson", "\\u", "metric_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "pass_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "No", "w", ",", " ", "we", " ", "need", " ", "to", " ", "generat", "e", " ", "a", " ", "\"", "compa", "ris", "on", "\"", " ", "object", " ", "for", " ", "all", " ", "files", " ", "in", " ", "the", " ", "database_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "We", " ", "will", " ", "use", " ", "a", " ", "celery", " ", "task", " ", "(", "as", " ", "this", " ", "will", " ", "be", " ", "integrated", " ", "int", "o", " ", "upload", " ", "workf", "low", ")_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "for_", "image1", "_", "in_", "Image_", "._", "objects_", "._", "filter_", "(_", "collection", "\\u\\u", "private_", "=_", "False_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "for_", "image2", "_", "in_", "Image_", "._", "objects_", "._", "filter_", "(_", "collection", "\\u\\u", "private_", "=_", "False_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "image1", "_", "._", "pk_", "<_", "image2", "_", "._", "pk_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "print_", "\"", "Calculating", " ", "pearson", " ", "similar", "it", "y", " ", "for", " ", "images", " ", "%", "s", " ", "and", " ", "%", "s", "\"_", "%_", "(_", "image1", "_", ",_", "image2", "_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "save", "\\u", "voxel", "wis", "e\\u", "pearson", "\\u", "similarity_", "(_", "image1", "_", "._", "pk_", ",_", "image2", "_", "._", "pk_", ")_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_" ]
[ 4, 4, 4, 4, 4, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 ]
Variable defined multiple times
kayhayen/Nuitka/nuitka/build/inline_copy/lib/scons-2.3.2/SCons/Tool/packaging/rpm.py
[ { "content": "def collectintargz(target, source, env):\n \"\"\" Puts all source files into a tar.gz file. \"\"\"\n # the rpm tool depends on a source package, until this is chagned\n # this hack needs to be here that tries to pack all sources in.\n sources = env.FindSourceFiles()\n\n # filter out the target we are building the source list for.\n #sources = [s for s in sources if not (s in target)]\n sources = [s for s in sources if s not in target]\n\n # find the .spec file for rpm and add it since it is not necessarily found\n # by the FindSourceFiles function.\n #sources.extend( [s for s in source if str(s).rfind('.spec')!=-1] )\n spec_file = lambda s: str(s).rfind('.spec') != -1\n sources.extend( list(filter(spec_file, source)) )\n\n # as the source contains the url of the source package this rpm package\n # is built from, we extract the target name\n #tarball = (str(target[0])+\".tar.gz\").replace('.rpm', '')\n tarball = (str(target[0])+\".tar.gz\").replace('.rpm', '')\n try:\n #tarball = env['SOURCE_URL'].split('/')[-1]\n tarball = env['SOURCE_URL'].split('/')[-1]\n except KeyError, e:\n raise SCons.Errors.UserError( \"Missing PackageTag '%s' for RPM packager\" % e.args[0] )\n\n tarball = src_targz.package(env, source=sources, target=tarball,\n PACKAGEROOT=env['PACKAGEROOT'], )\n\n return (target, tarball)", "metadata": "root.collectintargz", "header": "['module', '___EOS___']", "index": 86 } ]
[ { "span": "tarball ", "start_line": 105, "start_column": 4, "end_line": 105, "end_column": 11 } ]
[ { "span": "tarball ", "start_line": 108, "start_column": 8, "end_line": 108, "end_column": 15 } ]
1
true
[ "[CLS]_", "Variable_", "defined_", "multiple_", "times_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "collecti", "nta", "rg", "z_", "(_", "target_", ",_", "source_", ",_", "env_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", " ", "Put", "s", " ", "all", " ", "source", " ", "files", " ", "int", "o", " ", "a", " ", "tar", ".", "gz", " ", "file", ".", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "the", " ", "rpm", " ", "tool", " ", "depend", "s", " ", "on", " ", "a", " ", "source", " ", "package", ",", " ", "unti", "l", " ", "this", " ", "is", " ", "cha", "gned", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "this", " ", "hack", " ", "need", "s", " ", "to", " ", "be", " ", "here", " ", "tha", "t", " ", "trie", "s", " ", "to", " ", "pack", " ", "all", " ", "source", "s", " ", "in", "._", "\\u\\u\\uNL\\u\\u\\u_", "sources_", "=_", "env_", "._", "Fin", "d", "Sou", "rce", "Files_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "filter", " ", "out", " ", "the", " ", "target", " ", "we", " ", "are", " ", "buildi", "ng", " ", "the", " ", "source", " ", "list", " ", "for", "._", "\\u\\u\\uNL\\u\\u\\u_", "#", "source", "s", " ", "=", " ", "[", "s", " ", "for", " ", "s", " ", "in", " ", "source", "s", " ", "if", " ", "not", " ", "(", "s", " ", "in", " ", "target", ")]", "_", "\\u\\u\\uNL\\u\\u\\u_", "sources_", "=_", "[_", "s_", "for_", "s_", "in_", "sources_", "if_", "s_", "not_", "in_", "target_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "find", " ", "the", " ", ".", "spec", " ", "file", " ", "for", " ", "rpm", " ", "and", " ", "add", " ", "it", " ", "sinc", "e", " ", "it", " ", "is", " ", "not", " ", "necessar", "il", "y", " ", "found_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "by", " ", "the", " ", "Fin", "d", "Sou", "rce", "Files", " ", "function", "._", "\\u\\u\\uNL\\u\\u\\u_", "#", "source", "s", ".", "extend", "(", " ", "[", "s", " ", "for", " ", "s", " ", "in", " ", "source", " ", "if", " ", "str", "(", "s", ").", "rfi", "nd", "('.", "spec", "')", "!=", "-1", "]", " ", ")_", "\\u\\u\\uNL\\u\\u\\u_", "spec", "\\u", "file_", "=_", "lambda_", "s_", ":_", "str_", "(_", "s_", ")_", "._", "rfind_", "(_", "'.", "spec", "'_", ")_", "!=_", "-_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "sources_", "._", "extend_", "(_", "list_", "(_", "filter_", "(_", "spec", "\\u", "file_", ",_", "source_", ")_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "as", " ", "the", " ", "source", " ", "contain", "s", " ", "the", " ", "url", " ", "of", " ", "the", " ", "source", " ", "package", " ", "this", " ", "rpm", " ", "package_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "is", " ", "bui", "lt", " ", "from", ",", " ", "we", " ", "extract", " ", "the", " ", "target", " ", "name_", "\\u\\u\\uNL\\u\\u\\u_", "#", "tarball", " ", "=", " ", "(", "str", "(", "target", "[", "0", "])", "+\"", ".", "tar", ".", "gz", "\")", ".", "replace", "('.", "rpm", "',", " ", "''", ")_", "\\u\\u\\uNL\\u\\u\\u_", "tarball", "_", "=_", "(_", "str_", "(_", "target_", "[_", "0_", "]_", ")_", "+_", "\".", "tar", ".", "gz", "\"_", ")_", "._", "replace_", "(_", "'.", "rpm", "'_", ",_", "''_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", "tarball", " ", "=", " ", "env", "['", "SOU", "RC", "E", "\\u", "URL", "']", ".", "split", "('", "/'", ")[", "-1", "]_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "tarball", "_", "=_", "env_", "[_", "'", "SOU", "RC", "E", "\\u", "URL", "'_", "]_", "._", "split_", "(_", "'/'_", ")_", "[_", "-_", "1_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "Key", "Error_", ",_", "e_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "raise_", "SC", "ons_", "._", "Errors_", "._", "User", "Error_", "(_", "\"", "Missing", " ", "Packa", "ge", "Ta", "g", " ", "'%", "s", "'", " ", "for", " ", "RPM", " ", "package", "r", "\"_", "%_", "e_", "._", "args_", "[_", "0_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "tarball", "_", "=_", "src", "\\u", "targ", "z_", "._", "package_", "(_", "env_", ",_", "source_", "=_", "sources_", ",_", "target_", "=_", "tarball", "_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "PACKAG", "ERO", "OT", "_", "=_", "env_", "[_", "'", "PACKAG", "ERO", "OT", "'_", "]_", ",_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "return_", "(_", "target_", ",_", "tarball", "_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_" ]
[ 4, 4, 4, 4, 4, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,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 { "content": "# -*- coding: utf-8 -*-\n#\n# Piped documentation build configuration file, created by\n# sphinx-quickstart on Wed Apr 6 17:38:11 2011.\n#\n# This file is execfile()d with the current directory set to its containing dir.\n#\n# Note that not all possible configuration values are present in this\n# autogenerated file.\n#\n# All configuration values have a default; values that are commented out\n# serve to show the default.\n\nimport sys, os\n\n# If extensions (or modules to document with autodoc) are in another directory,\n# add these directories to sys.path here. If the directory is relative to the\n# documentation root, use os.path.abspath to make it absolute, like shown here.\n#sys.path.insert(0, os.path.abspath('.'))\n\n# -- General configuration -----------------------------------------------------\n\n# If your documentation needs a minimal Sphinx version, state it here.\n#needs_sphinx = '1.0'\n\n# Add any Sphinx extension module names here, as strings. They can be extensions\n# coming with Sphinx (named 'sphinx.ext.*') or your custom ones.\nextensions = ['sphinx.ext.autodoc', 'repoze.sphinx.autointerface',\n 'sphinx.ext.graphviz', 'sphinx.ext.intersphinx']\n\nautoclass_content = 'both'\n\ngraphviz_output_format = 'svg'\n\nintersphinx_mapping = dict(\n python = ('http://docs.python.org', None)\n)\n\nautodoc_default_flags = ['show-inheritance']\n\n# Add any paths that contain templates here, relative to this directory.\ntemplates_path = ['_templates']\n\n# The suffix of source filenames.\nsource_suffix = '.rst'\n\n# The encoding of source files.\n#source_encoding = 'utf-8-sig'\n\n# The master toctree document.\nmaster_doc = 'index'\n\n# General information about the project.\nproject = u'Piped'\ncopyright = u'2011-2012, Found IT A/S'\n\n# The version info for the project you're documenting, acts as replacement for\n# |version| and |release|, also used in various other places throughout the\n# built documents.\n#\n# The short X.Y version.\nversion = '0.4.5'\n# The full version, including alpha/beta/rc tags.\nrelease = '0.4.5'\n\n# The language for content autogenerated by Sphinx. Refer to documentation\n# for a list of supported languages.\n#language = None\n\n# There are two options for replacing |today|: either, you set today to some\n# non-false value, then it is used:\n#today = ''\n# Else, today_fmt is used as the format for a strftime call.\n#today_fmt = '%B %d, %Y'\n\n# List of patterns, relative to source directory, that match files and\n# directories to ignore when looking for source files.\nexclude_patterns = ['_build']\n\n# The reST default role (used for this markup: `text`) to use for all documents.\n#default_role = None\n\n# If true, '()' will be appended to :func: etc. cross-reference text.\n#add_function_parentheses = True\n\n# If true, the current module name will be prepended to all description\n# unit titles (such as .. function::).\n#add_module_names = True\n\n# If true, sectionauthor and moduleauthor directives will be shown in the\n# output. They are ignored by default.\n#show_authors = False\n\n# The name of the Pygments (syntax highlighting) style to use.\npygments_style = 'sphinx'\n\n# A list of ignored prefixes for module index sorting.\n#modindex_common_prefix = []\n\n\n# -- Options for HTML output ---------------------------------------------------\n\n# The theme to use for HTML and HTML Help pages. See the documentation for\n# a list of builtin themes.\n\nhtml_theme = 'default'\n#html_theme = 'werkzeug'\n\n# Theme options are theme-specific and customize the look and feel of a theme\n# further. For a list of options available for each theme, see the\n# documentation.\n#html_theme_options = {}\n\n# Add any paths that contain custom themes here, relative to this directory.\n#html_theme_path = []\n#html_theme_path = ['_themes']\n\n# The name for this set of Sphinx documents. If None, it defaults to\n# \"<project> v<release> documentation\".\n#html_title = None\n\n# A shorter title for the navigation bar. Default is the same as html_title.\n#html_short_title = None\n\n# The name of an image file (relative to this directory) to place at the top\n# of the sidebar.\n#html_logo = None\n\n# The name of an image file (within the static path) to use as favicon of the\n# docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32\n# pixels large.\n#html_favicon = None\n\n# Add any paths that contain custom static files (such as style sheets) here,\n# relative to this directory. They are copied after the builtin static files,\n# so a file named \"default.css\" will overwrite the builtin \"default.css\".\n#html_static_path = ['_static']\n\n# If not '', a 'Last updated on:' timestamp is inserted at every page bottom,\n# using the given strftime format.\n#html_last_updated_fmt = '%b %d, %Y'\n\n# If true, SmartyPants will be used to convert quotes and dashes to\n# typographically correct entities.\n#html_use_smartypants = True\n\n# Custom sidebar templates, maps document names to template names.\n#html_sidebars = {}\n\n# Additional templates that should be rendered to pages, maps page names to\n# template names.\n#html_additional_pages = {}\n\n# If false, no module index is generated.\n#html_domain_indices = True\n\n# If false, no index is generated.\n#html_use_index = True\n\n# If true, the index is split into individual pages for each letter.\n#html_split_index = False\n\n# If true, links to the reST sources are added to the pages.\n#html_show_sourcelink = True\n\n# If true, \"Created using Sphinx\" is shown in the HTML footer. Default is True.\n#html_show_sphinx = True\n\n# If true, \"(C) Copyright ...\" is shown in the HTML footer. Default is True.\n#html_show_copyright = True\n\n# If true, an OpenSearch description file will be output, and all pages will\n# contain a <link> tag referring to it. The value of this option must be the\n# base URL from which the finished HTML is served.\n#html_use_opensearch = ''\n\n# This is the file name suffix for HTML files (e.g. \".xhtml\").\n#html_file_suffix = None\n\n# Output file base name for HTML help builder.\nhtmlhelp_basename = 'Pipeddoc'\n\n\n# -- Options for LaTeX output --------------------------------------------------\n\n# The paper size ('letter' or 'a4').\n#latex_paper_size = 'letter'\n\n# The font size ('10pt', '11pt' or '12pt').\n#latex_font_size = '10pt'\n\n# Grouping the document tree into LaTeX files. List of tuples\n# (source start file, target name, title, author, documentclass [howto/manual]).\nlatex_documents = [\n ('index', 'Piped.tex', u'Piped Documentation',\n u'Found IT A/S', 'manual'),\n]\n\n# The name of an image file (relative to this directory) to place at the top of\n# the title page.\n#latex_logo = None\n\n# For \"manual\" documents, if this is true, then toplevel headings are parts,\n# not chapters.\n#latex_use_parts = False\n\n# If true, show page references after internal links.\n#latex_show_pagerefs = False\n\n# If true, show URL addresses after external links.\n#latex_show_urls = False\n\n# Additional stuff for the LaTeX preamble.\n#latex_preamble = ''\n\n# Documents to append as an appendix to all manuals.\n#latex_appendices = []\n\n# If false, no module index is generated.\n#latex_domain_indices = True\n\n\n# -- Options for manual page output --------------------------------------------\n\n# One entry per manual page. List of tuples\n# (source start file, name, description, authors, manual section).\nman_pages = [\n ('index', 'piped', u'Piped Documentation',\n [u'Found IT A/S'], 1)\n]", "metadata": "root", "header": "['module', '___EOS___']", "index": 0 } ]
[ { "span": "import sys, os", "start_line": 13, "start_column": 0, "end_line": 13, "end_column": 14 } ]
[]
1
false
[ "[CLS]_", "Un", "used_", "import_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "#", " ", "-*-", " ", "codi", "ng", ":", " ", "utf", "-", "8", " ", "-*-", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Pipe", "d", " ", "documentation", " ", "build", " ", "configura", "tion", " ", "file", ",", " ", "created", " ", "by_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "sphinx", "-", "quicks", "tart", " ", "on", " ", "We", "d", " ", "Ap", "r", " ", " ", "6", " ", "1", "7", ":", "3", "8", ":", "11", " ", "2011", "._", "\\u\\u\\uNL\\u\\u\\u_", "#", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Thi", "s", " ", "file", " ", "is", " ", "execfile", "()", "d", " ", "with", " ", "the", " ", "current", " ", "director", "y", " ", "set", " ", "to", " ", "its", " ", "contain", "ing", " ", "dir", "._", "\\u\\u\\uNL\\u\\u\\u_", "#", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Not", "e", " ", "tha", "t", " ", "not", " ", "all", " ", "possib", "le", " ", "configura", "tion", " ", "values", " ", "are", " ", "presen", "t", " ", "in", " ", "this_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "autogen", "erate", "d", " ", "file", "._", "\\u\\u\\uNL\\u\\u\\u_", "#", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "All", " ", "configura", "tion", " ", "values", " ", "have", " ", "a", " ", "default", ";", " ", "values", " ", "tha", "t", " ", "are", " ", "commente", "d", " ", "out_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "serve", " ", "to", " ", "show", " ", "the", " ", "default", "._", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "import_", "sys_", ",_", "os_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "If", " ", "extensi", "ons", " ", "(", "or", " ", "module", "s", " ", "to", " ", "document", " ", "with", " ", "autod", "oc", ")", " ", "are", " ", "in", " ", "anot", "her", " ", "director", "y", ",_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "add", " ", "these", " ", "director", "ies", " ", "to", " ", "sys", ".", "path", " ", "here", ".", " ", "If", " ", "the", " ", "director", "y", " ", "is", " ", "relative", " ", "to", " ", "the_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "documentation", " ", "root", ",", " ", "use", " ", "os", ".", "path", ".", "abs", "path", " ", "to", " ", "make", " ", "it", " ", "abs", "olute", ",", " ", "like", " ", "shown", " ", "here", "._", "\\u\\u\\uNL\\u\\u\\u_", "#", "sys", ".", "path", ".", "insert", "(", "0", ",", " ", "os", ".", "path", ".", "abs", "path", "('.", "'))", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "--", " ", "General", " ", "configura", "tion", " ", "--------------", "--------------", "--------------", "-----------", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "If", " ", "your", " ", "documentation", " ", "need", "s", " ", "a", " ", "minima", "l", " ", "Sph", "inx", " ", "version", ",", " ", "state", " ", "it", " ", "here", "._", "\\u\\u\\uNL\\u\\u\\u_", "#", "need", "s", "\\u", "sphinx", " ", "=", " ", "'", "1.0", "'_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Add", " ", "any", " ", "Sph", "inx", " ", "extensi", "on", " ", "module", " ", "names", " ", "here", ",", " ", "as", " ", "string", "s", ".", " ", "The", "y", " ", "can", " ", "be", " ", "extensions_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "comi", "ng", " ", "with", " ", "Sph", "inx", " ", "(", "named", " ", "'", "sphinx", ".", "ext", ".*", "')", " ", "or", " ", "your", " ", "custom", " ", "ones", "._", "\\u\\u\\uNL\\u\\u\\u_", "extensions_", "=_", "[_", "'", "sphinx", ".", "ext", ".", "autod", "oc", "'_", ",_", "'", "repo", "ze", ".", "sphinx", ".", "autoi", "nter", "face", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "sphinx", ".", "ext", ".", "graphviz", "'_", ",_", "'", "sphinx", ".", "ext", ".", "intersphinx", "'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "autocl", "ass", "\\u", "content_", "=_", "'", "bot", "h", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "graphviz", "\\u", "output", "\\u", "format_", "=_", "'", "svg", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "intersphinx", "\\u", "mapping_", "=_", "dict_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "python_", "=_", "(_", "'", "http", "://", "docs", ".", "python", ".", "org", "'_", ",_", "None_", ")_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "autod", "oc", "\\u", "default", "\\u", "flags_", "=_", "[_", "'", "show", "-", "inherita", "nce", "'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Add", " ", "any", " ", "path", "s", " ", "tha", "t", " ", "contain", " ", "template", "s", " ", "here", ",", " ", "relative", " ", "to", " ", "this", " ", "director", "y", "._", "\\u\\u\\uNL\\u\\u\\u_", "template", "s", "\\u", "path_", "=_", "[_", "'\\u", "template", "s", "'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "The", " ", "suff", "ix", " ", "of", " ", "source", " ", "filename", "s", "._", "\\u\\u\\uNL\\u\\u\\u_", "source", "\\u", "suffix_", "=_", "'.", "rst", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "The", " ", "encoding", " ", "of", " ", "source", " ", "files", "._", "\\u\\u\\uNL\\u\\u\\u_", "#", "source", "\\u", "encoding", " ", "=", " ", "'", "utf", "-", "8", "-", "sig", "'_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "The", " ", "master", " ", "toc", "tree", " ", "document", "._", "\\u\\u\\uNL\\u\\u\\u_", "master", "\\u", "doc_", "=_", "'", "index", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "General", " ", "informati", "on", " ", "abo", "ut", " ", "the", " ", "project", "._", "\\u\\u\\uNL\\u\\u\\u_", "project_", "=_", "u", "'", "Pipe", "d", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "copyright_", "=_", "u", "'", "2011", "-", "2012", ",", " ", "Foun", "d", " ", "IT", " ", "A", "/", "S", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "The", " ", "version", " ", "info", " ", "for", " ", "the", " ", "project", " ", "you", "'", "re", " ", "document", "ing", ",", " ", "acts", " ", "as", " ", "replace", "ment", " ", "for_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "|", "version", "|", " ", "and", " ", "|", "release", "|", ",", " ", "als", "o", " ", "used", " ", "in", " ", "vari", "ous", " ", "other", " ", "place", "s", " ", "through", "out", " ", "the_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "bui", "lt", " ", "document", "s", "._", "\\u\\u\\uNL\\u\\u\\u_", "#", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "The", " ", "short", " ", "X", ".", "Y", " ", "version", "._", "\\u\\u\\uNL\\u\\u\\u_", "version_", "=_", "'", "0.", "4.5", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "The", " ", "full", " ", "version", ",", " ", "inclu", "ding", " ", "alpha", "/", "beta", "/", "rc", " ", "tags", "._", "\\u\\u\\uNL\\u\\u\\u_", "release_", "=_", "'", "0.", "4.5", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "The", " ", "language", " ", "for", " ", "content", " ", "autogen", "erate", "d", " ", "by", " ", "Sph", "inx", ".", " ", "Refer", " ", "to", " ", "documentation", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "for", " ", "a", " ", "list", " ", "of", " ", "support", "ed", " ", "language", "s", "._", "\\u\\u\\uNL\\u\\u\\u_", "#", "language", " ", "=", " ", "None_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "There", " ", "are", " ", "two", " ", "options", " ", "for", " ", "repla", "cing", " ", "|", "toda", "y", "|", ":", " ", "eit", "her", ",", " ", "you", " ", "set", " ", "toda", "y", " ", "to", " ", "some", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "non", "-", "fal", "se", " ", "value", ",", " ", "then", " ", "it", " ", "is", " ", "used", ":_", "\\u\\u\\uNL\\u\\u\\u_", "#", "toda", "y", " ", "=", " ", "''_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Else", ",", " ", "toda", "y", "\\u", "fmt", " ", "is", " ", "used", " ", "as", " ", "the", " ", "format", " ", "for", " ", "a", " ", "strf", "time", " ", "call", "._", "\\u\\u\\uNL\\u\\u\\u_", "#", "toda", "y", "\\u", "fmt", " ", "=", " ", "'%", "B", " ", "%", "d", ",", " ", "%", "Y", "'_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "List", " ", "of", " ", "pattern", "s", ",", " ", "relative", " ", "to", " ", "source", " ", "director", "y", ",", " ", "tha", "t", " ", "match", " ", "files", " ", "and_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "director", "ies", " ", "to", " ", "ignore", " ", "whe", "n", " ", "look", "ing", " ", "for", " ", "source", " ", "files", "._", "\\u\\u\\uNL\\u\\u\\u_", "exclu", "de", "\\u", "patterns_", "=_", "[_", "'\\u", "build", "'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "The", " ", "re", "ST", " ", "default", " ", "role", " ", "(", "used", " ", "for", " ", "this", " ", "markup", ":", " ", "`", "text", "`)", " ", "to", " ", "use", " ", "for", " ", "all", " ", "document", "s", "._", "\\u\\u\\uNL\\u\\u\\u_", "#", "default", "\\u", "role", " ", "=", " ", "None_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "If", " ", "true", ",", " ", "'(", ")'", " ", "will", " ", "be", " ", "append", "ed", " ", "to", " ", ":", "func", ":", " ", "etc", ".", " ", "cross", "-", "reference", " ", "text", "._", "\\u\\u\\uNL\\u\\u\\u_", "#", "add", "\\u", "function", "\\u", "parenthes", "es", " ", "=", " ", "True_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "If", " ", "true", ",", " ", "the", " ", "current", " ", "module", " ", "name", " ", "will", " ", "be", " ", "prepend", "ed", " ", "to", " ", "all", " ", "description_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "unit", " ", "titles", " ", "(", "suc", "h", " ", "as", " ", "..", " ", "function", "::", ").", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", "add", "\\u", "module", "\\u", "names", " ", "=", " ", "True_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "If", " ", "true", ",", " ", "section", "author", " ", "and", " ", "module", "author", " ", "directive", "s", " ", "will", " ", "be", " ", "shown", " ", "in", " ", "the_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "output", ".", " ", "The", "y", " ", "are", " ", "ignore", "d", " ", "by", " ", "default", "._", "\\u\\u\\uNL\\u\\u\\u_", "#", "show", "\\u", "author", "s", " ", "=", " ", "False_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "The", " ", "name", " ", "of", " ", "the", " ", "Pyg", "ment", "s", " ", "(", "synta", "x", " ", "highlight", "ing", ")", " ", "style", " ", "to", " ", "use", "._", "\\u\\u\\uNL\\u\\u\\u_", "pyg", "ment", "s", "\\u", "style_", "=_", "'", "sphinx", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "A", " ", "list", " ", "of", " ", "ignore", "d", " ", "prefix", "es", " ", "for", " ", "module", " ", "index", " ", "sorting", "._", "\\u\\u\\uNL\\u\\u\\u_", "#", "modi", "nde", "x", "\\u", "common", "\\u", "prefix", " ", "=", " ", "[]", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "--", " ", "Optio", "ns", " ", "for", " ", "HTM", "L", " ", "output", " ", "--------------", "--------------", "--------------", "---------", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "The", " ", "them", "e", " ", "to", " ", "use", " ", "for", " ", "HTM", "L", " ", "and", " ", "HTM", "L", " ", "Help", " ", "page", "s", ".", " ", " ", "See", " ", "the", " ", "documentation", " ", "for_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "a", " ", "list", " ", "of", " ", "bui", "lti", "n", " ", "themes", "._", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "html", "\\u", "theme_", "=_", "'", "default", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", "html", "\\u", "them", "e", " ", "=", " ", "'", "werk", "zeu", "g", "'_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Them", "e", " ", "options", " ", "are", " ", "them", "e-", "specific", " ", "and", " ", "customize", " ", "the", " ", "look", " ", "and", " ", "feel", " ", "of", " ", "a", " ", "theme_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "fur", "ther", ".", " ", " ", "For", " ", "a", " ", "list", " ", "of", " ", "options", " ", "avail", "able", " ", "for", " ", "each", " ", "them", "e", ",", " ", "see", " ", "the_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "documentation", "._", "\\u\\u\\uNL\\u\\u\\u_", "#", "html", "\\u", "them", "e\\u", "options", " ", "=", " ", "{}", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Add", " ", "any", " ", "path", "s", " ", "tha", "t", " ", "contain", " ", "custom", " ", "themes", " ", "here", ",", " ", "relative", " ", "to", " ", "this", " ", "director", "y", "._", "\\u\\u\\uNL\\u\\u\\u_", "#", "html", "\\u", "them", "e\\u", "path", " ", "=", " ", "[]", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", "html", "\\u", "them", "e\\u", "path", " ", "=", " ", "['", "\\u", "themes", "']", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "The", " ", "name", " ", "for", " ", "this", " ", "set", " ", "of", " ", "Sph", "inx", " ", "document", "s", ".", " ", " ", "If", " ", "Non", "e", ",", " ", "it", " ", "default", "s", " ", "to_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "\"<", "project", ">", " ", "v", "<", "release", ">", " ", "documentation", "\".", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", "html", "\\u", "title", " ", "=", " ", "None_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "A", " ", "shorter", " ", "title", " ", "for", " ", "the", " ", "navigation", " ", "bar", ".", " ", " ", "Default", " ", "is", " ", "the", " ", "same", " ", "as", " ", "html", "\\u", "title", "._", "\\u\\u\\uNL\\u\\u\\u_", "#", "html", "\\u", "short", "\\u", "title", " ", "=", " ", "None_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "The", " ", "name", " ", "of", " ", "an", " ", "image", " ", "file", " ", "(", "relative", " ", "to", " ", "this", " ", "director", "y", ")", " ", "to", " ", "place", " ", "at", " ", "the", " ", "top_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "of", " ", "the", " ", "sidebar", "._", "\\u\\u\\uNL\\u\\u\\u_", "#", "html", "\\u", "logo", " ", "=", " ", "None_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "The", " ", "name", " ", "of", " ", "an", " ", "image", " ", "file", " ", "(", "within", " ", "the", " ", "static", " ", "path", ")", " ", "to", " ", "use", " ", "as", " ", "fav", "icon", " ", "of", " ", "the_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "docs", ".", " ", " ", "Thi", "s", " ", "file", " ", "shou", "ld", " ", "be", " ", "a", " ", "Window", "s", " ", "icon", " ", "file", " ", "(.", "ico", ")", " ", "bei", "ng", " ", "16", "x1", "6", " ", "or", " ", "32", "x3", "2_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "pixel", "s", " ", "large", "._", "\\u\\u\\uNL\\u\\u\\u_", "#", "html", "\\u", "fav", "icon", " ", "=", " ", "None_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Add", " ", "any", " ", "path", "s", " ", "tha", "t", " ", "contain", " ", "custom", " ", "static", " ", "files", " ", "(", "suc", "h", " ", "as", " ", "style", " ", "sheet", "s", ")", " ", "here", ",_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "relative", " ", "to", " ", "this", " ", "director", "y", ".", " ", "The", "y", " ", "are", " ", "copie", "d", " ", "after", " ", "the", " ", "bui", "lti", "n", " ", "static", " ", "files", ",_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "so", " ", "a", " ", "file", " ", "named", " ", "\"", "default", ".", "css", "\"", " ", "will", " ", "overwrit", "e", " ", "the", " ", "bui", "lti", "n", " ", "\"", "default", ".", "css", "\".", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", "html", "\\u", "static", "\\u", "path", " ", "=", " ", "['", "\\u", "static", "']", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "If", " ", "not", " ", "''", ",", " ", "a", " ", "'", "Las", "t", " ", "update", "d", " ", "on", ":'", " ", "timestamp", " ", "is", " ", "inserted", " ", "at", " ", "every", " ", "page", " ", "bottom", ",_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "usi", "ng", " ", "the", " ", "give", "n", " ", "strf", "time", " ", "format", "._", "\\u\\u\\uNL\\u\\u\\u_", "#", "html", "\\u", "last", "\\u", "update", "d\\u", "fmt", " ", "=", " ", "'%", "b", " ", "%", "d", ",", " ", "%", "Y", "'_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "If", " ", "true", ",", " ", "Sma", "rty", "Pant", "s", " ", "will", " ", "be", " ", "used", " ", "to", " ", "convert", " ", "quote", "s", " ", "and", " ", "dashes", " ", "to_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "typo", "graphical", "ly", " ", "correct", " ", "entit", "ies", "._", "\\u\\u\\uNL\\u\\u\\u_", "#", "html", "\\u", "use", "\\u", "smart", "ypa", "nts", " ", "=", " ", "True_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Custom", " ", "sidebar", " ", "template", "s", ",", " ", "maps", " ", "document", " ", "names", " ", "to", " ", "template", " ", "names", "._", "\\u\\u\\uNL\\u\\u\\u_", "#", "html", "\\u", "sidebar", "s", " ", "=", " ", "{}", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Addition", "al", " ", "template", "s", " ", "tha", "t", " ", "shou", "ld", " ", "be", " ", "render", "ed", " ", "to", " ", "page", "s", ",", " ", "maps", " ", "page", " ", "names", " ", "to_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "template", " ", "names", "._", "\\u\\u\\uNL\\u\\u\\u_", "#", "html", "\\u", "addition", "al", "\\u", "page", "s", " ", "=", " ", "{}", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "If", " ", "fal", "se", ",", " ", "no", " ", "module", " ", "index", " ", "is", " ", "generat", "ed", "._", "\\u\\u\\uNL\\u\\u\\u_", "#", "html", "\\u", "domain", "\\u", "indice", "s", " ", "=", " ", "True_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "If", " ", "fal", "se", ",", " ", "no", " ", "index", " ", "is", " ", "generat", "ed", "._", "\\u\\u\\uNL\\u\\u\\u_", "#", "html", "\\u", "use", "\\u", "index", " ", "=", " ", "True_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "If", " ", "true", ",", " ", "the", " ", "index", " ", "is", " ", "split", " ", "int", "o", " ", "individual", " ", "page", "s", " ", "for", " ", "each", " ", "letter", "._", "\\u\\u\\uNL\\u\\u\\u_", "#", "html", "\\u", "split", "\\u", "index", " ", "=", " ", "False_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "If", " ", "true", ",", " ", "link", "s", " ", "to", " ", "the", " ", "re", "ST", " ", "source", "s", " ", "are", " ", "adde", "d", " ", "to", " ", "the", " ", "page", "s", "._", "\\u\\u\\uNL\\u\\u\\u_", "#", "html", "\\u", "show", "\\u", "source", "link", " ", "=", " ", "True_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "If", " ", "true", ",", " ", "\"", "Creat", "ed", " ", "usi", "ng", " ", "Sph", "inx", "\"", " ", "is", " ", "shown", " ", "in", " ", "the", " ", "HTM", "L", " ", "footer", ".", " ", "Default", " ", "is", " ", "Tru", "e", "._", "\\u\\u\\uNL\\u\\u\\u_", "#", "html", "\\u", "show", "\\u", "sphinx", " ", "=", " ", "True_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "If", " ", "true", ",", " ", "\"(", "C", ")", " ", "Copy", "right", " ", "...\"", " ", "is", " ", "shown", " ", "in", " ", "the", " ", "HTM", "L", " ", "footer", ".", " ", "Default", " ", "is", " ", "Tru", "e", "._", "\\u\\u\\uNL\\u\\u\\u_", "#", "html", "\\u", "show", "\\u", "copyr", "ight", " ", "=", " ", "True_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "If", " ", "true", ",", " ", "an", " ", "Open", "Sear", "ch", " ", "description", " ", "file", " ", "will", " ", "be", " ", "output", ",", " ", "and", " ", "all", " ", "page", "s", " ", "will", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "contain", " ", "a", " ", "<", "link", ">", " ", "tag", " ", "refer", "ring", " ", "to", " ", "it", ".", " ", " ", "The", " ", "value", " ", "of", " ", "this", " ", "option", " ", "must", " ", "be", " ", "the_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "base", " ", "URL", " ", "from", " ", "whi", "ch", " ", "the", " ", "finish", "ed", " ", "HTM", "L", " ", "is", " ", "serve", "d", "._", "\\u\\u\\uNL\\u\\u\\u_", "#", "html", "\\u", "use", "\\u", "opens", "ear", "ch", " ", "=", " ", "''_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Thi", "s", " ", "is", " ", "the", " ", "file", " ", "name", " ", "suff", "ix", " ", "for", " ", "HTM", "L", " ", "files", " ", "(", "e", ".", "g", ".", " ", "\".", "xh", "tml", "\")", "._", "\\u\\u\\uNL\\u\\u\\u_", "#", "html", "\\u", "file", "\\u", "suff", "ix", " ", "=", " ", "None_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Output", " ", "file", " ", "base", " ", "name", " ", "for", " ", "HTM", "L", " ", "help", " ", "builde", "r", "._", "\\u\\u\\uNL\\u\\u\\u_", "html", "help", "\\u", "basename_", "=_", "'", "Pipe", "ddo", "c", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "--", " ", "Optio", "ns", " ", "for", " ", "La", "Te", "X", " ", "output", " ", "--------------", "--------------", "--------------", "--------", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "The", " ", "pape", "r", " ", "size", " ", "('", "letter", "'", " ", "or", " ", "'", "a4", "')", "._", "\\u\\u\\uNL\\u\\u\\u_", "#", "late", "x", "\\u", "pape", "r", "\\u", "size", " ", "=", " ", "'", "letter", "'_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "The", " ", "font", " ", "size", " ", "('", "10", "pt", "',", " ", "'", "11", "pt", "'", " ", "or", " ", "'", "1", "2p", "t", "')", "._", "\\u\\u\\uNL\\u\\u\\u_", "#", "late", "x", "\\u", "font", "\\u", "size", " ", "=", " ", "'", "10", "pt", "'_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Group", "ing", " ", "the", " ", "document", " ", "tree", " ", "int", "o", " ", "La", "Te", "X", " ", "files", ".", " ", "List", " ", "of", " ", "tuples_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "(", "source", " ", "start", " ", "file", ",", " ", "target", " ", "name", ",", " ", "title", ",", " ", "author", ",", " ", "document", "class", " ", "[", "how", "to", "/", "manu", "al", "])", "._", "\\u\\u\\uNL\\u\\u\\u_", "late", "x", "\\u", "documents_", "=_", "[_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "'", "index", "'_", ",_", "'", "Pipe", "d", ".", "tex", "'_", ",_", "u", "'", "Pipe", "d", " ", "Document", "ation", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "u", "'", "Foun", "d", " ", "IT", " ", "A", "/", "S", "'_", ",_", "'", "manu", "al", "'_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "The", " ", "name", " ", "of", " ", "an", " ", "image", " ", "file", " ", "(", "relative", " ", "to", " ", "this", " ", "director", "y", ")", " ", "to", " ", "place", " ", "at", " ", "the", " ", "top", " ", "of_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "the", " ", "title", " ", "page", "._", "\\u\\u\\uNL\\u\\u\\u_", "#", "late", "x", "\\u", "logo", " ", "=", " ", "None_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "For", " ", "\"", "manu", "al", "\"", " ", "document", "s", ",", " ", "if", " ", "this", " ", "is", " ", "true", ",", " ", "then", " ", "toplevel", " ", "heading", "s", " ", "are", " ", "part", "s", ",_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "not", " ", "chapters", "._", "\\u\\u\\uNL\\u\\u\\u_", "#", "late", "x", "\\u", "use", "\\u", "part", "s", " ", "=", " ", "False_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "If", " ", "true", ",", " ", "show", " ", "page", " ", "reference", "s", " ", "after", " ", "internal", " ", "link", "s", "._", "\\u\\u\\uNL\\u\\u\\u_", "#", "late", "x", "\\u", "show", "\\u", "pager", "ef", "s", " ", "=", " ", "False_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "If", " ", "true", ",", " ", "show", " ", "URL", " ", "addresse", "s", " ", "after", " ", "external", " ", "link", "s", "._", "\\u\\u\\uNL\\u\\u\\u_", "#", "late", "x", "\\u", "show", "\\u", "urls", " ", "=", " ", "False_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Addition", "al", " ", "stu", "ff", " ", "for", " ", "the", " ", "La", "Te", "X", " ", "preamble", "._", "\\u\\u\\uNL\\u\\u\\u_", "#", "late", "x", "\\u", "preamble", " ", "=", " ", "''_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Document", "s", " ", "to", " ", "append", " ", "as", " ", "an", " ", "appendi", "x", " ", "to", " ", "all", " ", "manu", "als", "._", "\\u\\u\\uNL\\u\\u\\u_", "#", "late", "x", "\\u", "appendi", "ces", " ", "=", " ", "[]", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "If", " ", "fal", "se", ",", " ", "no", " ", "module", " ", "index", " ", "is", " ", "generat", "ed", "._", "\\u\\u\\uNL\\u\\u\\u_", "#", "late", "x", "\\u", "domain", "\\u", "indice", "s", " ", "=", " ", "True_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "--", " ", "Optio", "ns", " ", "for", " ", "manu", "al", " ", "page", " ", "output", " ", "--------------", "--------------", "--------------", "--", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "One", " ", "entry", " ", "per", " ", "manu", "al", " ", "page", ".", " ", "List", " ", "of", " ", "tuples_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "(", "source", " ", "start", " ", "file", ",", " ", "name", ",", " ", "description", ",", " ", "author", "s", ",", " ", "manu", "al", " ", "section", ").", "_", "\\u\\u\\uNL\\u\\u\\u_", "man", "\\u", "pages_", "=_", "[_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "'", "index", "'_", ",_", "'", "pipe", "d", "'_", ",_", "u", "'", "Pipe", "d", " ", "Document", "ation", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "[_", "u", "'", "Foun", "d", " ", "IT", " ", "A", "/", "S", "'_", "]_", ",_", "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 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 ]
Unused local variable
saltstack/salt/salt/states/drac.py
[ { "content": "def network(ip, netmask, gateway):\n '''\n Ensure the DRAC network settings are consistent\n '''\n ret = {'name': ip,\n 'result': True,\n 'changes': {},\n 'comment': ''}\n\n current_network = __salt__['drac.network_info']()\n new_network = {}\n\n if ip != current_network['IPv4 settings']['IP Address']:\n ret['changes'].update({'IP Address':\n {'Old': current_network['IPv4 settings']['IP Address'],\n 'New': ip}})\n\n if netmask != current_network['IPv4 settings']['Subnet Mask']:\n ret['changes'].update({'Netmask':\n {'Old': current_network['IPv4 settings']['Subnet Mask'],\n 'New': netmask}})\n\n if gateway != current_network['IPv4 settings']['Gateway']:\n ret['changes'].update({'Gateway':\n {'Old': current_network['IPv4 settings']['Gateway'],\n 'New': gateway}})\n\n if __opts__['test']:\n ret['result'] = None\n return ret\n\n if __salt__['drac.set_network'](ip, netmask, gateway):\n if not ret['changes']:\n ret['comment'] = 'Network is in the desired state'\n\n return ret\n\n ret['result'] = False\n ret['comment'] = 'unable to configure network'\n\n return ret", "metadata": "root.network", "header": "['module', '___EOS___']", "index": 131 } ]
[ { "span": "new_network ", "start_line": 141, "start_column": 4, "end_line": 141, "end_column": 15 } ]
[]
1
true
[ "[CLS]_", "Un", "used_", "local_", "variable_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "network_", "(_", "ip_", ",_", "netmask_", ",_", "gateway_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "'''", "\\", "10", ";", " ", " ", " ", " ", "Ensur", "e", " ", "the", " ", "DRA", "C", " ", "network", " ", "settings", " ", "are", " ", "consistent", "\\", "10", ";", " ", " ", " ", " ", "'''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "ret_", "=_", "{_", "'", "name", "'_", ":_", "ip_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "result", "'_", ":_", "True_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "change", "s", "'_", ":_", "{_", "}_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "comment", "'_", ":_", "''_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "current", "\\u", "network_", "=_", "\\u\\u", "salt\\u\\u_", "[_", "'", "drac", ".", "network", "\\u", "info", "'_", "]_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "new", "\\u", "network_", "=_", "{_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "ip_", "!=_", "current", "\\u", "network_", "[_", "'", "IP", "v", "4", " ", "settings", "'_", "]_", "[_", "'", "IP", " ", "Address", "'_", "]_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "ret_", "[_", "'", "change", "s", "'_", "]_", "._", "update_", "(_", "{_", "'", "IP", " ", "Address", "'_", ":_", "\\u\\u\\uNL\\u\\u\\u_", "{_", "'", "Old", "'_", ":_", "current", "\\u", "network_", "[_", "'", "IP", "v", "4", " ", "settings", "'_", "]_", "[_", "'", "IP", " ", "Address", "'_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "New", "'_", ":_", "ip_", "}_", "}_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "netmask_", "!=_", "current", "\\u", "network_", "[_", "'", "IP", "v", "4", " ", "settings", "'_", "]_", "[_", "'", "Subnet", " ", "Mask", "'_", "]_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "ret_", "[_", "'", "change", "s", "'_", "]_", "._", "update_", "(_", "{_", "'", "Net", "mask", "'_", ":_", "\\u\\u\\uNL\\u\\u\\u_", "{_", "'", "Old", "'_", ":_", "current", "\\u", "network_", "[_", "'", "IP", "v", "4", " ", "settings", "'_", "]_", "[_", "'", "Subnet", " ", "Mask", "'_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "New", "'_", ":_", "netmask_", "}_", "}_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "gateway_", "!=_", "current", "\\u", "network_", "[_", "'", "IP", "v", "4", " ", "settings", "'_", "]_", "[_", "'", "Gat", "ewa", "y", "'_", "]_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "ret_", "[_", "'", "change", "s", "'_", "]_", "._", "update_", "(_", "{_", "'", "Gat", "ewa", "y", "'_", ":_", "\\u\\u\\uNL\\u\\u\\u_", "{_", "'", "Old", "'_", ":_", "current", "\\u", "network_", "[_", "'", "IP", "v", "4", " ", "settings", "'_", "]_", "[_", "'", "Gat", "ewa", "y", "'_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "New", "'_", ":_", "gateway_", "}_", "}_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "\\u\\u", "opts", "\\u\\u_", "[_", "'", "test", "'_", "]_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "ret_", "[_", "'", "result", "'_", "]_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "ret_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "\\u\\u", "salt\\u\\u_", "[_", "'", "drac", ".", "set\\u", "network", "'_", "]_", "(_", "ip_", ",_", "netmask_", ",_", "gateway_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "not_", "ret_", "[_", "'", "change", "s", "'_", "]_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "ret_", "[_", "'", "comment", "'_", "]_", "=_", "'", "Network", " ", "is", " ", "in", " ", "the", " ", "desi", "red", " ", "state", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "ret_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "ret_", "[_", "'", "result", "'_", "]_", "=_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "ret_", "[_", "'", "comment", "'_", "]_",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, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 ]
Unused import
elmar-hinz/Python.Vii/tests/Cursor_Test.py
[ { "content": "# from nose.tools import *\nfrom nose.plugins.skip import SkipTest\nfrom vii.Cursor import *\nfrom vii.Signals import *\n\n\n\n\n", "metadata": "root", "header": "['module', '___EOS___']", "index": 0 }, { "content": "class BufferMock:\n text = \"line one\\nline two\\nline three\\n\".splitlines()\n\n\n\n\n\n # def gotoPositionStrict(self, position):\n # pass", "metadata": "root.BufferMock", "header": "['module', '___EOS___']", "index": 5 }, { "content": " def isEmpty(self):\n return len(self.text) == 0", "metadata": "root.BufferMock.isEmpty", "header": "['class', 'BufferMock', ':', '___EOS___']", "index": 8 }, { "content": " def lengthOfLine(self, index):\n return len(self.text[index - 1])", "metadata": "root.BufferMock.lengthOfLine", "header": "['class', 'BufferMock', ':', '___EOS___']", "index": 11 }, { "content": " def copyLines(self, index, count):\n return self.text[index - 1]", "metadata": "root.BufferMock.copyLines", "header": "['class', 'BufferMock', ':', '___EOS___']", "index": 14 }, { "content": " def countOfLines(self):\n return len(self.text)", "metadata": "root.BufferMock.countOfLines", "header": "['class', 'BufferMock', ':', '___EOS___']", "index": 17 }, { "content": "class MotionsMock:\n", "metadata": "root.MotionsMock", "header": "['module', '___EOS___']", "index": 23 }, { "content": " def gotoPositionStrict(self, position):\n self.targetPosition = position\n if position == Position(1,1):\n \" test_delete_all_lines() \"\n return Range((0,0), (0,0))\n else:\n \" other tests \"\n return Range((1,1), (1,1))", "metadata": "root.MotionsMock.gotoPositionStrict", "header": "['class', 'MotionsMock', ':', '___EOS___']", "index": 25 }, { "content": "class Cursor_Test:\n\n\n\n\n\n\n \"\"\" Track insertions \"\"\"\n\n\n\n\n\n\n \"\"\" Track deletions \"\"\"\n\n\n\n\n\n\n\n", "metadata": "root.Cursor_Test", "header": "['module', '___EOS___']", "index": 34 }, { "content": " def setup(self):\n self.buffer = BufferMock()\n self.motions = MotionsMock()\n self.fixture = Cursor()\n self.fixture.x = 1\n self.fixture.y = 1\n self.fixture.buffer = self.buffer\n self.fixture.motions = self.motions\n slot(\"cursorMoved\", self)\n self.cursorMoved = False", "metadata": "root.Cursor_Test.setup", "header": "['class', 'Cursor_Test', ':', '___EOS___']", "index": 36 }, { "content": " def receive(self, signal, sender):\n if signal == \"cursorMoved\":\n if sender == self.fixture:\n self.cursorMoved = True", "metadata": "root.Cursor_Test.receive", "header": "['class', 'Cursor_Test', ':', '___EOS___']", "index": 47 }, { "content": " def test_init(self):\n assert self.fixture.__class__ == Cursor\n assert self.fixture.buffer == self.buffer\n assert self.fixture.motions == self.motions\n assert self.fixture.x == 1\n assert self.fixture.y == 1", "metadata": "root.Cursor_Test.test_init", "header": "['class', 'Cursor_Test', ':', '___EOS___']", "index": 52 }, { "content": " def test_update(self):\n self.fixture.updated()\n assert self.cursorMoved\n # TODO test execptions", "metadata": "root.Cursor_Test.test_update", "header": "['class', 'Cursor_Test', ':', '___EOS___']", "index": 59 }, { "content": " def test_position(self):\n assert self.fixture.position() == Position(1,1)\n assert not self.cursorMoved\n self.fixture.position(Position(2,3))\n assert self.fixture.position() == Position(2,3)\n assert self.cursorMoved", "metadata": "root.Cursor_Test.test_position", "header": "['class', 'Cursor_Test', ':', '___EOS___']", "index": 64 }, { "content": " def test_insert_vertically_after_cursor(self):\n \"\"\" cursor is fix \"\"\"\n signal(\"insertedIntoBuffer\", self.buffer,\n startPosition = Position(2,1),\n afterPosition = Position(3,1))\n assert self.fixture.position() == Position(1,1)\n assert not self.cursorMoved", "metadata": "root.Cursor_Test.test_insert_vertically_after_cursor", "header": "['class', 'Cursor_Test', ':', '___EOS___']", "index": 73 }, { "content": " def test_insert_horizontally_after_cursor(self):\n \"\"\" cursor is fix \"\"\"\n signal(\"insertedIntoBuffer\", self.buffer,\n startPosition = Position(1,2),\n afterPosition = Position(1,3))\n assert self.fixture.position() == Position(1,1)\n assert not self.cursorMoved", "metadata": "root.Cursor_Test.test_insert_horizontally_after_cursor", "header": "['class', 'Cursor_Test', ':', '___EOS___']", "index": 81 }, { "content": " def test_insert_vertically_before_cursor(self):\n \"\"\" cursor moves down \"\"\"\n self.fixture.position(Position(3, 2))\n text = \"line one\\naa\\nbb\\nline two\\nline three\\n\".splitlines()\n self.buffer.text = text\n signal(\"insertedIntoBuffer\", self.buffer,\n startPosition = Position(2,1),\n afterPosition = Position(4,1))\n assert self.fixture.position() == Position(5,2)\n assert self.cursorMoved", "metadata": "root.Cursor_Test.test_insert_vertically_before_cursor", "header": "['class', 'Cursor_Test', ':', '___EOS___']", "index": 89 }, { "content": " def test_insert_horizontally_before_cursor(self):\n \"\"\" cursor moves right \"\"\"\n self.fixture.position(Position(2, 4))\n text = \"line one\\nlxxxine two\\nline three\\n\".splitlines()\n self.buffer.text = text\n signal(\"insertedIntoBuffer\", self.buffer,\n startPosition = Position(2,2),\n afterPosition = Position(2,5))\n assert self.fixture.position() == Position(2, 7)\n assert self.cursorMoved", "metadata": "root.Cursor_Test.test_insert_horizontally_before_cursor", "header": "['class', 'Cursor_Test', ':', '___EOS___']", "index": 100 }, { "content": " def test_insert_before_cursor(self):\n \"\"\" cursor moves in both dimensions \"\"\"\n self.fixture.position(Position(2, 8))\n text = \"line one\\nline xxx\\n\\nytwo\\nline three\\n\".splitlines()\n self.buffer.text = text\n signal(\"insertedIntoBuffer\", self.buffer,\n startPosition = Position(2,6),\n afterPosition = Position(4,2))\n assert self.fixture.position() == Position(4, 4)\n assert self.cursorMoved", "metadata": "root.Cursor_Test.test_insert_before_cursor", "header": "['class', 'Cursor_Test', ':', '___EOS___']", "index": 111 }, { "content": " def test_delete_vertically_after_cursor(self):\n \"\"\" cursor is fix \"\"\"\n signal(\"deletedFromBuffer\", self.buffer,\n afterPosition = Position(2,1),\n startPosition = Position(3,1))\n assert self.fixture.position() == Position(1,1)\n assert not self.cursorMoved", "metadata": "root.Cursor_Test.test_delete_vertically_after_cursor", "header": "['class', 'Cursor_Test', ':', '___EOS___']", "index": 124 }, { "content": " def test_delete_horizontally_after_cursor(self):\n \"\"\" cursor is fix \"\"\"\n signal(\"deletedFromBuffer\", self.buffer,\n afterPosition = Position(1,2),\n startPosition = Position(1,3))\n assert self.fixture.position() == Position(1,1)\n assert not self.cursorMoved", "metadata": "root.Cursor_Test.test_delete_horizontally_after_cursor", "header": "['class', 'Cursor_Test', ':', '___EOS___']", "index": 132 }, { "content": " def test_delete_vertically_before_cursor(self):\n \"\"\" cursor moves up \"\"\"\n text = \"line one\\naa\\nbb\\nline two\\nline three\\n\".splitlines()\n self.buffer.text = text\n self.fixture.position(Position(5, 2))\n text = \"line one\\nline two\\nline three\\n\".splitlines()\n self.buffer.text = text\n signal(\"deletedFromBuffer\", self.buffer,\n afterPosition = Position(2,1),\n startPosition = Position(4,1))\n assert self.fixture.position() == Position(3,2)\n assert self.cursorMoved", "metadata": "root.Cursor_Test.test_delete_vertically_before_cursor", "header": "['class', 'Cursor_Test', ':', '___EOS___']", "index": 140 }, { "content": " def test_delete_horizontally_before_cursor(self):\n \"\"\" cursor moves left \"\"\"\n text = \"line one\\nlxxxine two\\nline three\\n\".splitlines()\n self.buffer.text = text\n self.fixture.position(Position(2, 7))\n text = \"line one\\nline two\\nline three\\n\".splitlines()\n self.buffer.text = text\n signal(\"deletedFromBuffer\", self.buffer,\n afterPosition = Position(2,2),\n startPosition = Position(2,5))\n assert self.fixture.position() == Position(2, 4)\n assert self.cursorMoved", "metadata": "root.Cursor_Test.test_delete_horizontally_before_cursor", "header": "['class', 'Cursor_Test', ':', '___EOS___']", "index": 153 }, { "content": " def test_delete_before_cursor(self):\n \"\"\" cursor moves in both dimensions \"\"\"\n text = \"line one\\nline xxx\\n\\nytwo\\nline three\\n\".splitlines()\n self.buffer.text = text\n self.fixture.position(Position(4, 4))\n text = \"line one\\nline two\\nline three\\n\".splitlines()\n self.buffer.text = text\n signal(\"deletedFromBuffer\", self.buffer,\n afterPosition = Position(2,6),\n startPosition = Position(4,2))\n assert self.fixture.position() == Position(2, 8)\n assert self.cursorMoved", "metadata": "root.Cursor_Test.test_delete_before_cursor", "header": "['class', 'Cursor_Test', ':', '___EOS___']", "index": 166 }, { "content": " def test_delete_around_cursor(self):\n \" cursor moves in both dimensions \"\n text = \"line one\\nline xxx\\nyyy\\nzzz two\\nline three\\n\".splitlines()\n self.buffer.text = text\n self.fixture.position(Position(3, 2))\n text = \"line one\\nline two\\nline three\\n\".splitlines()\n self.buffer.text = text\n signal(\"deletedFromBuffer\", self.buffer,\n afterPosition = Position(2,6),\n startPosition = Position(4,5))\n assert self.motions.targetPosition == Position(2,6)\n assert self.cursorMoved", "metadata": "root.Cursor_Test.test_delete_around_cursor", "header": "['class', 'Cursor_Test', ':', '___EOS___']", "index": 179 }, { "content": " def test_delete_last_lines_with_cursor(self):\n \" cursor moves to beginning of last line \"\n text = \"line one\\nline two\\nline three\\n44\\n55\\n\".splitlines()\n self.buffer.text = text\n self.fixture.position(Position(5, 2))\n text = \"line one\\nline two\\nline three\\n\".splitlines()\n self.buffer.text = text\n signal(\"deletedFromBuffer\", self.buffer,\n afterPosition = Position(4,1),\n startPosition = Position(5,3))\n assert self.motions.targetPosition == Position(4,1)\n assert self.cursorMoved", "metadata": "root.Cursor_Test.test_delete_last_lines_with_cursor", "header": "['class', 'Cursor_Test', ':', '___EOS___']", "index": 192 }, { "content": " def test_delete_all_lines(self):\n \" cursor moves to 0, 0 \"\n self.fixture.position(Position(2, 2))\n self.buffer.text = []\n signal(\"deletedFromBuffer\", self.buffer,\n afterPosition = Position(1, 1),\n startPosition = Position(4, 1))\n assert self.motions.targetPosition == Position(1,1)\n assert self.fixture.position() == Position(0,0)\n assert self.cursorMoved", "metadata": "root.Cursor_Test.test_delete_all_lines", "header": "['class', 'Cursor_Test', ':', '___EOS___']", "index": 205 } ]
[ { "span": "from nose.plugins.skip import SkipTest", "start_line": 1, "start_column": 0, "end_line": 1, "end_column": 38 } ]
[]
1
false
[ "[CLS]_", "Un", "used_", "import_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "#", " ", "from", " ", "nose", ".", "tool", "s", " ", "import", " ", "*_", "\\u\\u\\uNL\\u\\u\\u_", "from_", "nose_", "._", "plugins_", "._", "skip_", "import_", "Ski", "p", "Test_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "vi", "i_", "._", "Cursor_", "import_", "*_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "vi", "i_", "._", "Signals_", "import_", "*_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "class_", "Buffer", "Mock_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "text_", "=_", "\"", "line", " ", "one", "\\\\", "nline", " ", "two", "\\\\", "nline", " ", "three", "\\\\", "n", "\"_", "._", "splitlines_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "def", " ", "got", "o", "Position", "Stri", "ct", "(", "self", ",", " ", "position", "):", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "pass_", "\\u\\u\\uNL\\u\\u\\u_", "[SEP]_", "class_", "Buffer", "Mock_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "is", "Empty_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "len_", "(_", "self_", "._", "text_", ")_", "==_", "0_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Buffer", "Mock_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "length", "Of", "Line_", "(_", "self_", ",_", "index_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "len_", "(_", "self_", "._", "text_", "[_", "index_", "-_", "1_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Buffer", "Mock_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "copy", "Lines_", "(_", "self_", ",_", "index_", ",_", "count_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "self_", "._", "text_", "[_", "index_", "-_", "1_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Buffer", "Mock_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "count", "Of", "Lines_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "len_", "(_", "self_", "._", "text_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "class_", "Motion", "s", "Mock_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "[SEP]_", "class_", "Motion", "s", "Mock_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "def_", "got", "o", "Position", "Stri", "ct_", "(_", "self_", ",_", "position_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "target", "Position_", "=_", "position_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "position_", "==_", "Position_", "(_", "1_", ",_", "1_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"", " ", "test\\u", "delete", "\\u", "all", "\\u", "lines", "()", " ", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "Range_", "(_", "(_", "0_", ",_", "0_", ")_", ",_", "(_", "0_", ",_", "0_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"", " ", "other", " ", "tests", " ", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "Range_", "(_", "(_", "1_", ",_", "1_", ")_", ",_", "(_", "1_", ",_", "1_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "class_", "Curs", "or", "\\u", "Test_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\"\"\"", " ", "Track", " ", "insertion", "s", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\"\"\"", " ", "Track", " ", "deletion", "s", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "[SEP]_", "class_", "Curs", "or", "\\u", "Test_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "def_", "setup_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "buffer_", "=_", "Buffer", "Mock_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "moti", "ons_", "=_", "Motion", "s", "Mock_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "fixture_", "=_", "Cursor_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "fixture_", "._", "x_", "=_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "fixture_", "._", "y_", "=_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "fixture_", "._", "buffer_", "=_", "self_", "._", "buffer_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "fixture_", "._", "moti", "ons_", "=_", "self_", "._", "moti", "ons_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "slot_", "(_", "\"", "cursor", "Move", "d", "\"_", ",_", "self_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "cursor", "Move", "d_", "=_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Curs", "or", "\\u", "Test_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "receive_", "(_", "self_", ",_", "signal_", ",_", "sender_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "signal_", "==_", "\"", "cursor", "Move", "d", "\"_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "sender_", "==_", "self_", "._", "fixture_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "cursor", "Move", "d_", "=_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Curs", "or", "\\u", "Test_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "init_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "assert_", "self_", "._", "fixture_", "._", "\\u\\u", "class\\u\\u_", "==_", "Cursor_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "assert_", "self_", "._", "fixture_", "._", "buffer_", "==_", "self_", "._", "buffer_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "assert_", "self_", "._", "fixture_", "._", "moti", "ons_", "==_", "self_", "._", "moti", "ons_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "assert_", "self_", "._", "fixture_", "._", "x_", "==_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "assert_", "self_", "._", "fixture_", "._", "y_", "==_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Curs", "or", "\\u", "Test_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "update_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "fixture_", "._", "updated_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "assert_", "self_", "._", "cursor", "Move", "d_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "TOD", "O", " ", "test", " ", "exec", "ptions_", "\\u\\u\\uNL\\u\\u\\u_", "[SEP]_", "class_", "Curs", "or", "\\u", "Test_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "position_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "assert_", "self_", "._", "fixture_", "._", "position_", "(_", ")_", "==_", "Position_", "(_", "1_", ",_", "1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "assert_", "not_", "self_", "._", "cursor", "Move", "d_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "fixture_", "._", "position_", "(_", "Position_", "(_", "2_", ",_", "3_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "assert_", "self_", "._", "fixture_", "._", "position_", "(_", ")_", "==_", "Position_", "(_", "2_", ",_", "3_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "assert_", "self_", "._", "cursor", "Move", "d_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Curs", "or", "\\u", "Test_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "test\\u", "insert", "\\u", "vertical", "ly", "\\u", "after", "\\u", "cursor_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", " ", "cursor", " ", "is", " ", "fix", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "signal_", "(_", "\"", "inserted", "Int", "o", "Buffer", "\"_", ",_", "self_", "._", "buffer_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "start", "Position_", "=_", "Position_", "(_", "2_", ",_", "1_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "after", "Position_", "=_", "Position_", "(_", "3_", ",_", "1_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "assert_", "self_", "._", "fixture_", "._", "position_", "(_", ")_", "==_", "Position_", "(_", "1_", ",_", "1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "assert_", "not_", "self_", "._", "cursor", "Move", "d_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Curs", "or", "\\u", "Test_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "insert", "\\u", "horizon", "tally", "\\u", "after", "\\u", "cursor_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", " ", "cursor", " ", "is", " ", "fix", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "signal_", "(_", "\"", "inserted", "Int", "o", "Buffer", "\"_", ",_", "self_", "._", "buffer_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "start", "Position_", "=_", "Position_", "(_", "1_", ",_", "2_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "after", "Position_", "=_", "Position_", "(_", "1_", ",_", "3_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "assert_", "self_", "._", "fixture_", "._", "position_", "(_", ")_", "==_", "Position_", "(_", "1_", ",_", "1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "assert_", "not_", "self_", "._", "cursor", "Move", "d_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Curs", "or", "\\u", "Test_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "insert", "\\u", "vertical", "ly", "\\u", "bef", "ore", "\\u", "cursor_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", " ", "cursor", " ", "moves", " ", "down", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "fixture_", "._", "position_", "(_", "Position_", "(_", "3_", ",_", "2_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "text_", "=_", "\"", "line", " ", "one", "\\\\", "naa", "\\\\", "nb", "b", "\\\\", "nline", " ", "two", "\\\\", "nline", " ", "three", "\\\\", "n", "\"_", "._", "splitlines_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "buffer_", "._", "text_", "=_", "text_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "signal_", "(_", "\"", "inserted", "Int", "o", "Buffer", "\"_", ",_", "self_", "._", "buffer_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "start", "Position_", "=_", "Position_", "(_", "2_", ",_", "1_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "after", "Position_", "=_", "Position_", "(_", "4_", ",_", "1_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "assert_", "self_", "._", "fixture_", "._", "position_", "(_", ")_", "==_", "Position_", "(_", "5_", ",_", "2_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "assert_", "self_", "._", "cursor", "Move", "d_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Curs", "or", "\\u", "Test_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "insert", "\\u", "horizon", "tally", "\\u", "bef", "ore", "\\u", "cursor_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", " ", "cursor", " ", "moves", " ", "right", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "fixture_", "._", "position_", "(_", "Position_", "(_", "2_", ",_", "4_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "text_", "=_", "\"", "line", " ", "one", "\\\\", "nl", "xxx", "ine", " ", "two", "\\\\", "nline", " ", "three", "\\\\", "n", "\"_", "._", "splitlines_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "buffer_", "._", "text_", "=_", "text_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "signal_", "(_", "\"", "inserted", "Int", "o", "Buffer", "\"_", ",_", "self_", "._", "buffer_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "start", "Position_", "=_", "Position_", "(_", "2_", ",_", "2_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "after", "Position_", "=_", "Position_", "(_", "2_", ",_", "5_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "assert_", "self_", "._", "fixture_", "._", "position_", "(_", ")_", "==_", "Position_", "(_", "2_", ",_", "7_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "assert_", "self_", "._", "cursor", "Move", "d_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Curs", "or", "\\u", "Test_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "insert", "\\u", "bef", "ore", "\\u", "cursor_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", " ", "cursor", " ", "moves", " ", "in", " ", "bot", "h", " ", "dimension", "s", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "fixture_", "._", "position_", "(_", "Position_", "(_", "2_", ",_", "8_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "text_", "=_", "\"", "line", " ", "one", "\\\\", "nline", " ", "xxx", "\\\\", "n", "\\\\", "ny", "two", "\\\\", "nline", " ", "three", "\\\\", "n", "\"_", "._", "splitlines_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "buffer_", "._", "text_", "=_", "text_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "signal_", "(_", "\"", "inserted", "Int", "o", "Buffer", "\"_", ",_", "self_", "._", "buffer_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "start", "Position_", "=_", "Position_", "(_", "2_", ",_", "6_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "after", "Position_", "=_", "Position_", "(_", "4_", ",_", "2_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "assert_", "self_", "._", "fixture_", "._", "position_", "(_", ")_", "==_", "Position_", "(_", "4_", ",_", "4_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "assert_", "self_", "._", "cursor", "Move", "d_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Curs", "or", "\\u", "Test_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "test\\u", "delete", "\\u", "vertical", "ly", "\\u", "after", "\\u", "cursor_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", " ", "cursor", " ", "is", " ", "fix", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "signal_", "(_", "\"", "delete", "d", "Fro", "m", "Buffer", "\"_", ",_", "self_", "._", "buffer_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "after", "Position_", "=_", "Position_", "(_", "2_", ",_", "1_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "start", "Position_", "=_", "Position_", "(_", "3_", ",_", "1_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "assert_", "self_", "._", "fixture_", "._", "position_", "(_", ")_", "==_", "Position_", "(_", "1_", ",_", "1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "assert_", "not_", "self_", "._", "cursor", "Move", "d_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Curs", "or", "\\u", "Test_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "delete", "\\u", "horizon", "tally", "\\u", "after", "\\u", "cursor_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", " ", "cursor", " ", "is", " ", "fix", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "signal_", "(_", "\"", "delete", "d", "Fro", "m", "Buffer", "\"_", ",_", "self_", "._", "buffer_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "after", "Position_", "=_", "Position_", "(_", "1_", ",_", "2_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "start", "Position_", "=_", "Position_", "(_", "1_", ",_", "3_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "assert_", "self_", "._", "fixture_", "._", "position_", "(_", ")_", "==_", "Position_", "(_", "1_", ",_", "1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "assert_", "not_", "self_", "._", "cursor", "Move", "d_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Curs", "or", "\\u", "Test_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "delete", "\\u", "vertical", "ly", "\\u", "bef", "ore", "\\u", "cursor_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", " ", "cursor", " ", "moves", " ", "up", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "text_", "=_", "\"", "line", " ", "one", "\\\\", "naa", "\\\\", "nb", "b", "\\\\", "nline", " ", "two", "\\\\", "nline", " ", "three", "\\\\", "n", "\"_", "._", "splitlines_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "buffer_", "._", "text_", "=_", "text_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "fixture_", "._", "position_", "(_", "Position_", "(_", "5_", ",_", "2_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "text_", "=_", "\"", "line", " ", "one", "\\\\", "nline", " ", "two", "\\\\", "nline", " ", "three", "\\\\", "n", "\"_", "._", "splitlines_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "buffer_", "._", "text_", "=_", "text_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "signal_", "(_", "\"", "delete", "d", "Fro", "m", "Buffer", "\"_", ",_", "self_", "._", "buffer_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "after", "Position_", "=_", "Position_", "(_", "2_", ",_", "1_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "start", "Position_", "=_", "Position_", "(_", "4_", ",_", "1_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "assert_", "self_", "._", "fixture_", "._", "position_", "(_", ")_", "==_", "Position_", "(_", "3_", ",_", "2_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "assert_", "self_", "._", "cursor", "Move", "d_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Curs", "or", "\\u", "Test_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "delete", "\\u", "horizon", "tally", "\\u", "bef", "ore", "\\u", "cursor_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", " ", "cursor", " ", "moves", " ", "left", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "text_", "=_", "\"", "line", " ", "one", "\\\\", "nl", "xxx", "ine", " ", "two", "\\\\", "nline", " ", "three", "\\\\", "n", "\"_", "._", "splitlines_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "buffer_", "._", "text_", "=_", "text_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "fixture_", "._", "position_", "(_", "Position_", "(_", "2_", ",_", "7_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "text_", "=_", "\"", "line", " ", "one", "\\\\", "nline", " ", "two", "\\\\", "nline", " ", "three", "\\\\", "n", "\"_", "._", "splitlines_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "buffer_", "._", "text_", "=_", "text_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "signal_", "(_", "\"", "delete", "d", "Fro", "m", "Buffer", "\"_", ",_", "self_", "._", "buffer_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "after", "Position_", "=_", "Position_", "(_", "2_", ",_", "2_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "start", "Position_", "=_", "Position_", "(_", "2_", ",_", "5_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "assert_", "self_", "._", "fixture_", "._", "position_", "(_", ")_", "==_", "Position_", "(_", "2_", ",_", "4_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "assert_", "self_", "._", "cursor", "Move", "d_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Curs", "or", "\\u", "Test_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "delete", "\\u", "bef", "ore", "\\u", "cursor_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", " ", "cursor", " ", "moves", " ", "in", " ", "bot", "h", " ", "dimension", "s", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "text_", "=_", "\"", "line", " ", "one", "\\\\", "nline", " ", "xxx", "\\\\", "n", "\\\\", "ny", "two", "\\\\", "nline", " ", "three", "\\\\", "n", "\"_", "._", "splitlines_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "buffer_", "._", "text_", "=_", "text_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "fixture_", "._", "position_", "(_", "Position_", "(_", "4_", ",_", "4_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "text_", "=_", "\"", "line", " ", "one", "\\\\", "nline", " ", "two", "\\\\", "nline", " ", "three", "\\\\", "n", "\"_", "._", "splitlines_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "buffer_", "._", "text_", "=_", "text_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "signal_", "(_", "\"", "delete", "d", "Fro", "m", "Buffer", "\"_", ",_", "self_", "._", "buffer_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "after", "Position_", "=_", "Position_", "(_", "2_", ",_", "6_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "start", "Position_", "=_", "Position_", "(_", "4_", ",_", "2_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "assert_", "self_", "._", "fixture_", "._", "position_", "(_", ")_", "==_", "Position_", "(_", "2_", ",_", "8_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "assert_", "self_", "._", "cursor", "Move", "d_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Curs", "or", "\\u", "Test_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "delete", "\\u", "aro", "und", "\\u", "cursor_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"", " ", "cursor", " ", "moves", " ", "in", " ", "bot", "h", " ", "dimension", "s", " ", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "text_", "=_", "\"", "line", " ", "one", "\\\\", "nline", " ", "xxx", "\\\\", "ny", "yy", "\\\\", "nz", "zz", " ", "two", "\\\\", "nline", " ", "three", "\\\\", "n", "\"_", "._", "splitlines_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "buffer_", "._", "text_", "=_", "text_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "fixture_", "._", "position_", "(_", "Position_", "(_", "3_", ",_", "2_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "text_", "=_", "\"", "line", " ", "one", "\\\\", "nline", " ", "two", "\\\\", "nline", " ", "three", "\\\\", "n", "\"_", "._", "splitlines_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "buffer_", "._", "text_", "=_", "text_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "signal_", "(_", "\"", "delete", "d", "Fro", "m", "Buffer", "\"_", ",_", "self_", "._", "buffer_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "after", "Position_", "=_", "Position_", "(_", "2_", ",_", "6_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "start", "Position_", "=_", "Position_", "(_", "4_", ",_", "5_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "assert_", "self_", "._", "moti", "ons_", "._", "target", "Position_", "==_", "Position_", "(_", "2_", ",_", "6_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "assert_", "self_", "._", "cursor", "Move", "d_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Curs", "or", "\\u", "Test_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "delete", "\\u", "last", "\\u", "lines", "\\u", "with", "\\u", "cursor_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"", " ", "cursor", " ", "moves", " ", "to", " ", "beginn", "ing", " ", "of", " ", "last", " ", "line", " ", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "text_", "=_", "\"", "line", " ", "one", "\\\\", "nline", " ", "two", "\\\\", "nline", " ", "three", "\\\\", "n4", "4", "\\\\", "n", "5", "5", "\\\\", "n", "\"_", "._", "splitlines_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "buffer_", "._", "text_", "=_", "text_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "fixture_", "._", "position_", "(_", "Position_", "(_", "5_", ",_", "2_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "text_", "=_", "\"", "line", " ", "one", "\\\\", "nline", " ", "two", "\\\\", "nline", " ", "three", "\\\\", "n", "\"_", "._", "splitlines_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "buffer_", "._", "text_", "=_", "text_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "signal_", "(_", "\"", "delete", "d", "Fro", "m", "Buffer", "\"_", ",_", "self_", "._", "buffer_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "after", "Position_", "=_", "Position_", "(_", "4_", ",_", "1_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "start", "Position_", "=_", "Position_", "(_", "5_", ",_", "3_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "assert_", "self_", "._", "moti", "ons_", "._", "target", "Position_", "==_", "Position_", "(_", "4_", ",_", "1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "assert_", "self_", "._", "cursor", "Move", "d_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Curs", "or", "\\u", "Test_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "delete", "\\u", "all", "\\u", "lines_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"", " ", "cursor", " ", "moves", " ", "to", " ", "0", ",", " ", "0", " ", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "fixture_", "._", "position_", "(_", "Position_", "(_", "2_", ",_", "2_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "buffer_", "._", "text_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "signal_", "(_", "\"", "delete", "d", "Fro", "m", "Buffer", "\"_", ",_", "self_", "._", "buffer_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "after", "Position_", "=_", "Position_", "(_", "1_", ",_", "1_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "start", "Position_", "=_", "Position_", "(_", "4_", ",_", "1_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "assert_", "self_", "._", "moti", "ons_", "._", "target", "Position_", "==_", "Position_", "(_", "1_", ",_", "1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "assert_", "self_", "._", "fixture_", "._", "position_", "(_", ")_", "==_", "Position_", "(_", "0_", ",_", "0_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "assert_", "self_", "._", "cursor", "Move", "d_" ]
[ 4, 4, 4, 4, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2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 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 ]
Unused import
apache/climate/obs4MIPs/Toolbox/ESGFresources.py
[ { "content": "# Licensed to the Apache Software Foundation (ASF) under one\n# or more contributor license agreements. See the NOTICE file\n# distributed with this work for additional information\n# regarding copyright ownership. The ASF licenses this file\n# to you under the Apache License, Version 2.0 (the\n# \"License\"); you may not use this file except in compliance\n# with the License. You may obtain a copy of the License at\n#\n# http://www.apache.org/licenses/LICENSE-2.0\n#\n# Unless required by applicable law or agreed to in writing,\n# software distributed under the License is distributed on an\n# \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\n# KIND, either express or implied. See the License for the\n# specific language governing permissions and limitations\n# under the License.\n\n\nimport pdb\nimport shutil\nimport os,sys\nfrom numpy import arange\nfrom Toolbox.CMORresources import CMORAttributes\n\n# ********************************************************************\n# ESGFresources()\n#\n# ********************************************************************\n\n\n# ********************************************************************\n# movefiles() \n#\n# rename files in new obs4MIPS path\n# ********************************************************************\n\n", "metadata": "root", "header": "['module', '___EOS___']", "index": 0 }, { "content": "class ESGFresources:\n '''\n Create dictionary based on a file using key=value standard \n '''\n\n\n\n", "metadata": "root.ESGFresources", "header": "['module', '___EOS___']", "index": 28 }, { "content": " def __init__(self,rcFile):\n '''\n Read CMIP5 Table and convert into a dictionary\n strip quote double quote, leading and trailing white space\n from key and value.\n '''\n f=open( rcFile, 'r')\n lines=f.readlines()\n f.close()\n\n self.resources=dict([(key.strip(), value.strip(),) \n for line in lines if line != '\\n' \\\n and line[0] != \"#\" \n for (key, value) in\n [line.strip().\\\n replace(\"'\",\"\").\\\n replace(\"\\\"\",\"\").\\\n rstrip().\\\n split(\"=\")]])\n\n for key in self.resources.keys():\n self.resources[key]=self.resources[key].replace(\"\\\\\",\"\\\"\")\n \n self.xcl=None\n try:\n self.xcl=self.resources['excel_file']\n rc=self.ReadXCL()\n except:\n pass", "metadata": "root.ESGFresources.__init__", "header": "['class', 'ESGFresources', ':', '___EOS___']", "index": 32 }, { "content": " def __getitem__(self,key):\n '''\n Retreive item from resource dictionary\n '''\n return self.resources[key]", "metadata": "root.ESGFresources.__getitem__", "header": "['class', 'ESGFresources', ':', '___EOS___']", "index": 62 }, { "content": " def __setitem__(self,key,value):\n '''\n '''\n self.resources[key]=value", "metadata": "root.ESGFresources.__setitem__", "header": "['class', 'ESGFresources', ':', '___EOS___']", "index": 68 }, { "content": " def __delete__(self,key):\n '''\n '''\n del self.resources[key]", "metadata": "root.ESGFresources.__delete__", "header": "['class', 'ESGFresources', ':', '___EOS___']", "index": 73 }, { "content": " def ReadXCL(self):\n '''\n Read Excel Table and fill rc variable related field.\n '''\n try:\n import xlrd\n except:\n print \"****** Could not find xlrd Python Package ****\"\n print \"****** Please install xlrd package to read excel files ****\"\n\n if( os.path.isfile(self.xcl) ):\n\t\twb=xlrd.open_workbook(self.xcl)\n else:\n print \"****** Could not find \"+self.xcl+\" file ****\"\n print \"****** Please check excel file name ****\"\n raise NameError(self.xcl)\n\n sheet=wb.sheet_by_name('Variables')\n\n self.resources['cmor_var'] = [ sheet.row( i )[ 0 ].value.\\\n encode('ascii','ignore') \\\n for i in arange(sheet.nrows-2) + 2 ]\n\n self.resources['original_var'] = [ sheet.row( i )[ 1 ].value.\\\n encode('ascii','ignore') \\\n for i in arange(sheet.nrows-2) + 2 ]\n\n self.resources['original_units']=[ sheet.row( i )[ 2 ].value.\\\n encode('ascii','ignore') \\\n for i in arange(sheet.nrows-2) + 2 ]\n\n self.resources['level'] =[ sheet.row( i )[ 3 ].value.\\\n encode('ascii','ignore') \\\n for i in arange(sheet.nrows-2) + 2]\n \n self.resources['equation'] =[ sheet.row( i )[ 6 ].value.\\\n encode('ascii','ignore') \\\n for i in arange(sheet.nrows-2) + 2 ]\n\n # -----------------------------------------------------------------\n # Make sure it is a string. The main program will call eval on it.\n # -----------------------------------------------------------------\n self.resources['cmor_var'] = str(self.resources['cmor_var'] )\n self.resources['original_var'] = str(self.resources['original_var'])\n self.resources['original_units'] =str(self.resources['original_units'])\n self.resources['equation'] =str(self.resources['equation'])\n self.resources['level'] =str(self.resources['level'])\n return 1", "metadata": "root.ESGFresources.ReadXCL", "header": "['class', 'ESGFresources', ':', '___EOS___']", "index": 78 }, { "content": "def movefiles(rc): \n '''\n Change CMIP5 directory struture to obs4MIPS directory structure.\n Create new path and rename files following with new convention \n Remove old directory tree.\n '''\n # ----------------------\n # New path for obs4MIPS\n # ----------------------\n path = rc['institute_id' ] + '/' + \\\n rc['instrument' ] + '/' + \\\n rc['project_id' ] + '/' + \\\n rc['product' ] + '/' + \\\n rc['modeling_realm' ] + '/' + \\\n rc['cvrt_cmor_var' ] + '/' + \\\n rc['frequency' ] + '/' + \\\n rc['data_structure' ] + '/' + \\\n rc['institute_id' ] + '/' + \\\n rc['instrument' ] \n \n # -------------------------------------------------------------\n # For TRMM data set version_directory is set to 'false' so that\n # no version will be created in the directory\n # -------------------------------------------------------------\n try:\n rc['version_directory'] == 'false'\n pass\n except:\n path += '/V' + rc['processing_version'] + '/'\n\n # -----------------------------\n # Make sure the directory exist \n # ------------------------------\n try:\n os.makedirs(path)\n except:\n None\n\n # -----------------\n # Rename all files\n # -----------------\n cmorpath = rc['project_id' ] + '/' + \\\n rc['product' ] + '/' + \\\n rc['institute_id'] + '/' \n\n # -----------------\n # Manage attributes\n # -----------------\n for r,d,f in os.walk(cmorpath):\n for files in f:\n if files.endswith(\".nc\"):\n filetimestamp = files.split('_')[-1].strip(\".nc\")\n file = os.path.join(r,files)\n print file\n # -----------------\n # Delete attributes\n # ------------------\n Attr=CMORAttributes( file )\n DelGlbAttributes=eval(rc['DelGlbAttributes'].\\\n replace('\\\\','\\''))\n for attribute in DelGlbAttributes:\n print \"Deleting attribute: %s\" % attribute\n Attr.GlbDel(attribute)\n # -----------------\n # set attributes\n # ------------------\n SetGlbAttributes=eval(rc['SetGlbAttributes'].\\\n replace('\\\\','\\''))\n for (attribute,Value) in SetGlbAttributes:\n print \"Assigning attribute (%s,%s)\" % (attribute,Value)\n Attr.GlbSet(attribute,Value)\n Attr.close()\n\n source = ''\n if( rc['source_fn'] == 'SYNOPTIC' ):\n source = rc['SYNOPTIC']+\"z_\"\n elif( rc['source_fn'] != '' ):\n source = rc['source_fn'].split('_')[0] + '_'\n \n newfilename = rc['cvrt_cmor_var' ] + '_' + \\\n rc['instrument' ] + '-' + \\\n source + \\\n rc['processing_level' ] + '_v'+ \\\n rc['processing_version'] + '_' + \\\n filetimestamp + '.nc'\n \n newfilename = os.path.join(path,newfilename)\n # -----------\n # Move files\n # -----------\n print file\n print newfilename\n os.rename(file,newfilename)\n\n \n # ----------------\n # Remove cmor path\n # ----------------\n shutil.rmtree( rc['project_id'] )\n return 0", "metadata": "root.movefiles", "header": "['module', '___EOS___']", "index": 133 } ]
[ { "span": "import pdb", "start_line": 18, "start_column": 0, "end_line": 18, "end_column": 10 }, { "span": "import os,sys", "start_line": 20, "start_column": 0, "end_line": 20, "end_column": 13 } ]
[]
1
false
[ "[CLS]_", "Un", "used_", "import_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "#", " ", "License", "d", " ", "to", " ", "the", " ", "Ap", "ache", " ", "Sof", "twa", "re", " ", "Foun", "dati", "on", " ", "(", "AS", "F", ")", " ", "under", " ", "one_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "or", " ", "more", " ", "contributor", " ", "license", " ", "agreement", "s", ".", " ", " ", "See", " ", "the", " ", "NOTICE", " ", "file_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "distributed", " ", "with", " ", "this", " ", "work", " ", "for", " ", "addition", "al", " ", "information_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "regarding", " ", "copyr", "ight", " ", "owner", "ship", ".", " ", " ", "The", " ", "AS", "F", " ", "license", "s", " ", "this", " ", "file_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "to", " ", "you", " ", "under", " ", "the", " ", "Ap", "ache", " ", "License", ",", " ", "Version", " ", "2.0", " ", "(", "the_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "\"", "License", "\");", " ", "you", " ", "may", " ", "not", " ", "use", " ", "this", " ", "file", " ", "except", " ", "in", " ", "compli", "ance_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "with", " ", "the", " ", "License", ".", " ", " ", "You", " ", "may", " ", "obtain", " ", "a", " ", "copy", " ", "of", " ", "the", " ", "License", " ", "at_", "\\u\\u\\uNL\\u\\u\\u_", "#", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", " ", " ", " ", "http", "://", "www", ".", "apa", "che", ".", "org", "/", "license", "s", "/", "LICENSE", "-", "2.0_", "\\u\\u\\uNL\\u\\u\\u_", "#", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Un", "less", " ", "require", "d", " ", "by", " ", "applica", "ble", " ", "law", " ", "or", " ", "agree", "d", " ", "to", " ", "in", " ", "writ", "ing", ",_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "software", " ", "distributed", " ", "under", " ", "the", " ", "License", " ", "is", " ", "distributed", " ", "on", " ", "an_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "\"", "AS", " ", "IS", "\"", " ", "BAS", "IS", ",", " ", "WITH", "OUT", " ", "WAR", "RAN", "TIES", " ", "OR", " ", "CONDITION", "S", " ", "OF", " ", "ANY_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "KIND", ",", " ", "eit", "her", " ", "express", " ", "or", " ", "impli", "ed", ".", " ", " ", "See", " ", "the", " ", "License", " ", "for", " ", "the_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "specific", " ", "language", " ", "govern", "ing", " ", "permissi", "ons", " ", "and", " ", "limit", "ations_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "under", " ", "the", " ", "License", "._", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "import_", "pdb_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "shutil_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "os_", ",_", "sys_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "numpy_", "import_", "arange_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "Toolb", "ox_", "._", "CM", "OR", "resources_", "import_", "CM", "ORA", "ttr", "ibut", "es_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", " ", "***********", "***********", "***********", "***********", "***********", "***********", "**_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", " ", " ", " ", " ", "ES", "GF", "resource", "s", "()", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", " ", "***********", "***********", "***********", "***********", "***********", "***********", "**_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", " ", "***********", "***********", "***********", "***********", "***********", "***********", "**_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", " ", "move", "files", "()", " ", " ", " _", "\\u\\u\\uNL\\u\\u\\u_", "#", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", " ", "rename", " ", "files", " ", "in", " ", "new", " ", "obs", "4", "MIPS", " ", "path_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", " ", "***********", "***********", "***********", "***********", "***********", "***********", "**_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "class_", "ES", "GF", "resources_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "'''", "\\", "10", ";", " ", " ", " ", " ", "Creat", "e", " ", "dictionar", "y", " ", "based", " ", "on", " ", "a", " ", "file", " ", "usi", "ng", " ", "key", "=", "value", " ", "standard", " ", " ", "\\", "10", ";", " ", " ", " ", " ", "'''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "[SEP]_", "class_", "ES", "GF", "resources_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "\\u\\u", "init\\u\\u_", "(_", "self_", ",_", "rc", "File_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "'''", "\\", "10", ";", " ", " ", " ", " ", "Read", " ", "CM", "IP", "5", " ", "Table", " ", "and", " ", "convert", " ", "int", "o", " ", "a", " ", "dictionar", "y", "\\", "10", ";", " ", " ", " ", " ", "strip", " ", "quote", " ", "double", " ", "quote", ",", " ", "lead", "ing", " ", "and", " ", "trail", "ing", " ", "white", " ", "space", "\\", "10", ";", " ", " ", " ", " ", "from", " ", "key", " ", "and", " ", "value", ".", "\\", "10", ";", " ", " ", " ", " ", "'''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "f_", "=_", "open_", "(_", "rc", "File_", ",_", "'", "r", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "lines_", "=_", "f_", "._", "readlines_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "f_", "._", "close_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "resources_", "=_", "dict_", "(_", "[_", "(_", "key_", "._", "strip_", "(_", ")_", ",_", "value_", "._", "strip_", "(_", ")_", ",_", ")_", "\\u\\u\\uNL\\u\\u\\u_", "for_", "line_", "in_", "lines_", "if_", "line_", "!=_", "'\\\\", "n", "'_", "and_", "line_", "[_", "0_", "]_", "!=_", "\"#\"_", "\\u\\u\\uNL\\u\\u\\u_", "for_", "(_", "key_", ",_", "value_", ")_", "in_", "\\u\\u\\uNL\\u\\u\\u_", "[_", "line_", "._", "strip_", "(_", ")_", "._", "replace_", "(_", "\"'\"_", ",_", "\"\"_", ")_", "._", "replace_", "(_", "\"\\\\\"\"_", ",_", "\"\"_", ")_", "._", "rstrip_", "(_", ")_", "._", "split_", "(_", "\"=\"_", ")_", "]_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "for_", "key_", "in_", "self_", "._", "resources_", "._", "keys_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "resources_", "[_", "key_", "]_", "=_", "self_", "._", "resources_", "[_", "key_", "]_", "._", "replace_", "(_", "\"\\\\\\\\\"_", ",_", "\"\\\\\"\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "xc", "l_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "xc", "l_", "=_", "self_", "._", "resources_", "[_", "'", "exce", "l\\u", "file", "'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "rc_", "=_", "self_", "._", "Read", "XC", "L_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "pass_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "ES", "GF", "resources_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "\\u\\u", "getitem\\u\\u_", "(_", "self_", ",_", "key_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "'''", "\\", "10", ";", " ", " ", " ", " ", "Retr", "eive", " ", "item", " ", "from", " ", "resource", " ", "dictionar", "y", "\\", "10", ";", " ", " ", " ", " ", "'''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "self_", "._", "resources_", "[_", "key_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "ES", "GF", "resources_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "\\u\\u", "setitem\\u\\u_", "(_", "self_", ",_", "key_", ",_", "value_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "'''", "\\", "10", ";", " ", " ", " ", " ", "'''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "resources_", "[_", "key_", "]_", "=_", "value_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "ES", "GF", "resources_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "\\u\\u", "delete", "\\u\\u_", "(_", "self_", ",_", "key_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "'''", "\\", "10", ";", " ", " ", " ", " ", "'''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "del_", "self_", "._", "resources_", "[_", "key_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "ES", "GF", "resources_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "Read", "XC", "L_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "'''", "\\", "10", ";", " ", " ", " ", " ", "Read", " ", "Exce", "l", " ", "Table", " ", "and", " ", "fill", " ", "rc", " ", "variab", "le", " ", "relate", "d", " ", "field", ".", "\\", "10", ";", " ", " ", " ", " ", "'''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "import_", "xlr", "d_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "print_", "\"****", "**", " ", "Cou", "ld", " ", "not", " ", "find", " ", "xlr", "d", " ", "Pyth", "on", " ", "Packa", "ge", " ", "****", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "print_", "\"****", "**", " ", "Ple", "ase", " ", "install", " ", "xlr", "d", " ", "package", " ", "to", " ", "read", " ", "exce", "l", " ", "files", " ", "****", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "(_", "os_", "._", "path_", "._", "isfile_", "(_", "self_", "._", "xc", "l_", ")_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t_", "wb_", "=_", "xlr", "d_", "._", "open", "\\u", "workbook_", "(_", "self_", "._", "xc", "l_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "print_", "\"****", "**", " ", "Cou", "ld", " ", "not", " ", "find", " ", "\"_", "+_", "self_", "._", "xc", "l_", "+_", "\"", " ", "file", " ", "****", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "print_", "\"****", "**", " ", "Ple", "ase", " ", "check", " ", "exce", "l", " ", "file", " ", "name", " ", "****", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "raise_", "Name", "Error_", "(_", "self_", "._", "xc", "l_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "sheet_", "=_", "wb_", "._", "sheet", "\\u", "by", "\\u", "name_", "(_", "'", "Varia", "bles", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "resources_", "[_", "'", "cmo", "r", "\\u", "var", "'_", "]_", "=_", "[_", "sheet_", "._", "row_", "(_", "i_", ")_", "[_", "0_", "]_", "._", "value_", "._", "encode_", "(_", "'", "ascii", "'_", ",_", "'", "ignore", "'_", ")_", "for_", "i_", "in_", "arange_", "(_", "sheet_", "._", "nrows_", "-_", "2_", ")_", "+_", "2_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "resources_", "[_", "'", "original", "\\u", "var", "'_", "]_", "=_", "[_", "sheet_", "._", "row_", "(_", "i_", ")_", "[_", "1_", "]_", "._", "value_", "._", "encode_", "(_", "'", "ascii", "'_", ",_", "'", "ignore", "'_", ")_", "for_", "i_", "in_", "arange_", "(_", "sheet_", "._", "nrows_", "-_", "2_", ")_", "+_", "2_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "resources_", "[_", "'", "original", "\\u", "unit", "s", "'_", "]_", "=_", "[_", "sheet_", "._", "row_", "(_", "i_", ")_", "[_", "2_", "]_", "._", "value_", "._", "encode_", "(_", "'", "ascii", "'_", ",_", "'", "ignore", "'_", ")_", "for_", "i_", "in_", "arange_", "(_", "sheet_", "._", "nrows_", "-_", "2_", ")_", "+_", "2_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "resources_", "[_", "'", "level", "'_", "]_", "=_", "[_", "sheet_", "._", "row_", "(_", "i_", ")_", "[_", "3_", "]_", "._", "value_", "._", "encode_", "(_", "'", "ascii", "'_", ",_", "'", "ignore", "'_", ")_", "for_", "i_", "in_", "arange_", "(_", "sheet_", "._", "nrows_", "-_", "2_", ")_", "+_", "2_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "resources_", "[_", "'", "equation", "'_", "]_", "=_", "[_", "sheet_", "._", "row_", "(_", "i_", ")_", "[_", "6_", "]_", "._", "value_", "._", "encode_", "(_", "'", "ascii", "'_", ",_", "'", "ignore", "'_", ")_", "for_", "i_", "in_", "arange_", "(_", "sheet_", "._", "nrows_", "-_", "2_", ")_", "+_", "2_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "--------------", "--------------", "--------------", "--------------", "---------", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Make", " ", "sure", " ", "it", " ", "is", " ", "a", " ", "string", ".", " ", "The", " ", "main", " ", "program", " ", "will", " ", "call", " ", "eval", " ", "on", " ", "it", "._", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "--------------", "--------------", "--------------", "--------------", "---------", "_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "resources_", "[_", "'", "cmo", "r", "\\u", "var", "'_", "]_", "=_", "str_", "(_", "self_", "._", "resources_", "[_", "'", "cmo", "r", "\\u", "var", "'_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "resources_", "[_", "'", "original", "\\u", "var", "'_", "]_", "=_", "str_", "(_", "self_", "._", "resources_", "[_", "'", "original", "\\u", "var", "'_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "resources_", "[_", "'", "original", "\\u", "unit", "s", "'_", "]_", "=_", "str_", "(_", "self_", "._", "resources_", "[_", "'", "original", "\\u", "unit", "s", "'_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "resources_", "[_", "'", "equation", "'_", "]_", "=_", "str_", "(_", "self_", "._", "resources_", "[_", "'", "equation", "'_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "resources_", "[_", "'", "level", "'_", "]_", "=_", "str_", "(_", "self_", "._", "resources_", "[_", "'", "level", "'_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "move", "files_", "(_", "rc_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "'''", "\\", "10", ";", " ", " ", " ", " ", "Change", " ", "CM", "IP", "5", " ", "director", "y", " ", "stru", "ture", " ", "to", " ", "obs", "4", "MIPS", " ", "director", "y", " ", "structure", ".", "\\", "10", ";", " ", " ", " ", " ", "Creat", "e", " ", "new", " ", "path", " ", "and", " ", "rename", " ", "files", " ", "follow", "ing", " ", "with", " ", "new", " ", "convention", " ", "\\", "10", ";", " ", " ", " ", " ", "Remove", " ", "old", " ", "director", "y", " ", "tree", ".", "\\", "10", ";", " ", " ", " ", " ", "'''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "--------------", "--------", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "New", " ", "path", " ", "for", " ", "obs", "4", "MIPS", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "--------------", "--------", "_", "\\u\\u\\uNL\\u\\u\\u_", "path_", "=_", "rc_", "[_", "'", "institu", "te", "\\u", "id", "'_", "]_", "+_", "'/'_", "+_", "rc_", "[_", "'", "instrument", "'_", "]_", "+_", "'/'_", "+_", "rc_", "[_", "'", "project", "\\u", "id", "'_", "]_", "+_", "'/'_", "+_", "rc_", "[_", "'", "product", "'_", "]_", "+_", "'/'_", "+_", "rc_", "[_", "'", "modeling", "\\u", "real", "m", "'_", "]_", "+_", "'/'_", "+_", "rc_", "[_", "'", "cv", "rt", "\\u", "cmo", "r", "\\u", "var", "'_", "]_", "+_", "'/'_", "+_", "rc_", "[_", "'", "freque", "nc", "y", "'_", "]_", "+_", "'/'_", "+_", "rc_", "[_", "'", "data\\u", "structure", "'_", "]_", "+_", "'/'_", "+_", "rc_", "[_", "'", "institu", "te", "\\u", "id", "'_", "]_", "+_", "'/'_", "+_", "rc_", "[_", "'", "instrument", "'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "--------------", "--------------", "--------------", "--------------", "-----", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "For", " ", "TR", "MM", " ", "data", " ", "set", " ", "version", "\\u", "director", "y", " ", "is", " ", "set", " ", "to", " ", "'", "fal", "se", "'", " ", "so", " ", "that_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "no", " ", "version", " ", "will", " ", "be", " ", "created", " ", "in", " ", "the", " ", "directory_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "--------------", "--------------", "--------------", "--------------", "-----", "_", "\\u\\u\\uNL\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "rc_", "[_", "'", "version", "\\u", "director", "y", "'_", "]_", "==_", "'", "fal", "se", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "pass_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "path_", "+=_", "'/", "V", "'_", "+_", "rc_", "[_", "'", "process", "ing", "\\u", "version", "'_", "]_", "+_", "'/'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "--------------", "--------------", "-_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Make", " ", "sure", " ", "the", " ", "director", "y", " ", "exist", " _", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "--------------", "--------------", "--", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "os_", "._", "makedirs_", "(_", "path_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "--------------", "---", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Rename", " ", "all", " ", "files_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "--------------", "---", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "cmo", "rpath", "_", "=_", "rc_", "[_", "'", "project", "\\u", "id", "'_", "]_", "+_", "'/'_", "+_", "rc_", "[_", "'", "product", "'_", "]_", "+_", "'/'_", "+_", "rc_", "[_", "'", "institu", "te", "\\u", "id", "'_", "]_", "+_", "'/'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "--------------", "---", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Manage", " ", "attributes_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "--------------", "---", "_", "\\u\\u\\uNL\\u\\u\\u_", "for_", "r_", ",_", "d_", ",_", "f_", "in_", "os_", "._", "walk_", "(_", "cmo", "rpath", "_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "for_", "files_", "in_", "f_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "files_", "._", "endswith_", "(_", "\".", "nc", "\"_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "filet", "imes", "tamp", "_", "=_", "files_", "._", "split_", "(_", "'\\u'_", ")_", "[_", "-_", "1_", "]_", "._", "strip_", "(_", "\".", "nc", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "file_", "=_", "os_", "._", "path_", "._", "join_", "(_", "r_", ",_", "files_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "print_", "file_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "--------------", "---", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Delete", " ", "attributes_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "--------------", "----", "_", "\\u\\u\\uNL\\u\\u\\u_", "Attr_", "=_", "CM", "ORA", "ttr", "ibut", "es_", "(_", "file_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "Del", "Gl", "b", "Attributes_", "=_", "eval_", "(_", "rc_", "[_", "'", "Del", "Gl", "b", "Attribute", "s", "'_", "]_", "._", "replace_", "(_", "'\\\\\\\\'_", ",_", "'\\\\''_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "attribute_", "in_", "Del", "Gl", "b", "Attributes_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "print_", "\"", "Del", "eti", "ng", " ", "attribute", ":", " ", "%", "s", "\"_", "%_", "attribute_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "Attr_", "._", "Gl", "b", "Del", "_", "(_", "attribute_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "--------------", "---", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "set", " ", "attributes_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "--------------", "----", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "Set", "Gl", "b", "Attributes_", "=_", "eval_", "(_", "rc_", "[_", "'", "Set", "Gl", "b", "Attribute", "s", "'_", "]_", "._", "replace_", "(_", "'\\\\\\\\'_", ",_", "'\\\\''_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "(_", "attribute_", ",_", "Value_", ")_", "in_", "Set", "Gl", "b", "Attributes_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "print_", "\"", "Assign", "ing", " ", "attribute", " ", "(%", "s", ",%", "s", ")\"_", "%_", "(_", "attribute_", ",_", "Value_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "Attr_", "._", "Gl", "b", "Set_", "(_", "attribute_", ",_", "Value_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "Attr_", "._", "close_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "source_", "=_", "''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "(_", "rc_", "[_", "'", "source", "\\u", "fn", "'_", "]_", "==_", "'", "SYN", "OPTI", "C", "'_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "source_", "=_", "rc_", "[_", "'", "SYN", "OPTI", "C", "'_", "]_", "+_", "\"", "z", "\\u\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "(_", "rc_", "[_", "'", "source", "\\u", "fn", "'_", "]_", "!=_", "''_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "source_", "=_", "rc_", "[_", "'", "source", "\\u", "fn", "'_", "]_", "._", "split_", "(_", "'\\u'_", ")_", "[_", "0_", "]_", "+_", "'\\u'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "newfile", "name_", "=_", "rc_", "[_", "'", "cv", "rt", "\\u", "cmo", "r", "\\u", "var", "'_", "]_", "+_", "'\\u'_", "+_", "rc_", "[_", "'", "instrument", "'_", "]_", "+_", "'-'_", "+_", "source_", "+_", "rc_", "[_", "'", "process", "ing", "\\u", "level", "'_", "]_", "+_", "'\\u", "v", "'_", "+_", "rc_", "[_", "'", "process", "ing", "\\u", "version", "'_", "]_", "+_", "'\\u'_", "+_", "filet", "imes", "tamp", "_", "+_", "'.", "nc", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "newfile", "name_", "=_", "os_", "._", "path_", "._", "join_", "(_", "path_", ",_", "newfile", "name_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "-----------", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Move", " ", "files_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "-----------", "_", "\\u\\u\\uNL\\u\\u\\u_", "print_", "file_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "print_", "newfile", "name_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "os_", "._", "rename_", "(_", "file_", ",_", "newfile", "name_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "--------------", "--", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Remove", " ", "cmo", "r", " ", "path_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "--------------", "--", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "shutil_", "._", "rmtree_", "(_", "rc_", "[_", "'", "project", "\\u", "id", "'_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "0_" ]
[ 4, 4, 4, 4, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2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 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 ]
Unused local variable
EricssonResearch/calvin-base/calvin/utilities/tests/test_calconfig.py
[ { "content": " def setUp(self):\n self.filepath = None\n f, self.filepath = tempfile.mkstemp()\n os.unlink(self.filepath)\n self._env = os.environ\n print \"hej\"", "metadata": "root.TestBase.setUp", "header": "['class', 'TestBase', '(', 'unittest', '.', 'TestCase', ')', ':', '___EOS___']", "index": 26 } ]
[ { "span": "f,", "start_line": 28, "start_column": 8, "end_line": 28, "end_column": 9 } ]
[]
1
true
[ "[CLS]_", "Un", "used_", "local_", "variable_", "[SEP]_", "class_", "Test", "Base_", "(_", "unittest_", "._", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "def_", "set", "Up_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "filepath_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "f_", ",_", "self_", "._", "filepath_", "=_", "tempfile_", "._", "mkstemp_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "os_", "._", "unlink_", "(_", "self_", "._", "filepath_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "\\u", "env_", "=_", "os_", "._", "environ_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "print_", "\"", "he", "j", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_" ]
[ 4, 4, 4, 4, 4, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 ]
Unused import
nasa/CrisisMappingToolkit/cmt/radar/learning.py
[ { "content": "# -----------------------------------------------------------------------------\n# Copyright * 2014, United States Government, as represented by the\n# Administrator of the National Aeronautics and Space Administration. All\n# rights reserved.\n#\n# The Crisis Mapping Toolkit (CMT) v1 platform is licensed under the Apache\n# License, Version 2.0 (the \"License\"); you may not use this file except in\n# compliance with the License. You may obtain a copy of the License at\n# http://www.apache.org/licenses/LICENSE-2.0.\n#\n# Unless required by applicable law or agreed to in writing, software\n# distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the\n# License for the specific language governing permissions and limitations under\n# the License.\n# -----------------------------------------------------------------------------\n\nimport ee\nfrom cmt.mapclient_qt import centerMap, addToMap\n\nfrom histogram import RadarHistogram\n\n\n'''\nUse Earth Engine's classifier tool for water detection.\n'''\n\n\n\n\n", "metadata": "root", "header": "['module', '___EOS___']", "index": 0 }, { "content": "def __learning_threshold(domain, algorithm):\n \n training_domain = None\n if domain.training_domain:\n training_domain = domain.training_domain\n elif domain.unflooded_domain:\n training_domain = domain.unflooded_domain\n if not training_domain:\n raise Exception('Cannot use learning algorithms without a training image defined by the domain!')\n classifier = ee.apply('TrainClassifier', {'image': training_domain.get_radar().image,\n 'subsampling' : 0.07,\n 'training_image' : training_domain.ground_truth,\n 'training_band' : 'b1',\n 'training_region' : training_domain.bounds,\n 'max_classification': 2,\n 'classifier_name' : algorithm})\n classified = ee.call('ClassifyImage', domain.get_radar().image, classifier).select(['classification'], ['b1']);\n return classified;", "metadata": "root.__learning_threshold", "header": "['module', '___EOS___']", "index": 27 }, { "content": "def decision_tree(domain):\n '''Use \"Cart\" method: Classification and Regression Tree'''\n return __learning_threshold(domain, 'Cart')", "metadata": "root.decision_tree", "header": "['module', '___EOS___']", "index": 46 }, { "content": "def random_forests(domain):\n '''Use \"RifleSerialClassifier\" method: A Random Forest technique'''\n return __learning_threshold(domain, 'RifleSerialClassifier')", "metadata": "root.random_forests", "header": "['module', '___EOS___']", "index": 49 }, { "content": "def svm(domain):\n '''Use \"Pegasos\" method: Primal Estimated sub-GrAdient SOlver for SVM'''\n return __learning_threshold(domain, 'Pegasos')", "metadata": "root.svm", "header": "['module', '___EOS___']", "index": 52 } ]
[ { "span": "from cmt.mapclient_qt import centerMap, addToMap", "start_line": 18, "start_column": 0, "end_line": 18, "end_column": 48 }, { "span": "from histogram import RadarHistogram", "start_line": 20, "start_column": 0, "end_line": 20, "end_column": 36 } ]
[]
1
false
[ "[CLS]_", "Un", "used_", "import_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "#", " ", "--------------", "--------------", "--------------", "--------------", "--------------", "-------", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Copy", "right", " ", "*", " ", "2014", ",", " ", "Unit", "ed", " ", "State", "s", " ", "Gov", "ern", "ment", ",", " ", "as", " ", "represent", "ed", " ", "by", " ", "the_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Administra", "tor", " ", "of", " ", "the", " ", "Nat", "ional", " ", "Aer", "ona", "uti", "cs", " ", "and", " ", "Spac", "e", " ", "Administrati", "on", ".", " ", "All_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "rights", " ", "reserve", "d", "._", "\\u\\u\\uNL\\u\\u\\u_", "#", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "The", " ", "Cri", "sis", " ", "Map", "ping", " ", "Tool", "kit", " ", "(", "CM", "T", ")", " ", "v1", " ", "platform", " ", "is", " ", "license", "d", " ", "under", " ", "the", " ", "Ap", "ache_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "License", ",", " ", "Version", " ", "2.0", " ", "(", "the", " ", "\"", "License", "\");", " ", "you", " ", "may", " ", "not", " ", "use", " ", "this", " ", "file", " ", "except", " ", "in_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "compli", "anc", "e", " ", "with", " ", "the", " ", "License", ".", " ", "You", " ", "may", " ", "obtain", " ", "a", " ", "copy", " ", "of", " ", "the", " ", "License", " ", "at_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "http", "://", "www", ".", "apa", "che", ".", "org", "/", "license", "s", "/", "LICENSE", "-", "2.0", "._", "\\u\\u\\uNL\\u\\u\\u_", "#", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Un", "less", " ", "require", "d", " ", "by", " ", "applica", "ble", " ", "law", " ", "or", " ", "agree", "d", " ", "to", " ", "in", " ", "writ", "ing", ",", " ", "software", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "distributed", " ", "under", " ", "the", " ", "License", " ", "is", " ", "distributed", " ", "on", " ", "an", " ", "\"", "AS", " ", "IS", "\"", " ", "BAS", "IS", ",", " ", "WITH", "OUT_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "WAR", "RAN", "TIES", " ", "OR", " ", "CONDITION", "S", " ", "OF", " ", "ANY", " ", "KIND", ",", " ", "eit", "her", " ", "express", " ", "or", " ", "impli", "ed", ".", " ", "See", " ", "the_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "License", " ", "for", " ", "the", " ", "specific", " ", "language", " ", "govern", "ing", " ", "permissi", "ons", " ", "and", " ", "limit", "ation", "s", " ", "under", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "the", " ", "License", "._", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "--------------", "--------------", "--------------", "--------------", "--------------", "-------", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "import_", "ee_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "cmt", "_", "._", "map", "client", "\\u", "qt_", "import_", "center", "Map_", ",_", "add", "To", "Map_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "from_", "histogram_", "import_", "Rad", "ar", "Histogram", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "'''", "\\", "10", ";", "Us", "e", " ", "Ear", "th", " ", "Engine", "'", "s", " ", "classif", "ier", " ", "tool", " ", "for", " ", "water", " ", "detect", "ion", ".", "\\", "10", ";'", "''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "\\u\\u", "learn", "ing", "\\u", "threshold_", "(_", "domain_", ",_", "algorithm_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "train", "ing", "\\u", "domain_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "domain_", "._", "train", "ing", "\\u", "domain_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "train", "ing", "\\u", "domain_", "=_", "domain_", "._", "train", "ing", "\\u", "domain_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "domain_", "._", "unf", "loo", "ded", "\\u", "domain_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "train", "ing", "\\u", "domain_", "=_", "domain_", "._", "unf", "loo", "ded", "\\u", "domain_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "not_", "train", "ing", "\\u", "domain_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "raise_", "Exception_", "(_", "'", "Cann", "ot", " ", "use", " ", "learn", "ing", " ", "algo", "rit", "hms", " ", "with", "out", " ", "a", " ", "train", "ing", " ", "image", " ", "defin", "ed", " ", "by", " ", "the", " ", "domain", "!'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "classifier_", "=_", "ee_", "._", "apply_", "(_", "'", "Train", "Classif", "ier", "'_", ",_", "{_", "'", "image", "'_", ":_", "train", "ing", "\\u", "domain_", "._", "get", "\\u", "radar", "_", "(_", ")_", "._", "image_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "subs", "ampling", "'_", ":_", "0.07_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "train", "ing", "\\u", "image", "'_", ":_", "train", "ing", "\\u", "domain_", "._", "ground", "\\u", "truth_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "train", "ing", "\\u", "band", "'_", ":_", "'", "b1", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "train", "ing", "\\u", "region", "'_", ":_", "train", "ing", "\\u", "domain_", "._", "bounds_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "max", "\\u", "classificati", "on", "'_", ":_", "2_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "classif", "ier", "\\u", "name", "'_", ":_", "algorithm_", "}_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "classified", "_", "=_", "ee_", "._", "call_", "(_", "'", "Classif", "y", "Image", "'_", ",_", "domain_", "._", "get", "\\u", "radar", "_", "(_", ")_", "._", "image_", ",_", "classifier_", ")_", "._", "select_", "(_", "[_", "'", "classificati", "on", "'_", "]_", ",_", "[_", "'", "b1", "'_", "]_", ")_", ";_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "classified", "_", ";_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "decision", "\\u", "tree_", "(_", "domain_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "'''", "Us", "e", " ", "\"", "Cart", "\"", " ", "method", ":", " ", "Classificat", "ion", " ", "and", " ", "Regr", "ession", " ", "Tree", "'''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "\\u\\u", "learn", "ing", "\\u", "threshold_", "(_", "domain_", ",_", "'", "Cart", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "random", "\\u", "forest", "s_", "(_", "domain_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "'''", "Us", "e", " ", "\"", "Ri", "fle", "Ser", "ial", "Classif", "ier", "\"", " ", "method", ":", " ", "A", " ", "Random", " ", "Fore", "st", " ", "technique", "'''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "\\u\\u", "learn", "ing", "\\u", "threshold_", "(_", "domain_", ",_", "'", "Ri", "fle", "Ser", "ial", "Classif", "ier", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "svm_", "(_", "domain_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "'''", "Us", "e", " ", "\"", "Pe", "gas", "os", "\"", " ", "method", ":", " ", "Prim", "al", " ", "Estimated", " ", "sub", "-", "Gr", "Adi", "ent", " ", "SO", "lver", " ", "for", " ", "SV", "M", "'''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "\\u\\u", "learn", "ing", "\\u", "threshold_", "(_", "domain_", ",_", "'", "Pe", "gas", "os", "'_", ")_" ]
[ 4, 4, 4, 4, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2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, Inc. All Rights Reserved.\n#\n# Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated\n# documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation\n# the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and\n# to permit persons to whom the Software is furnished to do so, subject to the following conditions:\n#\n# The above copyright notice and this permission notice shall be included in all copies or substantial portions\n# of the Software.\n#\n# THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED\n# TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL\n# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF\n# CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS\n# IN THE SOFTWARE.\n\n__author__ = 'yfauser'\n\nfrom tests.config import *\nfrom nsxramlclient.client import NsxClient\nimport time\n\n\nclient_session = NsxClient(nsxraml_file, nsxmanager, nsx_username, nsx_password, debug=True)\n\n#TODO: add tests for all vds operations", "metadata": "root", "header": "['module', '___EOS___']", "index": 0 } ]
[ { "span": "import time", "start_line": 22, "start_column": 0, "end_line": 22, "end_column": 11 } ]
[]
1
false
[ "[CLS]_", "Un", "used_", "import_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "#", " ", "codi", "ng", "=", "utf", "-", "8_", "\\u\\u\\uNL\\u\\u\\u_", "#", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Copy", "right", " ", "\\", "169", ";", " ", "201", "5", " ", "VM", "ware", ",", " ", "Inc", ".", " ", "All", " ", "Rig", "hts", " ", "Reserve", "d", "._", "\\u\\u\\uNL\\u\\u\\u_", "#", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Permi", "ssion", " ", "is", " ", "here", "by", " ", "grant", "ed", ",", " ", "free", " ", "of", " ", "charge", ",", " ", "to", " ", "any", " ", "person", " ", "obtain", "ing", " ", "a", " ", "copy", " ", "of", " ", "this", " ", "software", " ", "and", " ", "associate", "d_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "documentation", " ", "files", " ", "(", "the", " ", "\"", "Sof", "twa", "re", "\")", ",", " ", "to", " ", "deal", " ", "in", " ", "the", " ", "Sof", "twa", "re", " ", "with", "out", " ", "restriction", ",", " ", "inclu", "ding", " ", "with", "out", " ", "limit", "ation_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "the", " ", "rights", " ", "to", " ", "use", ",", " ", "copy", ",", " ", "modif", "y", ",", " ", "merge", ",", " ", "publi", "sh", ",", " ", "distribute", ",", " ", "subli", "cens", "e", ",", " ", "and", "/", "or", " ", "sell", " ", "copie", "s", " ", "of", " ", "the", " ", "Sof", "twa", "re", ",", " ", "and_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "to", " ", "permit", " ", "person", "s", " ", "to", " ", "who", "m", " ", "the", " ", "Sof", "twa", "re", " ", "is", " ", "fur", "nish", "ed", " ", "to", " ", "do", " ", "so", ",", " ", "subject", " ", "to", " ", "the", " ", "follow", "ing", " ", "condition", "s", ":_", "\\u\\u\\uNL\\u\\u\\u_", "#", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "The", " ", "above", " ", "copyr", "ight", " ", "notice", " ", "and", " ", "this", " ", "permissi", "on", " ", "notice", " ", "sha", "ll", " ", "be", " ", "include", "d", " ", "in", " ", "all", " ", "copie", "s", " ", "or", " ", "substa", "nti", "al", " ", "porti", "ons_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "of", " ", "the", " ", "Sof", "twa", "re", "._", "\\u\\u\\uNL\\u\\u\\u_", "#", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "THE", " ", "SOFT", "WARE", " ", "IS", " ", "PROVI", "DED", " ", "\"", "AS", " ", "IS", "\",", " ", "WITH", "OUT", " ", "WAR", "RAN", "TY", " ", "OF", " ", "ANY", " ", "KIND", ",", " ", "EXPR", "ESS", " ", "OR", " ", "IMPL", "IED", ",", " ", "INC", "LU", "DING", " ", "BUT", " ", "NOT", " ", "LIMIT", "ED_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "TO", " ", "THE", " ", "WAR", "RAN", "TIES", " ", "OF", " ", "MER", "CHAN", "TAB", "ILI", "TY", ",", " ", "FIT", "NESS", " ", "FOR", " ", "A", " ", "PARTI", "CUL", "AR", " ", "PUR", "POS", "E", " ", "AND", " ", "NON", "INF", "RING", "EME", "NT", ".", " ", "IN", " ", "NO", " ", "EVENT", " ", "SHA", "LL_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "THE", " ", "AUTHOR", "S", " ", "OR", " ", "COPY", "RIG", "HT", " ", "HOLD", "ERS", " ", "BE", " ", "LI", "AB", "LE", " ", "FOR", " ", "ANY", " ", "CLA", "IM", ",", " ", "DA", "MAGE", "S", " ", "OR", " ", "OTHER", " ", "LI", "ABI", "LIT", "Y", ",", " ", "WHE", "THER", " ", "IN", " ", "AN", " ", "ACTI", "ON", " ", "OF_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "CONTR", "ACT", ",", " ", "TOR", "T", " ", "OR", " ", "OTHER", "WI", "SE", ",", " ", "ARI", "SIN", "G", " ", "FROM", ",", " ", "OUT", " ", "OF", " ", "OR", " ", "IN", " ", "CONNECTION", " ", "WITH", " ", "THE", " ", "SOFT", "WARE", " ", "OR", " ", "THE", " ", "USE", " ", "OR", " ", "OTHER", " ", "DEA", "LING", "S_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "IN", " ", "THE", " ", "SOFT", "WARE", "._", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u", "author\\u\\u_", "=_", "'", "yf", "aus", "er", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "from_", "tests_", "._", "config_", "import_", "*_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "ns", "xr", "aml", "client_", "._", "client_", "import_", "Ns", "x", "Client_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "time_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "client", "\\u", "session_", "=_", "Ns", "x", "Client_", "(_", "ns", "xr", "aml", "\\u", "file_", ",_", "ns", "xma", "nage", "r_", ",_", "ns", "x", "\\u", "username_", ",_", "ns", "x", "\\u", "password_", ",_", "debug_", "=_", "True_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", "TOD", "O", ":", " ", "add", " ", "tests", " ", "for", " ", "all", " ", "vd", "s", " ", "operations_", "\\u\\u\\uNL\\u\\u\\u_" ]
[ 4, 4, 4, 4, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2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 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 ]
Unreachable code
dhylands/upy-examples/boot-cdc-only.py
[ { "content": "def init():\n if False:\n uart = pyb.UART(6,115200)\n pyb.repl_uart(uart)\n print(\"REPL is also on UART 6 (Y1=Tx Y2=Rx)\")\n if False:\n bufsize = 100\n print(\"Setting alloc_emergency_exception_buf to\", bufsize)\n micropython.alloc_emergency_exception_buf(bufsize)", "metadata": "root.init", "header": "['module', '___EOS___']", "index": 28 } ]
[ { "span": "uart = pyb.UART(6,115200)", "start_line": 30, "start_column": 8, "end_line": 30, "end_column": 33 }, { "span": "bufsize = 100", "start_line": 34, "start_column": 8, "end_line": 34, "end_column": 21 } ]
[]
1
true
[ "[CLS]_", "Unrea", "chab", "le_", "code_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "init_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "False_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "uar", "t_", "=_", "pyb", "_", "._", "UART", "_", "(_", "6_", ",_", "1152", "00_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "pyb", "_", "._", "repl", "\\u", "uar", "t_", "(_", "uar", "t_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "print_", "(_", "\"", "REP", "L", " ", "is", " ", "als", "o", " ", "on", " ", "UART", " ", "6", " ", "(", "Y", "1", "=", "Tx", " ", "Y", "2", "=", "Rx", ")\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "False_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "bufsize_", "=_", "100_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "print_", "(_", "\"", "Sett", "ing", " ", "allo", "c\\u", "emergency", "\\u", "exception", "\\u", "buf", " ", "to", "\"_", ",_", "bufsize_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "microp", "ython_", "._", "allo", "c\\u", "emergency", "\\u", "exception", "\\u", "buf_", "(_", "bufsize_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_" ]
[ 4, 4, 4, 4, 4, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 ]
Unused import
uwdata/termite-visualizations/web2py/gluon/cfs.py
[ { "content": "#!/usr/bin/env python\n# -*- coding: utf-8 -*-\n\n\"\"\"\nThis file is part of the web2py Web Framework\nCopyrighted by Massimo Di Pierro <[email protected]>\nLicense: LGPLv3 (http://www.gnu.org/licenses/lgpl.html)\n\nFunctions required to execute app components\n============================================\n\nFOR INTERNAL USE ONLY\n\"\"\"\n\nfrom os import stat\nimport thread\nimport logging\nfrom gluon.fileutils import read_file\n\ncfs = {} # for speed-up\ncfs_lock = thread.allocate_lock() # and thread safety\n\n\n", "metadata": "root", "header": "['module', '___EOS___']", "index": 0 }, { "content": "def getcfs(key, filename, filter=None):\n \"\"\"\n Caches the *filtered* file `filename` with `key` until the file is\n modified.\n\n :param key: the cache key\n :param filename: the file to cache\n :param filter: is the function used for filtering. Normally `filename` is a\n .py file and `filter` is a function that bytecode compiles the file.\n In this way the bytecode compiled file is cached. (Default = None)\n\n This is used on Google App Engine since pyc files cannot be saved.\n \"\"\"\n try:\n t = stat(filename).st_mtime\n except OSError:\n return filter() if callable(filter) else ''\n cfs_lock.acquire()\n item = cfs.get(key, None)\n cfs_lock.release()\n if item and item[0] == t:\n return item[1]\n if not callable(filter):\n data = read_file(filename)\n else:\n data = filter()\n cfs_lock.acquire()\n cfs[key] = (t, data)\n cfs_lock.release()\n return data", "metadata": "root.getcfs", "header": "['module', '___EOS___']", "index": 23 } ]
[ { "span": "import logging", "start_line": 16, "start_column": 0, "end_line": 16, "end_column": 14 } ]
[]
1
false
[ "[CLS]_", "Un", "used_", "import_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "#!", "/", "usr", "/", "bin", "/", "env", " ", "python_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "-*-", " ", "codi", "ng", ":", " ", "utf", "-", "8", " ", "-*-", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\"\"\"", "\\", "10", ";", "Thi", "s", " ", "file", " ", "is", " ", "part", " ", "of", " ", "the", " ", "web", "2py", " ", "Web", " ", "Frame", "work", "\\", "10", ";", "Copy", "right", "ed", " ", "by", " ", "Mass", "imo", " ", "Di", " ", "Pie", "rro", " ", "<", "mdi", "pie", "rro", "@", "cs", ".", "dep", "aul", ".", "edu", ">", "\\", "10", ";", "License", ":", " ", "LGP", "Lv", "3", " ", "(", "http", "://", "www", ".", "gnu", ".", "org", "/", "license", "s", "/", "lg", "pl", ".", "html", ")", "\\", "10", ";", "\\", "10", ";", "Function", "s", " ", "require", "d", " ", "to", " ", "execute", " ", "app", " ", "component", "s", "\\", "10", ";", "==============", "==============", "==============", "==", "\\", "10", ";", "\\", "10", ";", "FOR", " ", "INTERN", "AL", " ", "USE", " ", "ONL", "Y", "\\", "10", ";\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "from_", "os_", "import_", "stat_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "thread_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "logging_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "gluon_", "._", "fileu", "tils_", "import_", "read", "\\u", "file_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "cf", "s_", "=_", "{_", "}_", "#", " ", "for", " ", "speed", "-", "up_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "cf", "s", "\\u", "lock_", "=_", "thread_", "._", "allocate", "\\u", "lock_", "(_", ")_", "#", " ", "and", " ", "thread", " ", "safety", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "getc", "fs_", "(_", "key_", ",_", "filename_", ",_", "filter_", "=_", "None_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Cache", "s", " ", "the", " ", "*", "filter", "ed", "*", " ", "file", " ", "`", "filename", "`", " ", "with", " ", "`", "key", "`", " ", "unti", "l", " ", "the", " ", "file", " ", "is", "\\", "10", ";", " ", " ", " ", " ", "modifi", "ed", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", ":", "param", " ", "key", ":", " ", "the", " ", "cache", " ", "key", "\\", "10", ";", " ", " ", " ", " ", ":", "param", " ", "filename", ":", " ", "the", " ", "file", " ", "to", " ", "cache", "\\", "10", ";", " ", " ", " ", " ", ":", "param", " ", "filter", ":", " ", "is", " ", "the", " ", "function", " ", "used", " ", "for", " ", "filtering", ".", " ", "Normal", "ly", " ", "`", "filename", "`", " ", "is", " ", "a", "\\", "10", ";", " ", " ", " ", " ", ".", "py", " ", "file", " ", "and", " ", "`", "filter", "`", " ", "is", " ", "a", " ", "function", " ", "tha", "t", " ", "bytecode", " ", "compile", "s", " ", "the", " ", "file", ".", "\\", "10", ";", " ", " ", " ", " ", "In", " ", "this", " ", "way", " ", "the", " ", "bytecode", " ", "compile", "d", " ", "file", " ", "is", " ", "cache", "d", ".", " ", "(", "Default", " ", "=", " ", "Non", "e", ")", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "Thi", "s", " ", "is", " ", "used", " ", "on", " ", "Goo", "gle", " ", "App", " ", "Engine", " ", "sinc", "e", " ", "pyc", " ", "files", " ", "cann", "ot", " ", "be", " ", "saved", ".", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "t_", "=_", "stat_", "(_", "filename_", ")_", "._", "st", "\\u", "mtime_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "OSE", "rror_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "filter_", "(_", ")_", "if_", "callable_", "(_", "filter_", ")_", "else_", "''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "cf", "s", "\\u", "lock_", "._", "acquire_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "item_", "=_", "cf", "s_", "._", "get_", "(_", "key_", ",_", "None_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "cf", "s", "\\u", "lock_", "._", "release_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "item_", "and_", "item_", "[_", "0_", "]_", "==_", "t_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "item_", "[_", "1_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "not_", "callable_", "(_", "filter_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "data_", "=_", "read", "\\u", "file_", "(_", "filename_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "data_", "=_", "filter_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "cf", "s", "\\u", "lock_", "._", "acquire_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "cf", "s_", "[_", "key_", "]_", "=_", "(_", "t_", ",_", "data_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "cf", "s", "\\u", "lock_", "._", "release_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "data_" ]
[ 4, 4, 4, 4, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 ]
Unused import
los-cocos/cocos/utest/test_RectMapCollider__no_stuck.py
[ { "content": "# -*- coding: utf-8 -*-\n\"\"\" Tests that an actor using RectMapCollider does not get stuck\nRun the tests with pytest.\n\nImplementation description\n - The basic situation considered is\n - actor touching wall in one of it sides\n - requested to move a dx, dy that will push against the wall and\n allow free movement in the axis not blocked by the wall\n\n - They are so many small variations in each situation proposed that\n directly writing each test setup would be error prone, so a layered\n case generator approach was selected\n - base cases depict qualitative diferent situations as a\n (map, actor_rect, push, signed free axis vector)\n - for each parametrizable value , a set of values of\n interest is defined\n - code will walk the (base cases, params values) generating the\n concrete cases to validate\n - as an implementation detail, maps will be cached\n\n - params desired to change\n map: the basic form and orientation in the situation\n cell_size, actor_size: mostly\n actor side z <=> cell side z\n actor side odd or even (because .center assings; division_errors?)\n push style: dx, dy\n actor start position: move the start position along the wall to cover\n all int alignements with the grid, ie do offsets 1..cell_width if\n free movement axis is x, ... \n\"\"\"\nfrom __future__ import division, print_function, unicode_literals\n\n# that simplifies the pyglet mockup needed\n# remember to erase or set to zero for normal runs\nimport os\nassert os.environ['cocos_utest']\n\n# set the desired pyglet mockup\nimport sys\nsys.path.insert(0,'pyglet_mockup1')\nimport pyglet\nassert pyglet.mock_level == 1\n \n# will use the cocos in the same checkout, except if you move this file.\nimport sys\nimport os\nsys.path.insert(0, os.path.join(os.path.dirname(__file__), '..'))\n\n# for py.test\nimport py\n\nimport cocos\nimport cocos.layer\nfrom cocos.tiles import RectMap, RectCell, RectMapCollider \nfrom cocos.rect import Rect\n\nimport aux_RectMapCollider__no_stuck as aux\n# set the cocos classes needed in aux before calling any function there\naux.RectMap_cls = RectMap\naux.RectCell = RectCell\naux.Rect = Rect\n\n\nmaps_cache = aux.generate_maps('-')\n \n##def test_smoketest_string_to_RectMap():\n## cells_per_row = 5\n## cells_per_column = 6\n## cell_width = 3\n## cell_height = 5\n## string_map = mapstrings['vertical_w_hole']\n## rect_map = string_to_RectMap(string_map, cell_width, cell_height)\n## cells = rect_map.get_in_region(0, 0,\n## cells_per_row * cell_width,\n## cells_per_column * cell_height)\n## assert len(cells)== cells_per_row * cells_per_column\n## non_empties = set(e for e in cells if e.cell is not None)\n## print(non_empties)\n## # remember rows begin counting from bottom due to openGL origin\n## assert ( set( (e.i, e.j) for e in non_empties ) ==\n## {(2, 0), (2,1), (2, 2), (2, 4), (2, 5) } )\n \n\n \n##class TestClass():\n## params = {\n## 'test_equals': [dict(a=1, b=2), dict(a=3, b=3), dict(a=5, b=4)],\n## 'test_zerodivision': [dict(a=1, b=0), dict(a=3, b=2)],\n## }\n## \n## def test_equals(self, a, b):\n## assert a == b\n## \n## def test_zerodivision(self, a, b):\n## py.test.raises(ZeroDivisionError, \"a/b\")\n##\n##class TestClass2():\n## params = {\n## \"test_concatenation\": [dict(r='a', s='b', res='ab'),\n## dict(r='aa', s='bb', res='aabb')]\n## }\n##\n## def test_concatenation(self, r, s, res):\n## assert r+s+'z' == res\n\nscenario = [ d for d in aux.case_generator(aux.first_expansion(maps_cache, aux.common_base_cases))]\n\n\n", "metadata": "root", "header": "['module', '___EOS___']", "index": 0 }, { "content": "def pytest_generate_tests(metafunc):\n # called once per each test function\n for funcargs in metafunc.cls.params[metafunc.function.__name__]:\n # schedule a new test function run with applied **funcargs\n metafunc.addcall(funcargs=funcargs)", "metadata": "root.pytest_generate_tests", "header": "['module', '___EOS___']", "index": 84 }, { "content": "class TestClass():\n params = {\n 'test_no_stuck': scenario,\n }\n", "metadata": "root.TestClass", "header": "['module', '___EOS___']", "index": 113 }, { "content": " def test_no_stuck(self, generic_id, tilemap, start_rect, dx, dy, expect_dxdy):\n collider = RectMapCollider()\n new = start_rect.copy()\n new.x += dx\n new.y += dy\n new_dx, new_dy = collider.collide_map(tilemap, start_rect, new, dx, dy)\n assert new.position == (start_rect.x + expect_dxdy[0],\n start_rect.y + expect_dxdy[1])\n # uncomment if changed behavior in RectMapCollider \n assert (new_dx, new_dy) == expect_dxdy", "metadata": "root.TestClass.test_no_stuck", "header": "['class', 'TestClass', '(', ')', ':', '___EOS___']", "index": 118 } ]
[ { "span": "import py", "start_line": 50, "start_column": 0, "end_line": 50, "end_column": 9 }, { "span": "import cocos", "start_line": 52, "start_column": 0, "end_line": 52, "end_column": 12 }, { "span": "import cocos.layer", "start_line": 53, "start_column": 0, "end_line": 53, "end_column": 18 } ]
[]
1
false
[ "[CLS]_", "Un", "used_", "import_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "#", " ", "-*-", " ", "codi", "ng", ":", " ", "utf", "-", "8", " ", "-*-", "_", "\\u\\u\\uNL\\u\\u\\u_", "\"\"\"", " ", "Test", "s", " ", "tha", "t", " ", "an", " ", "actor", " ", "usi", "ng", " ", "Rect", "Map", "Colli", "der", " ", "doe", "s", " ", "not", " ", "get", " ", "stu", "ck", "\\", "10", ";", "Run", " ", "the", " ", "tests", " ", "with", " ", "pytest", ".", "\\", "10", ";", "\\", "10", ";", "Implementation", " ", "description", "\\", "10", ";", " ", " ", " ", " ", "-", " ", "The", " ", "basic", " ", "situation", " ", "consider", "ed", " ", "is", "\\", "10", ";", " ", " ", "-", " ", "actor", " ", "touch", "ing", " ", "wall", " ", "in", " ", "one", " ", "of", " ", "it", " ", "side", "s", "\\", "10", ";", " ", " ", "-", " ", "request", "ed", " ", "to", " ", "move", " ", "a", " ", "dx", ",", " ", "dy", " ", "tha", "t", " ", "will", " ", "push", " ", "against", " ", "the", " ", "wall", " ", "and", "\\", "10", ";", " ", " ", " ", " ", "allow", " ", "free", " ", "movement", " ", "in", " ", "the", " ", "axis", " ", "not", " ", "block", "ed", " ", "by", " ", "the", " ", "wall", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "-", " ", "The", "y", " ", "are", " ", "so", " ", "many", " ", "small", " ", "variations", " ", "in", " ", "each", " ", "situation", " ", "proposed", " ", "tha", "t", "\\", "10", ";", " ", " ", "direct", "ly", " ", "writ", "ing", " ", "each", " ", "test", " ", "setup", " ", "wou", "ld", " ", "be", " ", "error", " ", "pron", "e", ",", " ", "so", " ", "a", " ", "layer", "ed", "\\", "10", ";", " ", " ", "case", " ", "generat", "or", " ", "appro", "ach", " ", "was", " ", "selecte", "d", "\\", "10", ";", " ", " ", "-", " ", "base", " ", "case", "s", " ", "dep", "ict", " ", "quali", "tative", " ", "dif", "eren", "t", " ", "situation", "s", " ", "as", " ", "a", "\\", "10", ";", " ", " ", " ", " ", " ", "(", "map", ",", " ", "actor", "\\u", "rect", ",", " ", "push", ",", " ", "sign", "ed", " ", "free", " ", "axis", " ", "vector", ")", "\\", "10", ";", " ", " ", "-", " ", "for", " ", "each", " ", "parametriz", "able", " ", "value", " ", ",", " ", "a", " ", "set", " ", "of", " ", "values", " ", "of", "\\", "10", ";", " ", " ", " ", " ", "interest", " ", "is", " ", "defin", "ed", "\\", "10", ";", " ", " ", "-", " ", "code", " ", "will", " ", "walk", " ", "the", " ", "(", "base", " ", "case", "s", ",", " ", "params", " ", "values", ")", " ", "generat", "ing", " ", "the", "\\", "10", ";", " ", " ", " ", " ", "concre", "te", " ", "case", "s", " ", "to", " ", "validat", "e", "\\", "10", ";", " ", " ", "-", " ", "as", " ", "an", " ", "implementation", " ", "deta", "il", ",", " ", "maps", " ", "will", " ", "be", " ", "cache", "d", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "-", " ", "params", " ", "desi", "red", " ", "to", " ", "change", "\\", "10", ";", " ", " ", " ", " ", "map", ":", " ", "the", " ", "basic", " ", "form", " ", "and", " ", "orientation", " ", "in", " ", "the", " ", "situation", "\\", "10", ";", " ", " ", " ", " ", "cell", "\\u", "size", ",", " ", "actor", "\\u", "size", ":", " ", "most", "ly", "\\", "10", ";", " ", " ", " ", "actor", " ", "side", " ", "z", " ", "<=", ">", " ", "cell", " ", "side", " ", "z", "\\", "10", ";", " ", " ", " ", "actor", " ", "side", " ", "odd", " ", "or", " ", "even", " ", "(", "bec", "aus", "e", " ", ".", "center", " ", "assi", "ngs", ";", " ", "divisi", "on", "\\u", "error", "s", "?)", "\\", "10", ";", " ", " ", " ", " ", "push", " ", "style", ":", " ", "dx", ",", " ", "dy", "\\", "10", ";", " ", " ", " ", " ", "actor", " ", "start", " ", "position", ":", " ", "move", " ", "the", " ", "start", " ", "position", " ", "along", " ", "the", " ", "wall", " ", "to", " ", "cover", "\\", "10", ";", " ", " ", "all", " ", "int", " ", "align", "ement", "s", " ", "with", " ", "the", " ", "grid", ",", " ", "ie", " ", "do", " ", "offset", "s", " ", "1", "..", "cell", "\\u", "widt", "h", " ", "if", "\\", "10", ";", " ", " ", "free", " ", "movement", " ", "axis", " ", "is", " ", "x", ",", " ", "...", " ", "\\", "10", ";\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "\\u\\u", "future\\u\\u_", "import_", "division_", ",_", "print", "\\u", "function_", ",_", "unicode", "\\u", "literals_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "tha", "t", " ", "simpli", "fie", "s", " ", "the", " ", "pyg", "let", " ", "mock", "up", " ", "needed_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "remember", " ", "to", " ", "erase", " ", "or", " ", "set", " ", "to", " ", "zero", " ", "for", " ", "normal", " ", "runs_", "\\u\\u\\uNL\\u\\u\\u_", "import_", "os_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "assert_", "os_", "._", "environ_", "[_", "'", "coco", "s", "\\u", "ute", "st", "'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "set", " ", "the", " ", "desi", "red", " ", "pyg", "let", " ", "mock", "up_", "\\u\\u\\uNL\\u\\u\\u_", "import_", "sys_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "sys_", "._", "path_", "._", "insert_", "(_", "0_", ",_", "'", "pyg", "let", "\\u", "mock", "up", "1", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "pyglet_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "assert_", "pyglet_", "._", "mock", "\\u", "level_", "==_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "will", " ", "use", " ", "the", " ", "coco", "s", " ", "in", " ", "the", " ", "same", " ", "check", "out", ",", " ", "except", " ", "if", " ", "you", " ", "move", " ", "this", " ", "file", "._", "\\u\\u\\uNL\\u\\u\\u_", "import_", "sys_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "os_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "sys_", "._", "path_", "._", "insert_", "(_", "0_", ",_", "os_", "._", "path_", "._", "join_", "(_", "os_", "._", "path_", "._", "dirname_", "(_", "\\u\\u", "file\\u\\u_", ")_", ",_", "'..'_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "for", " ", "py", ".", "test_", "\\u\\u\\uNL\\u\\u\\u_", "import_", "py_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "import_", "coco", "s_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "coco", "s_", "._", "layer_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "coco", "s_", "._", "tiles_", "import_", "Rect", "Map_", ",_", "Rect", "Cell_", ",_", "Rect", "Map", "Colli", "der_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "coco", "s_", "._", "rect_", "import_", "Rect_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "import_", "aux", "\\u", "Rect", "Map", "Colli", "der", "\\u\\u", "no", "\\u", "stu", "ck_", "as_", "aux_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "set", " ", "the", " ", "coco", "s", " ", "classe", "s", " ", "need", "ed", " ", "in", " ", "aux", " ", "bef", "ore", " ", "calling", " ", "any", " ", "function", " ", "there", "_", "\\u\\u\\uNL\\u\\u\\u_", "aux_", "._", "Rect", "Map", "\\u", "cls_", "=_", "Rect", "Map_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "aux_", "._", "Rect", "Cell_", "=_", "Rect", "Cell_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "aux_", "._", "Rect_", "=_", "Rect_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "maps", "\\u", "cache_", "=_", "aux_", "._", "generat", "e\\u", "maps_", "(_", "'-'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "##", "def", " ", "test\\u", "smoke", "test\\u", "string", "\\u", "to", "\\u", "Rect", "Map", "():", "_", "\\u\\u\\uNL\\u\\u\\u_", "##", " ", " ", " ", " ", "cells", "\\u", "per", "\\u", "row", " ", "=", " ", "5_", "\\u\\u\\uNL\\u\\u\\u_", "##", " ", " ", " ", " ", "cells", "\\u", "per", "\\u", "column", " ", "=", " ", "6_", "\\u\\u\\uNL\\u\\u\\u_", "##", " ", " ", " ", " ", "cell", "\\u", "widt", "h", " ", "=", " ", "3_", "\\u\\u\\uNL\\u\\u\\u_", "##", " ", " ", " ", " ", "cell", "\\u", "height", " ", "=", " ", "5_", "\\u\\u\\uNL\\u\\u\\u_", "##", " ", " ", " ", " ", "string", "\\u", "map", " ", "=", " ", "maps", "tring", "s", "['", "vertical", "\\u", "w", "\\u", "hole", "']", "_", "\\u\\u\\uNL\\u\\u\\u_", "##", " ", " ", " ", " ", "rect", "\\u", "map", " ", "=", " ", "string", "\\u", "to", "\\u", "Rect", "Map", "(", "string", "\\u", "map", ",", " ", "cell", "\\u", "widt", "h", ",", " ", "cell", "\\u", "height", ")_", "\\u\\u\\uNL\\u\\u\\u_", "##", " ", " ", " ", " ", "cells", " ", "=", " ", "rect", "\\u", "map", ".", "get", "\\u", "in", "\\u", "region", "(", "0", ",", " ", "0", ",_", "\\u\\u\\uNL\\u\\u\\u_", "##", " ", " ", " ", " ", " ", "cells", "\\u", "per", "\\u", "row", " ", "*", " ", "cell", "\\u", "widt", "h", ",_", "\\u\\u\\uNL\\u\\u\\u_", "##", " ", " ", " ", " ", " ", "cells", "\\u", "per", "\\u", "column", " ", "*", " ", "cell", "\\u", "height", ")_", "\\u\\u\\uNL\\u\\u\\u_", "##", " ", " ", " ", " ", "assert", " ", "len", "(", "cells", ")=", "=", " ", "cells", "\\u", "per", "\\u", "row", " ", "*", " ", "cells", "\\u", "per", "\\u", "column_", "\\u\\u\\uNL\\u\\u\\u_", "##", " ", " ", " ", " ", "non", "\\u", "emp", "ties", " ", "=", " ", "set", "(", "e", " ", "for", " ", "e", " ", "in", " ", "cells", " ", "if", " ", "e", ".", "cell", " ", "is", " ", "not", " ", "Non", "e", ")_", "\\u\\u\\uNL\\u\\u\\u_", "##", " ", " ", " ", " ", "print", "(", "non", "\\u", "emp", "ties", ")_", "\\u\\u\\uNL\\u\\u\\u_", "##", " ", " ", " ", " ", "#", " ", "remember", " ", "rows", " ", "begin", " ", "counti", "ng", " ", "from", " ", "bottom", " ", "due", " ", "to", " ", "open", "GL", " ", "origin_", "\\u\\u\\uNL\\u\\u\\u_", "##", " ", " ", " ", " ", "assert", " ", "(", " ", "set", "(", " ", "(", "e", ".", "i", ",", " ", "e", ".", "j", ")", " ", "for", " ", "e", " ", "in", " ", "non", "\\u", "emp", "ties", " ", ")", " ", "==_", "\\u\\u\\uNL\\u\\u\\u_", "##", " ", " ", " ", " ", " ", "{(", "2", ",", " ", "0", "),", " ", "(", "2", ",", "1", "),", " ", "(", "2", ",", " ", "2", "),", " ", "(", "2", ",", " ", "4", "),", " ", "(", "2", ",", " ", "5", ")", " ", "}", " ", ")_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "##", "class", " ", "Test", "Class", "():", "_", "\\u\\u\\uNL\\u\\u\\u_", "##", " ", " ", " ", " ", "params", " ", "=", " ", "{_", "\\u\\u\\uNL\\u\\u\\u_", "##", " ", " ", " ", " ", "'", "test\\u", "equals", "':", " ", "[", "dict", "(", "a", "=", "1", ",", " ", "b", "=", "2", "),", " ", "dict", "(", "a", "=", "3", ",", " ", "b", "=", "3", "),", " ", "dict", "(", "a", "=", "5", ",", " ", "b", "=", "4", ")]", ",_", "\\u\\u\\uNL\\u\\u\\u_", "##", " ", " ", " ", " ", "'", "test\\u", "zero", "divisi", "on", "':", " ", "[", "dict", "(", "a", "=", "1", ",", " ", "b", "=", "0", "),", " ", "dict", "(", "a", "=", "3", ",", " ", "b", "=", "2", ")]", ",_", "\\u\\u\\uNL\\u\\u\\u_", "##", " ", " ", " ", " ", "}_", "\\u\\u\\uNL\\u\\u\\u_", "##", " _", "\\u\\u\\uNL\\u\\u\\u_", "##", " ", " ", " ", " ", "def", " ", "test\\u", "equals", "(", "self", ",", " ", "a", ",", " ", "b", "):", "_", "\\u\\u\\uNL\\u\\u\\u_", "##", " ", " ", " ", " ", "assert", " ", "a", " ", "==", " ", "b_", "\\u\\u\\uNL\\u\\u\\u_", "##", " _", "\\u\\u\\uNL\\u\\u\\u_", "##", " ", " ", " ", " ", "def", " ", "test\\u", "zero", "divisi", "on", "(", "self", ",", " ", "a", ",", " ", "b", "):", "_", "\\u\\u\\uNL\\u\\u\\u_", "##", " ", " ", " ", " ", "py", ".", "test", ".", "raise", "s", "(", "Zero", "Divis", "ion", "Error", ",", " ", "\"", "a", "/", "b", "\")", "_", "\\u\\u\\uNL\\u\\u\\u_", "##", "_", "\\u\\u\\uNL\\u\\u\\u_", "##", "class", " ", "Test", "Class", "2", "():", "_", "\\u\\u\\uNL\\u\\u\\u_", "##", " ", " ", " ", " ", "params", " ", "=", " ", "{_", "\\u\\u\\uNL\\u\\u\\u_", "##", " ", " ", " ", " ", "\"", "test\\u", "concate", "nati", "on", "\":", " ", "[", "dict", "(", "r", "='", "a", "',", " ", "s", "='", "b", "',", " ", "res", "='", "ab", "')", ",_", "\\u\\u\\uNL\\u\\u\\u_", "##", " ", " ", " ", " ", " ", "dict", "(", "r", "='", "aa", "',", " ", "s", "='", "bb", "',", " ", "res", "='", "aab", "b", "')]", "_", "\\u\\u\\uNL\\u\\u\\u_", "##", " ", " ", " ", " ", "}_", "\\u\\u\\uNL\\u\\u\\u_", "##", "_", "\\u\\u\\uNL\\u\\u\\u_", "##", " ", " ", " ", " ", "def", " ", "test\\u", "concate", "nati", "on", "(", "self", ",", " ", "r", ",", " ", "s", ",", " ", "res", "):", "_", "\\u\\u\\uNL\\u\\u\\u_", "##", " ", " ", " ", " ", "assert", " ", "r", "+", "s", "+'", "z", "'", " ", "==", " ", "res_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "scenario_", "=_", "[_", "d_", "for_", "d_", "in_", "aux_", "._", "case", "\\u", "generator_", "(_", "aux_", "._", "first", "\\u", "expansion", "_", "(_", "maps", "\\u", "cache_", ",_", "aux_", "._", "common", "\\u", "base", "\\u", "cases_", ")_", ")_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "pytest", "\\u", "generat", "e\\u", "tests_", "(_", "metaf", "unc_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "call", "ed", " ", "onc", "e", " ", "per", " ", "each", " ", "test", " ", "function_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "for_", "func", "args_", "in_", "metaf", "unc_", "._", "cls_", "._", "params_", "[_", "metaf", "unc_", "._", "function_", "._", "\\u\\u", "name\\u\\u_", "]_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "schedule", " ", "a", " ", "new", " ", "test", " ", "function", " ", "run", " ", "with", " ", "applied", " ", "**", "func", "args_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "metaf", "unc_", "._", "addc", "all_", "(_", "func", "args_", "=_", "func", "args_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "class_", "Test", "Class_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "params_", "=_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "'", "test\\u", "no", "\\u", "stu", "ck", "'_", ":_", "scenario_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "[SEP]_", "class_", "Test", "Class_", "(_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "test\\u", "no", "\\u", "stu", "ck_", "(_", "self_", ",_", "gener", "ic", "\\u", "id_", ",_", "tile", "map_", ",_", "start", "\\u", "rect_", ",_", "dx_", ",_", "dy_", ",_", "expect", "\\u", "dx", "dy_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "collide", "r_", "=_", "Rect", "Map", "Colli", "der_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "new_", "=_", "start", "\\u", "rect_", "._", "copy_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "new_", "._", "x_", "+=_", "dx_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "new_", "._", "y_", "+=_", "dy_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "new", "\\u", "dx_", ",_", "new", "\\u", "dy_", "=_", "collide", "r_", "._", "collide", "\\u", "map_", "(_", "tile", "map_", ",_", "start", "\\u", "rect_", ",_", "new_", ",_", "dx_", ",_", "dy_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "assert_", "new_", "._", "position_", "==_", "(_", "start", "\\u", "rect_", "._", "x_", "+_", "expect", "\\u", "dx", "dy_", "[_", "0_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "start", "\\u", "rect_", "._", "y_", "+_", "expect", "\\u", "dx", "dy_", "[_", "1_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "uncomm", "ent", " ", "if", " ", "change", "d", " ", "behavior", " ", "in", " ", "Rect", "Map", "Colli", "der", " _", "\\u\\u\\uNL\\u\\u\\u_", "assert_", "(_", "new", "\\u", "dx_", ",_", "new", "\\u", "dy_", ")_", "==_", "expect", "\\u", "dx", "dy_" ]
[ 4, 4, 4, 4, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 ]
Except block handles 'BaseException'
ella/ella/ella/core/views.py
[ { "content": " @cache_this(archive_year_cache_key, timeout=60 * 60 * 24)\n def _archive_entry_year(self, category):\n \" Return ARCHIVE_ENTRY_YEAR from settings (if exists) or year of the newest object in category \"\n year = getattr(settings, 'ARCHIVE_ENTRY_YEAR', None)\n if not year:\n n = now()\n try:\n year = Listing.objects.filter(\n category__site__id=settings.SITE_ID,\n category__tree_path__startswith=category.tree_path,\n publish_from__lte=n\n ).values('publish_from')[0]['publish_from'].year\n except:\n year = n.year\n return year", "metadata": "root.ListContentType._archive_entry_year", "header": "['class', 'ListContentType', '(', 'EllaCoreView', ')', ':', '___EOS___']", "index": 319 } ]
[ { "span": "except:", "start_line": 331, "start_column": 12, "end_line": 331, "end_column": 19 } ]
[]
1
true
[ "[CLS]_", "Except", "_", "block_", "handles_", "'", "Base", "Except", "ion", "'_", "[SEP]_", "class_", "List", "Conten", "t", "Type_", "(_", "Ell", "a", "Core", "View_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "@_", "cache", "\\u", "this_", "(_", "archive", "\\u", "year", "\\u", "cache", "\\u", "key_", ",_", "timeout_", "=_", "60_", "*_", "60_", "*_", "24_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "\\u", "archive", "\\u", "entry", "\\u", "year_", "(_", "self_", ",_", "category_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"", " ", "Return", " ", "ARCHIVE", "\\u", "ENTR", "Y", "\\u", "YEA", "R", " ", "from", " ", "settings", " ", "(", "if", " ", "exist", "s", ")", " ", "or", " ", "year", " ", "of", " ", "the", " ", "newest", " ", "object", " ", "in", " ", "category", " ", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "year_", "=_", "getattr_", "(_", "settings_", ",_", "'", "ARCHIVE", "\\u", "ENTR", "Y", "\\u", "YEA", "R", "'_", ",_", "None_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "not_", "year_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "n_", "=_", "now_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "year_", "=_", "Listi", "ng_", "._", "objects_", "._", "filter_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "category", "\\u\\u", "site", "\\u\\u", "id_", "=_", "settings_", "._", "SITE", "\\u", "ID_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "category", "\\u\\u", "tree", "\\u", "path", "\\u\\u", "startswith_", "=_", "category_", "._", "tree", "\\u", "path_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "publi", "sh", "\\u", "from", "\\u\\u", "lte_", "=_", "n_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "._", "values_", "(_", "'", "publi", "sh", "\\u", "from", "'_", ")_", "[_", "0_", "]_", "[_", "'", "publi", "sh", "\\u", "from", "'_", "]_", "._", "year_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "year_", "=_", "n_", "._", "year_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "year_", "\\u\\u\\uNEWLINE\\u\\u\\u_" ]
[ 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 ]
Unused local variable
anandology/pyjamas/pyjs/src/pyjs/translator_dict.py
[ { "content": " def node_and_test(self, node, jsbool=False, name=None):\n jsvars = self.jsvars.copy()\n args = []\n childs = node.children.__iter__()\n if jsbool:\n name = None\n elif name is None:\n name = self.get_tmp_jsname('and$')\n self.add_lines(\"var %s\" % name)\n args.append(self.get_test(childs.next(), name))\n try:\n while True:\n self.assert_value(node, childs.next().value, 'and')\n args.append(self.get_test(childs.next(), name))\n except StopIteration:\n pass\n test = ' && '.join(args)\n if jsbool:\n return test\n return '(%s ? %s : %s)' % (test, name, name)", "metadata": "root.Translator.node_and_test", "header": "['class', 'Translator', '(', 'object', ')', ':', '___EOS___']", "index": 1124 }, { "content": " def node_except_clause(self, node):\n jsvars = self.jsvars.copy()\n childs = node.children.__iter__()\n self.assert_value(node, childs.next().value, 'except')\n classes = None\n varname = None\n try:\n child = childs.next()\n if isinstance(child, Node) and type_repr(child.type) == 'atom':\n self.assert_value(node, child.children[0].value, '(')\n self.assert_value(node, child.children[-1].value, ')')\n classes = self.dispatch(child.children[1])\n else:\n classes = self.dispatch(child)\n self.assert_value(node, childs.next().value, ',')\n varname = self.dispatch(childs.next(), assign=True)\n except StopIteration:\n pass\n if classes is not None:\n if not isinstance(classes, list):\n classes = [classes]\n tests = []\n return classes, varname\n return None, None", "metadata": "root.Translator.node_except_clause", "header": "['class', 'Translator', '(', 'object', ')', ':', '___EOS___']", "index": 1598 }, { "content": " def node_if_stmt(self, node):\n jsvars = self.jsvars.copy()\n childs = node.children.__iter__()\n try:\n while True:\n stmt = childs.next()\n if stmt.value == 'if':\n test = self.get_test(childs.next())\n test = \"if (%s) {\" % test\n self.add_lines(test, self.track_lineno(stmt))\n elif stmt.value == 'elif':\n test = self.get_test(childs.next())\n test = \"} else if (%s) {\" % test\n self.add_lines(test)\n elif stmt.value == 'else':\n self.add_lines('} else {')\n self.assert_value(node, childs.next().value, ':')\n self.indent()\n self.dispatch(childs.next())\n self.dedent()\n except StopIteration:\n pass\n self.add_lines(\"}\")", "metadata": "root.Translator.node_if_stmt", "header": "['class', 'Translator', '(', 'object', ')', ':', '___EOS___']", "index": 2224 }, { "content": " def node_or_test(self, node, jsbool=False, name=None):\n jsvars = self.jsvars.copy()\n args = []\n childs = node.children.__iter__()\n if jsbool:\n name = None\n elif name is None:\n name = self.get_tmp_jsname('or$')\n self.add_lines(\"var %s\" % name)\n args.append(self.get_test(childs.next(), name))\n try:\n while True:\n self.assert_value(node, childs.next().value, 'or')\n args.append(self.get_test(childs.next(), name))\n except StopIteration:\n pass\n test = ' || '.join(args)\n if jsbool:\n return test\n return '(%s ? %s : %s)' % (test, name, name)", "metadata": "root.Translator.node_or_test", "header": "['class', 'Translator', '(', 'object', ')', ':', '___EOS___']", "index": 2459 }, { "content": " def node_test(self, node):\n jsvars = self.jsvars.copy()\n childs = node.children.__iter__()\n left = self.dispatch(childs.next())\n self.assert_value(node, childs.next().value, 'if')\n test = self.get_test(childs.next())\n self.assert_value(node, childs.next().value, 'else')\n right = self.dispatch(childs.next())\n return '%s ? %s : %s' % (test, left, right)", "metadata": "root.Translator.node_test", "header": "['class', 'Translator', '(', 'object', ')', ':', '___EOS___']", "index": 2758 }, { "content": "def translate(compiler, sources, output_file, module_name=None, **kw):\n global TranslationError\n kw = dict(all_compile_options, **kw)\n list_imports = kw.get('list_imports', False)\n sources = map(os.path.abspath, sources)\n output_file = os.path.abspath(output_file)\n if not module_name:\n module_name, extension = os.path.splitext(os.path.basename(sources[0]))\n\n translator = Translator(sources[0], module_name, kw)\n TranslationError = translator.TranslationError\n trees = []\n tree = None\n for src in sources:\n current_tree = translator.ast_tree_creator(src)\n flags = set()\n f = file(src)\n for l in f:\n if l.startswith('#@PYJS_'):\n flags.add(l.strip()[7:])\n f.close()\n if tree:\n tree = translator.tree_merge(tree, current_tree, flags)\n else:\n tree = current_tree\n #XXX: if we have an override the sourcefile and the tree is not the same!\n f = file(sources[0], \"r\")\n src = f.read()\n f.close()\n if list_imports:\n # TODO: use ImportVisitor instead of Translator\n translator.dispatch_file(tree)\n return translator.imported_modules.keys(), translator.imported_js.keys()\n v = ImportVisitor(module_name)\n compiler.walk(tree, v)\n return v.imported_modules, v.imported_js\n\n translator.dispatch_file(tree)\n\n if output_file == '-':\n output = sys.stdout\n else:\n output = file(output_file, 'w')\n output.write(translator.get_javascript())\n output.close()\n return sorted(translator.imported_modules.keys()), sorted(translator.imported_js.keys())", "metadata": "root.translate", "header": "['module', '___EOS___']", "index": 3141 }, { "content": " def visitFrom(self, node):\n if node.modname == '__pyjamas__':\n return\n if node.modname == '__javascript__':\n return\n # XXX: hack for in-function checking, we should have another\n # object to check our scope\n absPath = False\n modname = node.modname\n if hasattr(node, 'level') and node.level > 0:\n absPath = True\n modname = self.module_name.split('.')\n level = node.level\n if len(modname) < level:\n raise TranslationError(\n \"Attempted relative import beyond toplevel package\",\n node, self.module_name)\n if node.modname != '':\n level += 1\n if level > 1:\n modname = '.'.join(modname[:-(node.level-1)])\n else:\n modname = self.module_name\n if node.modname != '':\n modname += '.' + node.modname\n if modname[0] == '.':\n modname = modname[1:]\n for name in node.names:\n sub = modname + '.' + name[0]\n ass_name = name[1] or name[0]\n self._doImport(((sub, ass_name),))", "metadata": "root.ImportVisitor.visitFrom", "header": "['class', 'ImportVisitor', '(', 'object', ')', ':', '___EOS___']", "index": 3217 } ]
[ { "span": "jsvars ", "start_line": 1125, "start_column": 8, "end_line": 1125, "end_column": 14 }, { "span": "jsvars ", "start_line": 1599, "start_column": 8, "end_line": 1599, "end_column": 14 }, { "span": "tests ", "start_line": 1619, "start_column": 12, "end_line": 1619, "end_column": 17 }, { "span": "jsvars ", "start_line": 2225, "start_column": 8, "end_line": 2225, "end_column": 14 }, { "span": "jsvars ", "start_line": 2460, "start_column": 8, "end_line": 2460, "end_column": 14 }, { "span": "jsvars ", "start_line": 2759, "start_column": 8, "end_line": 2759, "end_column": 14 }, { "span": "trees ", "start_line": 3152, "start_column": 4, "end_line": 3152, "end_column": 9 }, { "span": "src ", "start_line": 3168, "start_column": 4, "end_line": 3168, "end_column": 7 }, { "span": "absPath ", "start_line": 3227, "start_column": 12, "end_line": 3227, "end_column": 19 } ]
[]
1
true
[ "[CLS]_", "Un", "used_", "local_", "variable_", "[SEP]_", "class_", "Translator_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "node", "\\u", "and", "\\u", "test_", "(_", "self_", ",_", "node_", ",_", "js", "bool_", "=_", "False_", ",_", "name_", "=_", "None_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "js", "vars_", "=_", "self_", "._", "js", "vars_", "._", "copy_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "args_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "childs_", "=_", "node_", "._", "children_", "._", "\\u\\u", "iter\\u\\u_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "js", "bool_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "name_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "name_", "is_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "name_", "=_", "self_", "._", "get", "\\u", "tmp", "\\u", "js", "name_", "(_", "'", "and", "$'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "add", "\\u", "lines_", "(_", "\"", "var", " ", "%", "s", "\"_", "%_", "name_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "args_", "._", "append_", "(_", "self_", "._", "get", "\\u", "test_", "(_", "childs_", "._", "next_", "(_", ")_", ",_", "name_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "while_", "True_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "assert", "\\u", "value_", "(_", "node_", ",_", "childs_", "._", "next_", "(_", ")_", "._", "value_", ",_", "'", "and", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "args_", "._", "append_", "(_", "self_", "._", "get", "\\u", "test_", "(_", "childs_", "._", "next_", "(_", ")_", ",_", "name_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "Sto", "p", "Iteration_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "pass_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "test_", "=_", "'", " ", "&&", " ", "'_", "._", "join_", "(_", "args_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "js", "bool_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "test_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "'(", "%", "s", " ", "?", " ", "%", "s", " ", ":", " ", "%", "s", ")'_", "%_", "(_", "test_", ",_", "name_", ",_", "name_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Translator_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "node", "\\u", "except", "\\u", "clause_", "(_", "self_", ",_", "node_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "js", "vars_", "=_", "self_", "._", "js", "vars_", "._", "copy_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "childs_", "=_", "node_", "._", "children_", "._", "\\u\\u", "iter\\u\\u_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "\\u", "value_", "(_", "node_", ",_", "childs_", "._", "next_", "(_", ")_", "._", "value_", ",_", "'", "except", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "classes_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "varname_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "child_", "=_", "childs_", "._", "next_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "isinstance_", "(_", "child_", ",_", "Node_", ")_", "and_", "type", "\\u", "repr_", "(_", "child_", "._", "type_", ")_", "==_", "'", "atom", "'_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "assert", "\\u", "value_", "(_", "node_", ",_", "child_", "._", "children_", "[_", "0_", "]_", "._", "value_", ",_", "'('_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "\\u", "value_", "(_", "node_", ",_", "child_", "._", "children_", "[_", "-_", "1_", "]_", "._", "value_", ",_", "')'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "classes_", "=_", "self_", "._", "dispatch_", "(_", "child_", "._", "children_", "[_", "1_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "classes_", "=_", "self_", "._", "dispatch_", "(_", "child_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "assert", "\\u", "value_", "(_", "node_", ",_", "childs_", "._", "next_", "(_", ")_", "._", "value_", ",_", "','_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "varname_", "=_", "self_", "._", "dispatch_", "(_", "childs_", "._", "next_", "(_", ")_", ",_", "assign_", "=_", "True_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "Sto", "p", "Iteration_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "pass_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "classes_", "is_", "not_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "not_", "isinstance_", "(_", "classes_", ",_", "list_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "classes_", "=_", "[_", "classes_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "tests_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "classes_", ",_", "varname_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "None_", ",_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Translator_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "node", "\\u", "if", "\\u", "stmt_", "(_", "self_", ",_", "node_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "js", "vars_", "=_", "self_", "._", "js", "vars_", "._", "copy_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "childs_", "=_", "node_", "._", "children_", "._", "\\u\\u", "iter\\u\\u_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "while_", "True_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "stmt_", "=_", "childs_", "._", "next_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "stmt_", "._", "value_", "==_", "'", "if", "'_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "test_", "=_", "self_", "._", "get", "\\u", "test_", "(_", "childs_", "._", "next_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "test_", "=_", "\"", "if", " ", "(%", "s", ")", " ", "{\"_", "%_", "test_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "add", "\\u", "lines_", "(_", "test_", ",_", "self_", "._", "track", "\\u", "lineno_", "(_", "stmt_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "stmt_", "._", "value_", "==_", "'", "eli", "f", "'_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "test_", "=_", "self_", "._", "get", "\\u", "test_", "(_", "childs_", "._", "next_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "test_", "=_", "\"}", " ", "else", " ", "if", " ", "(%", "s", ")", " ", "{\"_", "%_", "test_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "add", "\\u", "lines_", "(_", "test_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "stmt_", "._", "value_", "==_", "'", "else", "'_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "self_", "._", "add", "\\u", "lines_", "(_", "'}", " ", "else", " ", "{'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "assert", "\\u", "value_", "(_", "node_", ",_", "childs_", "._", "next_", "(_", ")_", "._", "value_", ",_", "':'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "indent_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "dispatch_", "(_", "childs_", "._", "next_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "dedent_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "Sto", "p", "Iteration_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "pass_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "add", "\\u", "lines_", "(_", "\"}\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Translator_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "node", "\\u", "or", "\\u", "test_", "(_", "self_", ",_", "node_", ",_", "js", "bool_", "=_", "False_", ",_", "name_", "=_", "None_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "js", "vars_", "=_", "self_", "._", "js", "vars_", "._", "copy_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "args_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "childs_", "=_", "node_", "._", "children_", "._", "\\u\\u", "iter\\u\\u_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "js", "bool_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "name_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "name_", "is_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "name_", "=_", "self_", "._", "get", "\\u", "tmp", "\\u", "js", "name_", "(_", "'", "or", "$'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "add", "\\u", "lines_", "(_", "\"", "var", " ", "%", "s", "\"_", "%_", "name_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "args_", "._", "append_", "(_", "self_", "._", "get", "\\u", "test_", "(_", "childs_", "._", "next_", "(_", ")_", ",_", "name_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "while_", "True_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "assert", "\\u", "value_", "(_", "node_", ",_", "childs_", "._", "next_", "(_", ")_", "._", "value_", ",_", "'", "or", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "args_", "._", "append_", "(_", "self_", "._", "get", "\\u", "test_", "(_", "childs_", "._", "next_", "(_", ")_", ",_", "name_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "Sto", "p", "Iteration_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "pass_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "test_", "=_", "'", " ", "||", " ", "'_", "._", "join_", "(_", "args_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "js", "bool_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "test_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "'(", "%", "s", " ", "?", " ", "%", "s", " ", ":", " ", "%", "s", ")'_", "%_", "(_", "test_", ",_", "name_", ",_", "name_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Translator_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "node", "\\u", "test_", "(_", "self_", ",_", "node_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "js", "vars_", "=_", "self_", "._", "js", "vars_", "._", "copy_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "childs_", "=_", "node_", "._", "children_", "._", "\\u\\u", "iter\\u\\u_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "left_", "=_", "self_", "._", "dispatch_", "(_", "childs_", "._", "next_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "\\u", "value_", "(_", "node_", ",_", "childs_", "._", "next_", "(_", ")_", "._", "value_", ",_", "'", "if", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "test_", "=_", "self_", "._", "get", "\\u", "test_", "(_", "childs_", "._", "next_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "\\u", "value_", "(_", "node_", ",_", "childs_", "._", "next_", "(_", ")_", "._", "value_", ",_", "'", "else", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "right_", "=_", "self_", "._", "dispatch_", "(_", "childs_", "._", "next_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "'%", "s", " ", "?", " ", "%", "s", " ", ":", " ", "%", "s", "'_", "%_", "(_", "test_", ",_", "left_", ",_", "right_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "translate_", "(_", "compiler_", ",_", "sources_", ",_", "output", "\\u", "file_", ",_", "module", "\\u", "name_", "=_", "None_", ",_", "**_", "kw_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "global_", "Translat", "ion", "Error_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "kw_", "=_", "dict_", "(_", "all", "\\u", "compile", "\\u", "options_", ",_", "**_", "kw_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "list", "\\u", "imports_", "=_", "kw_", "._", "get_", "(_", "'", "list", "\\u", "import", "s", "'_", ",_", "False_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "sources_", "=_", "map_", "(_", "os_", "._", "path_", "._", "abspath_", ",_", "sources_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "output", "\\u", "file_", "=_", "os_", "._", "path_", "._", "abspath_", "(_", "output", "\\u", "file_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "not_", "module", "\\u", "name_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "module", "\\u", "name_", ",_", "extension_", "=_", "os_", "._", "path_", "._", "splitext_", "(_", "os_", "._", "path_", "._", "basename_", "(_", "sources_", "[_", "0_", "]_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "translator_", "=_", "Translator_", "(_", "sources_", "[_", "0_", "]_", ",_", "module", "\\u", "name_", ",_", "kw_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "Translat", "ion", "Error_", "=_", "translator_", "._", "Translat", "ion", "Error_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "trees_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "tree_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "src_", "in_", "sources_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "current", "\\u", "tree_", "=_", "translator_", "._", "ast", "\\u", "tree", "\\u", "creator_", "(_", "src_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "flags_", "=_", "set_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "f_", "=_", "file_", "(_", "src_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "l_", "in_", "f_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "l_", "._", "startswith_", "(_", "'#", "@", "PY", "JS", "\\u'_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "flags_", "._", "add_", "(_", "l_", "._", "strip_", "(_", ")_", "[_", "7_", ":_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "f_", "._", "close_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "tree_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "tree_", "=_", "translator_", "._", "tree", "\\u", "merge_", "(_", "tree_", ",_", "current", "\\u", "tree_", ",_", "flags_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "tree_", "=_", "current", "\\u", "tree_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", "XX", "X", ":", " ", "if", " ", "we", " ", "have", " ", "an", " ", "override", " ", "the", " ", "sourcef", "ile", " ", "and", " ", "the", " ", "tree", " ", "is", " ", "not", " ", "the", " ", "same", "!", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "f_", "=_", "file_", "(_", "sources_", "[_", "0_", "]_", ",_", "\"", "r", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "src_", "=_", "f_", "._", "read_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "f_", "._", "close_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "list", "\\u", "imports_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "TOD", "O", ":", " ", "use", " ", "Import", "Visit", "or", " ", "inst", "ead", " ", "of", " ", "Translator_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "translator_", "._", "dispatch", "\\u", "file_", "(_", "tree_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "translator_", "._", "import", "ed", "\\u", "modules_", "._", "keys_", "(_", ")_", ",_", "translator_", "._", "import", "ed", "\\u", "js_", "._", "keys_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "v_", "=_", "Import", "Visitor_", "(_", "module", "\\u", "name_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "compiler_", "._", "walk_", "(_", "tree_", ",_", "v_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "v_", "._", "import", "ed", "\\u", "modules_", ",_", "v_", "._", "import", "ed", "\\u", "js_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "translator_", "._", "dispatch", "\\u", "file_", "(_", "tree_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "output", "\\u", "file_", "==_", "'-'_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "output_", "=_", "sys_", "._", "stdout_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "output_", "=_", "file_", "(_", "output", "\\u", "file_", ",_", "'", "w", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "output_", "._", "write_", "(_", "translator_", "._", "get", "\\u", "javascript", "_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "output_", "._", "close_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "sorted_", "(_", "translator_", "._", "import", "ed", "\\u", "modules_", "._", "keys_", "(_", ")_", ")_", ",_", "sorted_", "(_", "translator_", "._", "import", "ed", "\\u", "js_", "._", "keys_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Import", "Visitor_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "visit", "From_", "(_", "self_", ",_", "node_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "node_", "._", "modname_", "==_", "'\\u", "\\u", "pyj", "ama", "s", "\\u\\u'_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "node_", "._", "modname_", "==_", "'\\u", "\\u", "javascript", "\\u\\u'_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "XX", "X", ":", " ", "hack", " ", "for", " ", "in", "-", "function", " ", "checking", ",", " ", "we", " ", "shou", "ld", " ", "have", " ", "anot", "her_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "object", " ", "to", " ", "check", " ", "our", " ", "scope_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "abs", "Path_", "=_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "modname_", "=_", "node_", "._", "modname_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "hasattr_", "(_", "node_", ",_", "'", "level", "'_", ")_", "and_", "node_", "._", "level_", ">_", "0_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "abs", "Path_", "=_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "modname_", "=_", "self_", "._", "module", "\\u", "name_", "._", "split_", "(_", "'.'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "level_", "=_", "node_", "._", "level_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "len_", "(_", "modname_", ")_", "<_", "level_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "raise_", "Translat", "ion", "Error_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "Atte", "mpte", "d", " ", "relative", " ", "import", " ", "be", "yon", "d", " ", "toplevel", " ", "package", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "node_", ",_", "self_", "._", "module", "\\u", "name_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "node_", "._", "modname_", "!=_", "''_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "level_", "+=_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "level_", ">_", "1_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "modname_", "=_", "'.'_", "._", "join_", "(_", "modname_", "[_", ":_", "-_", "(_", "node_", "._", "level_", "-_", "1_", ")_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "modname_", "=_", "self_", "._", "module", "\\u", "name_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "node_", "._", "modname_", "!=_", "''_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "modname_", "+=_", "'.'_", "+_", "node_", "._", "modname_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "modname_", "[_", "0_", "]_", "==_", "'.'_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "modname_", "=_", "modname_", "[_", "1_", ":_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "for_", "name_", "in_", "node_", "._", "names_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "sub_", "=_", "modname_", "+_", "'.'_", "+_", "name_", "[_", "0_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "ass", "\\u", "name_", "=_", "name_", "[_", "1_", "]_", "or_", "name_", "[_", "0_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "\\u", "do", "Import_", "(_", "(_", "(_", "sub_", ",_", "ass", "\\u", "name_", ")_", ",_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_" ]
[ 4, 4, 4, 4, 4, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2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2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 ]
Except block handles 'BaseException'
rawdigits/bouncer/example/redis-loaders/host.py
[ { "content": "def process_data(data):\n global metric\n #print data\n if data['type'] == 'request':\n time = ((data['time']/1000)/granularity)*granularity\n TIME_LENGTH=10\n\n try:\n metric[\"%s-%s\" % (time, data['host'])] += 1\n except:\n metric[\"%s-%s\" % (time, data['host'])] = 1\n\n if b.check():\n #using slices in these because it seems faster..\n for k,v in metric.items():\n time, host = k[0:10], k[11:]\n r.zincrby(time+\"-hosts\", host, v)\n\n metric.clear()", "metadata": "root.process_data", "header": "['module', '___EOS___']", "index": 14 } ]
[ { "span": "except:", "start_line": 23, "start_column": 4, "end_line": 23, "end_column": 11 } ]
[]
1
true
[ "[CLS]_", "Except", "_", "block_", "handles_", "'", "Base", "Except", "ion", "'_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "process", "\\u", "data_", "(_", "data_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "global_", "metric_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", "print", " ", "data_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "data_", "[_", "'", "type", "'_", "]_", "==_", "'", "request", "'_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "time_", "=_", "(_", "(_", "data_", "[_", "'", "time", "'_", "]_", "/_", "1000_", ")_", "/_", "granularity", "_", ")_", "*_", "granularity", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "TIME", "\\u", "LENGTH_", "=_", "10_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "metric_", "[_", "\"%", "s", "-%", "s", "\"_", "%_", "(_", "time_", ",_", "data_", "[_", "'", "host", "'_", "]_", ")_", "]_", "+=_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "metric_", "[_", "\"%", "s", "-%", "s", "\"_", "%_", "(_", "time_", ",_", "data_", "[_", "'", "host", "'_", "]_", ")_", "]_", "=_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "b_", "._", "check_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", "usi", "ng", " ", "slice", "s", " ", "in", " ", "these", " ", "bec", "aus", "e", " ", "it", " ", "see", "ms", " ", "faste", "r", "..", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "for_", "k_", ",_", "v_", "in_", "metric_", "._", "items_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "time_", ",_", "host_", "=_", "k_", "[_", "0_", ":_", "10_", "]_", ",_", "k_", "[_", "11_", ":_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "r_", "._", "zin", "cr", "by_", "(_", "time_", "+_", "\"-", "host", "s", "\"_", ",_", "host_", ",_", "v_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "metric_", "._", "clear_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_" ]
[ 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 ]
Imprecise assert
crossbario/autobahn-python/autobahn/wamp/test/test_auth.py
[ { "content": " def test_compute_totp(self):\n pat = re.compile(u\"\\d{6}\")\n secret = u\"MFRGGZDFMZTWQ2LK\"\n signature = auth.compute_totp(secret)\n self.assertEqual(type(signature), six.text_type)\n self.assertTrue(pat.match(signature) is not None)", "metadata": "root.TestWampAuthHelpers.test_compute_totp", "header": "['class', 'TestWampAuthHelpers', '(', 'unittest', '.', 'TestCase', ')', ':', '___EOS___']", "index": 90 }, { "content": " def test_compute_totp_offset(self):\n pat = re.compile(u\"\\d{6}\")\n secret = u\"MFRGGZDFMZTWQ2LK\"\n for offset in range(-10, 10):\n signature = auth.compute_totp(secret, offset)\n self.assertEqual(type(signature), six.text_type)\n self.assertTrue(pat.match(signature) is not None)", "metadata": "root.TestWampAuthHelpers.test_compute_totp_offset", "header": "['class', 'TestWampAuthHelpers', '(', 'unittest', '.', 'TestCase', ')', ':', '___EOS___']", "index": 97 } ]
[ { "span": "self.assertTrue(pat.match(signature) is not None)", "start_line": 95, "start_column": 8, "end_line": 95, "end_column": 57 }, { "span": "self.assertTrue(pat.match(signature) is not None)", "start_line": 103, "start_column": 12, "end_line": 103, "end_column": 61 } ]
[]
1
true
[ "[CLS]_", "Imp", "reci", "se_", "assert_", "[SEP]_", "class_", "Test", "Wa", "mp", "Auth", "Helpers_", "(_", "unittest_", "._", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "compute", "\\u", "tot", "p_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "pat_", "=_", "re_", "._", "compile_", "(_", "u", "\"\\\\", "d", "{", "6", "}\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "secret_", "=_", "u", "\"", "MF", "RG", "GZ", "DF", "MZ", "TW", "Q2", "LK", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "signature_", "=_", "auth_", "._", "compute", "\\u", "tot", "p_", "(_", "secret_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "type_", "(_", "signature_", ")_", ",_", "six_", "._", "text", "\\u", "type_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "pat_", "._", "match_", "(_", "signature_", ")_", "is_", "not_", "None_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Test", "Wa", "mp", "Auth", "Helpers_", "(_", "unittest_", "._", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "compute", "\\u", "tot", "p", "\\u", "offset_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "pat_", "=_", "re_", "._", "compile_", "(_", "u", "\"\\\\", "d", "{", "6", "}\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "secret_", "=_", "u", "\"", "MF", "RG", "GZ", "DF", "MZ", "TW", "Q2", "LK", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "offset_", "in_", "range_", "(_", "-_", "10_", ",_", "10_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "signature_", "=_", "auth_", "._", "compute", "\\u", "tot", "p_", "(_", "secret_", ",_", "offset_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "type_", "(_", "signature_", ")_", ",_", "six_", "._", "text", "\\u", "type_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "pat_", "._", "match_", "(_", "signature_", ")_", "is_", "not_", "None_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_" ]
[ 4, 4, 4, 4, 4, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2 ]
Unused import
cigroup-ol/windml/examples_alt/prediction/svr_response_curve.py
[ { "content": "\"\"\"\nResponse Curve of a Turbine\n--------------------------------------------------\n\nThe response curve is the mapping from wind speed to wind power production. In\nthis example the response curve is learned via support vector regression.\n\"\"\"\n\n# Author: Nils A. Treiber <[email protected]>\n# License: BSD 3 clause\n\nfrom matplotlib import dates\nimport matplotlib.pylab as plt\nimport datetime, time\nimport numpy as np\n\nfrom numpy import array, matrix\nfrom sklearn.grid_search import GridSearchCV\nfrom sklearn.cross_validation import KFold\nfrom sklearn import __version__ as sklearn_version\nfrom sklearn.svm import SVR\n\nfrom sklearn.neighbors import KNeighborsRegressor\nfrom windml.datasets.nrel import NREL\nfrom windml.visualization.plot_response_curve import plot_response_curve\n\n\nds = NREL()\nturbine = ds.get_turbine(NREL.park_id['palmsprings'], 2004, 2006)\ntimeseries = turbine.get_measurements()\nmax_speed = 40\nskip = 1\n\n\n# plot true values as blue points\nspeed = [m[2] for m in timeseries[::skip]]\nscore = [m[1] for m in timeseries[::skip]]\n\n\n# Second Plot: KNN-Interpolation\n# Built patterns und labels\nX_train = speed[0:len(speed):1]\nY_train = score[0:len(score):1]\nX_train_array = array([[element] for element in X_train])\n\n# initialize KNN regressor from sklearn.\nk_neighbors = 30\nknn = KNeighborsRegressor(k_neighbors, 'uniform')\n\n# fitting the pattern-label pairs\nT = np.linspace(0, max_speed, 500)[:, np.newaxis]\nY_hat = knn.fit(X_train_array, Y_train).predict(T)\n\n\n# Last Plot\nstart_speed = 15\nthreshold = 25\nelements = max_speed-start_speed\n\nnum_over_thres = np.zeros((elements), dtype=np.int)\nnum_below_thres = np.zeros((elements), dtype=np.int)\n\nfor i in range(len(X_train)):\n elem = 0\n for j in range(start_speed, max_speed):\n act_value = np.float32(j)\n if (X_train[i] >= (act_value) and X_train[i] < (act_value+1.0)):\n if (Y_train[i] < threshold):\n num_below_thres[elem] += 1\n else:\n num_over_thres[elem] += 1\n elem += 1\n\n\nfraction = np.zeros(max_speed, dtype=np.float32)\nfor i in range(start_speed, len(fraction)):\n if (np.float32(num_below_thres[i-start_speed]+num_over_thres[i-start_speed]) > 0):\n fraction[i] = np.float32(num_below_thres[i-start_speed])/(num_below_thres[i-start_speed]+num_over_thres[i-start_speed])\n else:\n fraction[i] = -1\nprint fraction\n\n\n\nfigure = plt.figure(figsize=(15, 10))\nplot_abs = plt.subplot(2, 2, 1)\nplt.title(\"Measurements\")\nplt.scatter(speed, score, color=\"b\")\nplt.xlim([-1, max_speed])\nplt.xlabel(\"Windspeed [m/s]\")\nplt.ylim([-2, 32])\nplt.ylabel(\"Correct Score [MW]\")\n\nplot_scatter = plt.subplot(2, 2, 2)\nplt.title(\"KNN Interpolation of the Response Curve\")\nplt.plot(T, Y_hat, color='b')\nplt.scatter(speed, score, color=\"#CCCCCC\")\nplt.xlim([-1, max_speed])\nplt.xlabel(\"Windspeed [m/s]\")\nplt.ylim([-2, 32])\nplt.ylabel(\"Correct Score [MW]\")\n\nplot_abs = plt.subplot(2, 2, 3)\nplt.title(\"Distribution of Wind Speeds\")\nplt.hist( X_train, bins=np.float(max_speed), histtype='stepfilled', normed=True, color='b')\nplt.xlim([-1, max_speed])\nplt.ylim(-0.01, 0.13)\nplt.xlabel(\"Windspeed [m/s]\")\nplt.ylabel(\"Relative Frequency\")\n\nplot_scatter = plt.subplot(2, 2, 4)\nplt.title(\"Frequency of Cut-Outs\")\nsteps = range(40)\nplt.plot(steps, fraction, \"o\", color='b')\nplt.xlim([-1,max_speed])\nplt.xlabel(\"Windspeed [m/s]\")\nplt.ylim([-0.1, 1.1])\nplt.ylabel(\"Probabilty of Cut-Out Events (Thres = 15)\")\n\nplt.show()\n\n\n", "metadata": "root", "header": "['module', '___EOS___']", "index": 0 } ]
[ { "span": "from matplotlib import dates", "start_line": 11, "start_column": 0, "end_line": 11, "end_column": 28 }, { "span": "import datetime, time", "start_line": 13, "start_column": 0, "end_line": 13, "end_column": 21 }, { "span": "from numpy import array, matrix", "start_line": 16, "start_column": 0, "end_line": 16, "end_column": 31 }, { "span": "from sklearn.grid_search import GridSearchCV", "start_line": 17, "start_column": 0, "end_line": 17, "end_column": 44 }, { "span": "from sklearn.cross_validation import KFold", "start_line": 18, "start_column": 0, "end_line": 18, "end_column": 42 }, { "span": "from sklearn import __version__ as sklearn_version", "start_line": 19, "start_column": 0, "end_line": 19, "end_column": 50 }, { "span": "from sklearn.svm import SVR", "start_line": 20, "start_column": 0, "end_line": 20, "end_column": 27 }, { "span": "from windml.visualization.plot_response_curve import plot_response_curve", "start_line": 24, "start_column": 0, "end_line": 24, "end_column": 72 } ]
[]
1
false
[ "[CLS]_", "Un", "used_", "import_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\"\"\"", "\\", "10", ";", "Respons", "e", " ", "Curve", " ", "of", " ", "a", " ", "Turb", "ine", "\\", "10", ";", "--------------", "--------------", "--------------", "--------", "\\", "10", ";", "\\", "10", ";", "The", " ", "response", " ", "curve", " ", "is", " ", "the", " ", "mapping", " ", "from", " ", "wind", " ", "speed", " ", "to", " ", "wind", " ", "power", " ", "producti", "on", ".", " ", "In", "\\", "10", ";", "this", " ", "example", " ", "the", " ", "response", " ", "curve", " ", "is", " ", "learned", " ", "via", " ", "support", " ", "vector", " ", "regress", "ion", ".", "\\", "10", ";\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Author", ":", " ", "Ni", "ls", " ", "A", ".", " ", "Tre", "ibe", "r", " ", "<", "nil", "s", ".", "andr", "e", ".", "tre", "ibe", "r", "@", "uni", "-", "old", "enb", "urg", ".", "de", ">_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "License", ":", " ", "BS", "D", " ", "3", " ", "clause_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "from_", "matplotlib_", "import_", "dates_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "matplotlib_", "._", "pylab_", "as_", "plt_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "datetime_", ",_", "time_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "numpy_", "as_", "np_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "from_", "numpy_", "import_", "array_", ",_", "matrix_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "sklearn_", "._", "grid", "\\u", "search_", "import_", "Grid", "Sear", "ch", "CV_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "sklearn_", "._", "cross", "\\u", "validation_", "import_", "KF", "old_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "sklearn_", "import_", "\\u\\u", "version\\u\\u_", "as_", "skl", "earn", "\\u", "version_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "sklearn_", "._", "svm_", "import_", "SV", "R_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "from_", "sklearn_", "._", "neighbors_", "import_", "KN", "eig", "hbo", "rs", "Regressor_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "wind", "ml_", "._", "datasets_", "._", "nre", "l_", "import_", "NR", "EL_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "wind", "ml_", "._", "visualization", "_", "._", "plot", "\\u", "response", "\\u", "curve_", "import_", "plot", "\\u", "response", "\\u", "curve_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "ds_", "=_", "NR", "EL_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "turb", "ine_", "=_", "ds_", "._", "get", "\\u", "turb", "ine_", "(_", "NR", "EL_", "._", "park", "\\u", "id_", "[_", "'", "pal", "msp", "rings", "'_", "]_", ",_", "2004", "_", ",_", "2006", "_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "timeseries_", "=_", "turb", "ine_", "._", "get", "\\u", "measurements_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "max", "\\u", "speed_", "=_", "40_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "skip_", "=_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "plot", " ", "true", " ", "values", " ", "as", " ", "blue", " ", "points_", "\\u\\u\\uNL\\u\\u\\u_", "speed_", "=_", "[_", "m_", "[_", "2_", "]_", "for_", "m_", "in_", "timeseries_", "[_", ":_", ":_", "skip_", "]_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "score_", "=_", "[_", "m_", "[_", "1_", "]_", "for_", "m_", "in_", "timeseries_", "[_", ":_", ":_", "skip_", "]_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Second", " ", "Plot", ":", " ", "KN", "N", "-", "Interpolation", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Bu", "ilt", " ", "pattern", "s", " ", "und", " ", "labels_", "\\u\\u\\uNL\\u\\u\\u_", "X", "\\u", "train_", "=_", "speed_", "[_", "0_", ":_", "len_", "(_", "speed_", ")_", ":_", "1_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "Y", "\\u", "train_", "=_", "score_", "[_", "0_", ":_", "len_", "(_", "score_", ")_", ":_", "1_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "X", "\\u", "train", "\\u", "array_", "=_", "array_", "(_", "[_", "[_", "element_", "]_", "for_", "element_", "in_", "X", "\\u", "train_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "initialize", " ", "KN", "N", " ", "regressor", " ", "from", " ", "skl", "earn", "._", "\\u\\u\\uNL\\u\\u\\u_", "k", "\\u", "neighbors_", "=_", "30_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "knn", "_", "=_", "KN", "eig", "hbo", "rs", "Regressor_", "(_", "k", "\\u", "neighbors_", ",_", "'", "uniform", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "fitting", " ", "the", " ", "pattern", "-", "label", " ", "pairs_", "\\u\\u\\uNL\\u\\u\\u_", "T_", "=_", "np_", "._", "linspace_", "(_", "0_", ",_", "max", "\\u", "speed_", ",_", "500_", ")_", "[_", ":_", ",_", "np_", "._", "newaxis_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "Y", "\\u", "hat_", "=_", "knn", "_", "._", "fit_", "(_", "X", "\\u", "train", "\\u", "array_", ",_", "Y", "\\u", "train_", ")_", "._", "predict_", "(_", "T_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Las", "t", " ", "Plot_", "\\u\\u\\uNL\\u\\u\\u_", "start", "\\u", "speed_", "=_", "15_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "threshold_", "=_", "25_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "elements_", "=_", "max", "\\u", "speed_", "-_", "start", "\\u", "speed_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "num", "\\u", "over", "\\u", "thres", "_", "=_", "np_", "._", "zeros_", "(_", "(_", "elements_", ")_", ",_", "dtype_", "=_", "np_", "._", "int_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "num", "\\u", "belo", "w", "\\u", "thres", "_", "=_", "np_", "._", "zeros_", "(_", "(_", "elements_", ")_", ",_", "dtype_", "=_", "np_", "._", "int_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "for_", "i_", "in_", "range_", "(_", "len_", "(_", "X", "\\u", "train_", ")_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "elem_", "=_", "0_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "j_", "in_", "range_", "(_", "start", "\\u", "speed_", ",_", "max", "\\u", "speed_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "act", "\\u", "value_", "=_", "np_", "._", "float32_", "(_", "j_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "(_", "X", "\\u", "train_", "[_", "i_", "]_", ">=_", "(_", "act", "\\u", "value_", ")_", "and_", "X", "\\u", "train_", "[_", "i_", "]_", "<_", "(_", "act", "\\u", "value_", "+_", "1.0_", ")_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "(_", "Y", "\\u", "train_", "[_", "i_", "]_", "<_", "threshold_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "num", "\\u", "belo", "w", "\\u", "thres", "_", "[_", "elem_", "]_", "+=_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "num", "\\u", "over", "\\u", "thres", "_", "[_", "elem_", "]_", "+=_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elem_", "+=_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "fraction_", "=_", "np_", "._", "zeros_", "(_", "max", "\\u", "speed_", ",_", "dtype_", "=_", "np_", "._", "float32_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "i_", "in_", "range_", "(_", "start", "\\u", "speed_", ",_", "len_", "(_", "fraction_", ")_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "(_", "np_", "._", "float32_", "(_", "num", "\\u", "belo", "w", "\\u", "thres", "_", "[_", "i_", "-_", "start", "\\u", "speed_", "]_", "+_", "num", "\\u", "over", "\\u", "thres", "_", "[_", "i_", "-_", "start", "\\u", "speed_", "]_", ")_", ">_", "0_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "fraction_", "[_", "i_", "]_", "=_", "np_", "._", "float32_", "(_", "num", "\\u", "belo", "w", "\\u", "thres", "_", "[_", "i_", "-_", "start", "\\u", "speed_", "]_", ")_", "/_", "(_", "num", "\\u", "belo", "w", "\\u", "thres", "_", "[_", "i_", "-_", "start", "\\u", "speed_", "]_", "+_", "num", "\\u", "over", "\\u", "thres", "_", "[_", "i_", "-_", "start", "\\u", "speed_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "fraction_", "[_", "i_", "]_", "=_", "-_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "print_", "fraction_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "figure_", "=_", "plt_", "._", "figure_", "(_", "figsize_", "=_", "(_", "15_", ",_", "10_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "plot", "\\u", "abs_", "=_", "plt_", "._", "subplot_", "(_", "2_", ",_", "2_", ",_", "1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "plt_", "._", "title_", "(_", "\"", "Measurement", "s", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "plt_", "._", "scatter_", "(_", "speed_", ",_", "score_", ",_", "color_", "=_", "\"", "b", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "plt_", "._", "xlim_", "(_", "[_", "-_", "1_", ",_", "max", "\\u", "speed_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "plt_", "._", "xlabel_", "(_", "\"", "Wind", "speed", " ", "[", "m", "/", "s", "]\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "plt_", "._", "ylim_", "(_", "[_", "-_", "2_", ",_", "32_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "plt_", "._", "ylabel_", "(_", "\"", "Correct", " ", "Score", " ", "[", "MW", "]\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "plot", "\\u", "scatter_", "=_", "plt_", "._", "subplot_", "(_", "2_", ",_", "2_", ",_", "2_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "plt_", "._", "title_", "(_", "\"", "KN", "N", " ", "Interpolation", " ", "of", " ", "the", " ", "Respons", "e", " ", "Curve", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "plt_", "._", "plot_", "(_", "T_", ",_", "Y", "\\u", "hat_", ",_", "color_", "=_", "'", "b", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "plt_", "._", "scatter_", "(_", "speed_", ",_", "score_", ",_", "color_", "=_", "\"#", "CCCC", "CC", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "plt_", "._", "xlim_", "(_", "[_", "-_", "1_", ",_", "max", "\\u", "speed_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "plt_", "._", "xlabel_", "(_", "\"", "Wind", "speed", " ", "[", "m", "/", "s", "]\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "plt_", "._", "ylim_", "(_", "[_", "-_", "2_", ",_", "32_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "plt_", "._", "ylabel_", "(_", "\"", "Correct", " ", "Score", " ", "[", "MW", "]\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "plot", "\\u", "abs_", "=_", "plt_", "._", "subplot_", "(_", "2_", ",_", "2_", ",_", "3_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "plt_", "._", "title_", "(_", "\"", "Distribut", "ion", " ", "of", " ", "Wind", " ", "Spee", "ds", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "plt_", "._", "hist_", "(_", "X", "\\u", "train_", ",_", "bins_", "=_", "np_", "._", "float_", "(_", "max", "\\u", "speed_", ")_", ",_", "hist", "type_", "=_", "'", "step", "filled", "'_", ",_", "normed_", "=_", "True_", ",_", "color_", "=_", "'", "b", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "plt_", "._", "xlim_", "(_", "[_", "-_", "1_", ",_", "max", "\\u", "speed_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "plt_", "._", "ylim_", "(_", "-_", "0.01_", ",_", "0.13", "_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "plt_", "._", "xlabel_", "(_", "\"", "Wind", "speed", " ", "[", "m", "/", "s", "]\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "plt_", "._", "ylabel_", "(_", "\"", "Relative", " ", "Freq", "uenc", "y", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "plot", "\\u", "scatter_", "=_", "plt_", "._", "subplot_", "(_", "2_", ",_", "2_", ",_", "4_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "plt_", "._", "title_", "(_", "\"", "Freq", "uenc", "y", " ", "of", " ", "Cut", "-", "Outs", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "steps_", "=_", "range_", "(_", "40_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "plt_", "._", "plot_", "(_", "steps_", ",_", "fraction_", ",_", "\"", "o", "\"_", ",_", "color_", "=_", "'", "b", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "plt_", "._", "xlim_", "(_", "[_", "-_", "1_", ",_", "max", "\\u", "speed_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "plt_", "._", "xlabel_", "(_", "\"", "Wind", "speed", " ", "[", "m", "/", "s", "]\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "plt_", "._", "ylim_", "(_", "[_", "-_", "0.1_", ",_", "1.1_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "plt_", "._", "ylabel_", "(_", "\"", "Prob", "abi", "lty", " ", "of", " ", "Cut", "-", "Out", " ", "Event", "s", " ", "(", "Thre", "s", " ", "=", " ", "15", ")\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "plt_", "._", "show_", "(_", ")_" ]
[ 4, 4, 4, 4, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 0, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 0, 1, 1, 1, 1, 1, 2, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 0, 1, 1, 1, 1, 1, 1, 1, 1, 2, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 0, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 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2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 ]
Except block handles 'BaseException'
treeio/treeio/treeio/messaging/views.py
[ { "content": "@handle_response_format\n@treeio_login_required\n@_process_mass_form\ndef stream_view(request, stream_id, response_format='html'):\n \"Stream view page\"\n\n user = request.user.profile\n\n stream = get_object_or_404(MessageStream, pk=stream_id)\n if not request.user.profile.has_permission(stream):\n return user_denied(request, message=\"You don't have access to this Stream\",\n response_format=response_format)\n\n if request.user.profile.has_permission(stream, mode='x'):\n if request.POST:\n message = Message()\n message.author = user.get_contact()\n if not message.author:\n return user_denied(request,\n message=\"You can't send message without a Contact Card assigned to you.\",\n response_format=response_format)\n\n form = MessageForm(\n request.user.profile, None, None, request.POST, instance=message)\n if form.is_valid():\n message = form.save()\n message.recipients.add(user.get_contact())\n message.set_user_from_request(request)\n message.read_by.add(user)\n try:\n # if email entered create contact and add to recipients\n if 'multicomplete_recipients' in request.POST and request.POST['multicomplete_recipients']:\n try:\n conf = ModuleSetting.get_for_module(\n 'treeio.messaging', 'default_contact_type')[0]\n default_contact_type = ContactType.objects.get(\n pk=long(conf.value))\n except Exception:\n default_contact_type = None\n emails = request.POST[\n 'multicomplete_recipients'].split(',')\n for email in emails:\n emailstr = unicode(email).strip()\n if re.match('[a-zA-Z0-9+_\\-\\.]+@[0-9a-zA-Z][.-0-9a-zA-Z]*.[a-zA-Z]+', emailstr):\n contact, created = Contact.get_or_create_by_email(\n emailstr, contact_type=default_contact_type)\n message.recipients.add(contact)\n if created:\n contact.set_user_from_request(request)\n except:\n pass\n # send email to all recipients\n message.send_email()\n\n return HttpResponseRedirect(reverse('messaging_stream_view', args=[stream.id]))\n else:\n form = MessageForm(request.user.profile, stream_id)\n\n else:\n form = None\n\n objects = Object.filter_by_request(request, Message.objects.filter(\n reply_to__isnull=True, stream=stream).order_by('-date_created'))\n context = _get_default_context(request)\n context.update({'messages': objects,\n 'form': form,\n 'stream': stream})\n\n return render_to_response('messaging/stream_view', context,\n context_instance=RequestContext(request),\n response_format=response_format)", "metadata": "root.stream_view", "header": "['module', '___EOS___']", "index": 218 }, { "content": "@handle_response_format\n@treeio_login_required\ndef stream_checkmail(request, stream_id, response_format='html'):\n \"Stream check mail\"\n user = request.user.profile\n\n stream = get_object_or_404(MessageStream, pk=stream_id)\n if not user.has_permission(stream):\n return user_denied(request, message=\"You don't have access to this Stream\",\n response_format=response_format)\n\n try:\n stream.process_email()\n messages.add_message(\n request, messages.INFO, _(\"E-mails fetched successfully.\"), fail_silently=True)\n except:\n try:\n messages.add_message(request, messages.ERROR, _(\n \"Failed to retrieve messages for this stream. Please check stream settings\"), fail_silently=True)\n except:\n pass\n\n return HttpResponseRedirect(reverse('messaging_stream_view', args=[stream.id]))", "metadata": "root.stream_checkmail", "header": "['module', '___EOS___']", "index": 322 }, { "content": "@handle_response_format\n@treeio_login_required\ndef messaging_compose(request, response_format='html'):\n \"New message page\"\n\n user = request.user.profile\n\n if request.POST:\n if 'cancel' not in request.POST:\n message = Message()\n message.author = user.get_contact()\n if not message.author:\n return user_denied(request,\n message=\"You can't send message without a Contact Card assigned to you.\",\n response_format=response_format)\n\n form = MessageForm(\n request.user.profile, None, None, request.POST, instance=message)\n if form.is_valid():\n message = form.save()\n message.recipients.add(user.get_contact())\n message.set_user_from_request(request)\n message.read_by.add(user)\n try:\n # if email entered create contact and add to recipients\n if 'multicomplete_recipients' in request.POST and request.POST['multicomplete_recipients']:\n try:\n conf = ModuleSetting.get_for_module(\n 'treeio.messaging', 'default_contact_type')[0]\n default_contact_type = ContactType.objects.get(\n pk=long(conf.value))\n except Exception:\n default_contact_type = None\n emails = request.POST[\n 'multicomplete_recipients'].split(',')\n for email in emails:\n emailstr = unicode(email).strip()\n if re.match('[a-zA-Z0-9+_\\-\\.]+@[0-9a-zA-Z][.-0-9a-zA-Z]*.[a-zA-Z]+', emailstr):\n contact, created = Contact.get_or_create_by_email(\n emailstr, contact_type=default_contact_type)\n message.recipients.add(contact)\n if created:\n contact.set_user_from_request(request)\n except:\n pass\n # send email to all recipients\n message.send_email()\n\n return HttpResponseRedirect(reverse('messaging'))\n else:\n return HttpResponseRedirect(reverse('messaging'))\n\n else:\n form = MessageForm(request.user.profile, None)\n\n context = _get_default_context(request)\n context.update({'form': form})\n\n return render_to_response('messaging/message_compose', context,\n context_instance=RequestContext(request), response_format=response_format)", "metadata": "root.messaging_compose", "header": "['module', '___EOS___']", "index": 376 }, { "content": "@handle_response_format\n@treeio_login_required\ndef messaging_view(request, message_id, response_format='html'):\n \"Single message page\"\n\n message = get_object_or_404(Message, pk=message_id)\n user = request.user.profile\n\n if not user.has_permission(message):\n return user_denied(request, message=\"You don't have access to this Message\",\n response_format=response_format)\n\n message.read_by.add(user)\n\n if request.POST and request.POST.get('body', False):\n \"Unread message\"\n\n reply = Message()\n reply.author = user.get_contact()\n if not reply.author:\n return user_denied(request,\n message=\"You can't send message without a Contact Card assigned to you.\",\n response_format=response_format)\n reply.reply_to = message\n form = MessageReplyForm(\n user, message.stream_id, message, request.POST, instance=reply)\n if form.is_valid():\n reply = form.save()\n reply.set_user_from_request(request)\n # Add author to recipients\n reply.recipients.add(reply.author)\n message.read_by.clear()\n\n try:\n # if email entered create contact and add to recipients\n if 'multicomplete_recipients' in request.POST and request.POST['multicomplete_recipients']:\n try:\n conf = ModuleSetting.get_for_module(\n 'treeio.messaging', 'default_contact_type')[0]\n default_contact_type = ContactType.objects.get(\n pk=long(conf.value))\n except Exception:\n default_contact_type = None\n emails = request.POST[\n 'multicomplete_recipients'].split(',')\n for email in emails:\n emailstr = unicode(email).strip()\n if re.match('[a-zA-Z0-9+_\\-\\.]+@[0-9a-zA-Z][.-0-9a-zA-Z]*.[a-zA-Z]+', emailstr):\n contact, created = Contact.get_or_create_by_email(\n emailstr, contact_type=default_contact_type)\n reply.recipients.add(contact)\n if created:\n contact.set_user_from_request(request)\n except:\n pass\n\n # Add each recipient of the reply to the original message\n for recipient in reply.recipients.all():\n message.recipients.add(recipient)\n\n # send email to all recipients\n reply.send_email()\n\n return HttpResponseRedirect(reverse('messaging_message_view', args=[message.id]))\n\n else:\n form = MessageReplyForm(\n request.user.profile, message.stream_id, message)\n\n replies = Object.filter_by_request(request,\n Message.objects.filter(reply_to=message).order_by('date_created'))\n\n context = _get_default_context(request)\n context.update({'message': message,\n 'messages': replies,\n 'form': form})\n\n return render_to_response('messaging/message_view', context,\n context_instance=RequestContext(request),\n response_format=response_format)", "metadata": "root.messaging_view", "header": "['module', '___EOS___']", "index": 438 }, { "content": "@handle_response_format\n@treeio_login_required\ndef settings_view(request, response_format='html'):\n \"Settings admin view\"\n\n # default content type\n try:\n conf = ModuleSetting.get_for_module('treeio.messaging', 'default_contact_type',\n user=request.user.profile)[0]\n default_contact_type = ContactType.objects.get(pk=long(conf.value))\n except:\n default_contact_type = None\n\n # default imap folder\n try:\n conf = ModuleSetting.get_for_module(\n 'treeio.messaging', 'default_imap_folder')[0]\n default_imap_folder = conf.value\n except:\n default_imap_folder = getattr(\n settings, 'HARDTREE_MESSAGING_IMAP_DEFAULT_FOLDER_NAME', 'UNSEEN')\n\n # signature\n try:\n conf = ModuleSetting.get_for_module('treeio.messaging', 'signature',\n user=request.user.profile, strict=True)[0]\n signature = conf.value\n except:\n signature = ''\n\n types = Object.filter_by_request(\n request, ContactType.objects.order_by('name'))\n\n context = _get_default_context(request)\n context.update({'types': types,\n 'signature': signature,\n 'default_contact_type': default_contact_type,\n 'default_imap_folder': default_imap_folder})\n\n return render_to_response('messaging/settings_view', context,\n context_instance=RequestContext(request),\n response_format=response_format)", "metadata": "root.settings_view", "header": "['module', '___EOS___']", "index": 680 } ]
[ { "span": "except:", "start_line": 267, "start_column": 16, "end_line": 267, "end_column": 23 }, { "span": "except:", "start_line": 337, "start_column": 4, "end_line": 337, "end_column": 11 }, { "span": "except:", "start_line": 341, "start_column": 8, "end_line": 341, "end_column": 15 }, { "span": "except:", "start_line": 419, "start_column": 16, "end_line": 419, "end_column": 23 }, { "span": "except:", "start_line": 491, "start_column": 12, "end_line": 491, "end_column": 19 }, { "span": "except:", "start_line": 690, "start_column": 4, "end_line": 690, "end_column": 11 }, { "span": "except:", "start_line": 698, "start_column": 4, "end_line": 698, "end_column": 11 }, { "span": "except:", "start_line": 707, "start_column": 4, "end_line": 707, "end_column": 11 } ]
[]
1
true
[ "[CLS]_", "Except", "_", "block_", "handles_", "'", "Base", "Except", "ion", "'_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "@_", "handle", "\\u", "response", "\\u", "format_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "@_", "treei", "o", "\\u", "login", "\\u", "required_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "@_", "\\u", "process", "\\u", "mass", "\\u", "form_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "stream", "\\u", "view_", "(_", "request_", ",_", "stream", "\\u", "id_", ",_", "response", "\\u", "format_", "=_", "'", "html", "'_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"", "Stream", " ", "view", " ", "page", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "user_", "=_", "request_", "._", "user_", "._", "profile_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "stream_", "=_", "get", "\\u", "object\\u", "or", "\\u", "404_", "(_", "Messag", "e", "Stream_", ",_", "pk_", "=_", "stream", "\\u", "id_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "not_", "request_", "._", "user_", "._", "profile_", "._", "has", "\\u", "permission_", "(_", "stream_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "user", "\\u", "deni", "ed_", "(_", "request_", ",_", "message_", "=_", "\"", "You", " ", "don", "'", "t", " ", "have", " ", "access", " ", "to", " ", "this", " ", "Stream", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "response", "\\u", "format_", "=_", "response", "\\u", "format_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "request_", "._", "user_", "._", "profile_", "._", "has", "\\u", "permission_", "(_", "stream_", ",_", "mode_", "=_", "'", "x", "'_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "request_", "._", "POST_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "message_", "=_", "Message_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "message_", "._", "author_", "=_", "user_", "._", "get", "\\u", "contact_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "not_", "message_", "._", "author_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "user", "\\u", "deni", "ed_", "(_", "request_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "message_", "=_", "\"", "You", " ", "can", "'", "t", " ", "send", " ", "message", " ", "with", "out", " ", "a", " ", "Conta", "ct", " ", "Card", " ", "assign", "ed", " ", "to", " ", "you", ".\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "response", "\\u", "format_", "=_", "response", "\\u", "format_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "form_", "=_", "Messag", "e", "Form_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "request_", "._", "user_", "._", "profile_", ",_", "None_", ",_", "None_", ",_", "request_", "._", "POST_", ",_", "instance_", "=_", "message_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "form_", "._", "is", "\\u", "valid_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "message_", "=_", "form_", "._", "save_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "message_", "._", "recipients_", "._", "add_", "(_", "user_", "._", "get", "\\u", "contact_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "message_", "._", "set\\u", "user", "\\u", "from", "\\u", "request_", "(_", "request_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "message_", "._", "read", "\\u", "by_", "._", "add_", "(_", "user_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "if", " ", "email", " ", "enter", "ed", " ", "create", " ", "contact", " ", "and", " ", "add", " ", "to", " ", "recipients_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "if_", "'", "multico", "mplet", "e\\u", "recip", "ients", "'_", "in_", "request_", "._", "POST_", "and_", "request_", "._", "POST_", "[_", "'", "multico", "mplet", "e\\u", "recip", "ients", "'_", "]_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "conf_", "=_", "Modul", "e", "Setting_", "._", "get", "\\u", "for", "\\u", "module_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "'", "treei", "o", ".", "mess", "agin", "g", "'_", ",_", "'", "default", "\\u", "contact", "\\u", "type", "'_", ")_", "[_", "0_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "default", "\\u", "contact", "\\u", "type_", "=_", "Conta", "ct", "Type_", "._", "objects_", "._", "get_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "pk_", "=_", "long_", "(_", "conf_", "._", "value_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "Exception_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "default", "\\u", "contact", "\\u", "type_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "emails_", "=_", "request_", "._", "POST_", "[_", "\\u\\u\\uNL\\u\\u\\u_", "'", "multico", "mplet", "e\\u", "recip", "ients", "'_", "]_", "._", "split_", "(_", "','_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "email_", "in_", "emails_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "email", "str_", "=_", "unicode_", "(_", "email_", ")_", "._", "strip_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "re_", "._", "match_", "(_", "'[", "a", "-", "z", "A", "-", "Z", "0", "-", "9", "+\\u", "\\\\-\\", "\\", ".]+", "@[", "0", "-", "9", "a", "-", "z", "A", "-", "Z", "][", ".-", "0", "-", "9", "a", "-", "z", "A", "-", "Z", "]*", ".", "[", "a", "-", "z", "A", "-", "Z", "]+'_", ",_", "email", "str_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "contact_", ",_", "created_", "=_", "Contact_", "._", "get", "\\u", "or", "\\u", "create", "\\u", "by", "\\u", "email_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "email", "str_", ",_", "contact", "\\u", "type_", "=_", "default", "\\u", "contact", "\\u", "type_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "message_", "._", "recipients_", "._", "add_", "(_", "contact_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "created_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "contact_", "._", "set\\u", "user", "\\u", "from", "\\u", "request_", "(_", "request_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "pass_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "send", " ", "email", " ", "to", " ", "all", " ", "recipients_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "message_", "._", "send", "\\u", "email_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "return_", "Http", "Respons", "e", "Redirect_", "(_", "reverse_", "(_", "'", "mess", "agin", "g", "\\u", "stream", "\\u", "view", "'_", ",_", "args_", "=_", "[_", "stream_", "._", "id_", "]_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "form_", "=_", "Messag", "e", "Form_", "(_", "request_", "._", "user_", "._", "profile_", ",_", "stream", "\\u", "id_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "form_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "objects_", "=_", "Object_", "._", "filter", "\\u", "by", "\\u", "request_", "(_", "request_", ",_", "Message_", "._", "objects_", "._", "filter_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "repl", "y", "\\u", "to", "\\u\\u", "isnull_", "=_", "True_", ",_", "stream_", "=_", "stream_", ")_", "._", "order", "\\u", "by_", "(_", "'-", "date", "\\u", "created", "'_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "context_", "=_", "\\u", "get", "\\u", "default", "\\u", "context_", "(_", "request_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "context_", "._", "update_", "(_", "{_", "'", "message", "s", "'_", ":_", "objects_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "form", "'_", ":_", "form_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "stream", "'_", ":_", "stream_", "}_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "return_", "render", "\\u", "to", "\\u", "response_", "(_", "'", "mess", "agin", "g", "/", "stream", "\\u", "view", "'_", ",_", "context_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "context", "\\u", "instance_", "=_", "Request", "Context_", "(_", "request_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "response", "\\u", "format_", "=_", "response", "\\u", "format_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "@_", "handle", "\\u", "response", "\\u", "format_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "@_", "treei", "o", "\\u", "login", "\\u", "required_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "stream", "\\u", "check", "mail_", "(_", "request_", ",_", "stream", "\\u", "id_", ",_", "response", "\\u", "format_", "=_", "'", "html", "'_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"", "Stream", " ", "check", " ", "mail", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "user_", "=_", "request_", "._", "user_", "._", "profile_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "stream_", "=_", "get", "\\u", "object\\u", "or", "\\u", "404_", "(_", "Messag", "e", "Stream_", ",_", "pk_", "=_", "stream", "\\u", "id_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "not_", "user_", "._", "has", "\\u", "permission_", "(_", "stream_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "user", "\\u", "deni", "ed_", "(_", "request_", ",_", "message_", "=_", "\"", "You", " ", "don", "'", "t", " ", "have", " ", "access", " ", "to", " ", "this", " ", "Stream", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "response", "\\u", "format_", "=_", "response", "\\u", "format_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "stream_", "._", "process", "\\u", "email_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "messages_", "._", "add", "\\u", "message_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "request_", ",_", "messages_", "._", "INFO_", ",_", "\\u_", "(_", "\"", "E-", "mails", " ", "fetched", " ", "success", "full", "y", ".\"_", ")_", ",_", "fail", "\\u", "silently", "_", "=_", "True_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "messages_", "._", "add", "\\u", "message_", "(_", "request_", ",_", "messages_", "._", "ERROR_", ",_", "\\u_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "Fail", "ed", " ", "to", " ", "retrieve", " ", "message", "s", " ", "for", " ", "this", " ", "stream", ".", " ", "Ple", "ase", " ", "check", " ", "stream", " ", "settings", "\"_", ")_", ",_", "fail", "\\u", "silently", "_", "=_", "True_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "pass_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "Http", "Respons", "e", "Redirect_", "(_", "reverse_", "(_", "'", "mess", "agin", "g", "\\u", "stream", "\\u", "view", "'_", ",_", "args_", "=_", "[_", "stream_", "._", "id_", "]_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "@_", "handle", "\\u", "response", "\\u", "format_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "@_", "treei", "o", "\\u", "login", "\\u", "required_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "mess", "agin", "g", "\\u", "compose_", "(_", "request_", ",_", "response", "\\u", "format_", "=_", "'", "html", "'_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"", "New", " ", "message", " ", "page", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "user_", "=_", "request_", "._", "user_", "._", "profile_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "request_", "._", "POST_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "'", "cancel", "'_", "not_", "in_", "request_", "._", "POST_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "message_", "=_", "Message_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "message_", "._", "author_", "=_", "user_", "._", "get", "\\u", "contact_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "not_", "message_", "._", "author_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "user", "\\u", "deni", "ed_", "(_", "request_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "message_", "=_", "\"", "You", " ", "can", "'", "t", " ", "send", " ", "message", " ", "with", "out", " ", "a", " ", "Conta", "ct", " ", "Card", " ", "assign", "ed", " ", "to", " ", "you", ".\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "response", "\\u", "format_", "=_", "response", "\\u", "format_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "form_", "=_", "Messag", "e", "Form_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "request_", "._", "user_", "._", "profile_", ",_", "None_", ",_", "None_", ",_", "request_", "._", "POST_", ",_", "instance_", "=_", "message_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "form_", "._", "is", "\\u", "valid_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "message_", "=_", "form_", "._", "save_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "message_", "._", "recipients_", "._", "add_", "(_", "user_", "._", "get", "\\u", "contact_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "message_", "._", "set\\u", "user", "\\u", "from", "\\u", "request_", "(_", "request_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "message_", "._", "read", "\\u", "by_", "._", "add_", "(_", "user_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "if", " ", "email", " ", "enter", "ed", " ", "create", " ", "contact", " ", "and", " ", "add", " ", "to", " ", "recipients_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "if_", "'", "multico", "mplet", "e\\u", "recip", "ients", "'_", "in_", "request_", "._", "POST_", "and_", "request_", "._", "POST_", "[_", "'", "multico", "mplet", "e\\u", "recip", "ients", "'_", "]_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "conf_", "=_", "Modul", "e", "Setting_", "._", "get", "\\u", "for", "\\u", "module_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "'", "treei", "o", ".", "mess", "agin", "g", "'_", ",_", "'", "default", "\\u", "contact", "\\u", "type", "'_", ")_", "[_", "0_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "default", "\\u", "contact", "\\u", "type_", "=_", "Conta", "ct", "Type_", "._", "objects_", "._", "get_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "pk_", "=_", "long_", "(_", "conf_", "._", "value_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "Exception_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "default", "\\u", "contact", "\\u", "type_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "emails_", "=_", "request_", "._", "POST_", "[_", "\\u\\u\\uNL\\u\\u\\u_", "'", "multico", "mplet", "e\\u", "recip", "ients", "'_", "]_", "._", "split_", "(_", "','_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "email_", "in_", "emails_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "email", "str_", "=_", "unicode_", "(_", "email_", ")_", "._", "strip_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "re_", "._", "match_", "(_", "'[", "a", "-", "z", "A", "-", "Z", "0", "-", "9", "+\\u", "\\\\-\\", "\\", ".]+", "@[", "0", "-", "9", "a", "-", "z", "A", "-", "Z", "][", ".-", "0", "-", "9", "a", "-", "z", "A", "-", "Z", "]*", ".", "[", "a", "-", "z", "A", "-", "Z", "]+'_", ",_", "email", "str_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "contact_", ",_", "created_", "=_", "Contact_", "._", "get", "\\u", "or", "\\u", "create", "\\u", "by", "\\u", "email_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "email", "str_", ",_", "contact", "\\u", "type_", "=_", "default", "\\u", "contact", "\\u", "type_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "message_", "._", "recipients_", "._", "add_", "(_", "contact_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "created_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "contact_", "._", "set\\u", "user", "\\u", "from", "\\u", "request_", "(_", "request_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "pass_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "send", " ", "email", " ", "to", " ", "all", " ", "recipients_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "message_", "._", "send", "\\u", "email_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "return_", "Http", "Respons", "e", "Redirect_", "(_", "reverse_", "(_", "'", "mess", "agin", "g", "'_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "Http", "Respons", "e", "Redirect_", "(_", "reverse_", "(_", "'", "mess", "agin", "g", "'_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "form_", "=_", "Messag", "e", "Form_", "(_", "request_", "._", "user_", "._", "profile_", ",_", "None_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "context_", "=_", "\\u", "get", "\\u", "default", "\\u", "context_", "(_", "request_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "context_", "._", "update_", "(_", "{_", "'", "form", "'_", ":_", "form_", "}_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "return_", "render", "\\u", "to", "\\u", "response_", "(_", "'", "mess", "agin", "g", "/", "message", "\\u", "compose", "'_", ",_", "context_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "context", "\\u", "instance_", "=_", "Request", "Context_", "(_", "request_", ")_", ",_", "response", "\\u", "format_", "=_", "response", "\\u", "format_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "@_", "handle", "\\u", "response", "\\u", "format_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "@_", "treei", "o", "\\u", "login", "\\u", "required_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "mess", "agin", "g", "\\u", "view_", "(_", "request_", ",_", "message", "\\u", "id_", ",_", "response", "\\u", "format_", "=_", "'", "html", "'_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"", "Sing", "le", " ", "message", " ", "page", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "message_", "=_", "get", "\\u", "object\\u", "or", "\\u", "404_", "(_", "Message_", ",_", "pk_", "=_", "message", "\\u", "id_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "user_", "=_", "request_", "._", "user_", "._", "profile_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "not_", "user_", "._", "has", "\\u", "permission_", "(_", "message_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "user", "\\u", "deni", "ed_", "(_", "request_", ",_", "message_", "=_", "\"", "You", " ", "don", "'", "t", " ", "have", " ", "access", " ", "to", " ", "this", " ", "Messag", "e", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "response", "\\u", "format_", "=_", "response", "\\u", "format_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "message_", "._", "read", "\\u", "by_", "._", "add_", "(_", "user_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "request_", "._", "POST_", "and_", "request_", "._", "POST_", "._", "get_", "(_", "'", "body", "'_", ",_", "False_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"", "Unrea", "d", " ", "message", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "reply_", "=_", "Message_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "reply_", "._", "author_", "=_", "user_", "._", "get", "\\u", "contact_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "not_", "reply_", "._", "author_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "user", "\\u", "deni", "ed_", "(_", "request_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "message_", "=_", "\"", "You", " ", "can", "'", "t", " ", "send", " ", "message", " ", "with", "out", " ", "a", " ", "Conta", "ct", " ", "Card", " ", "assign", "ed", " ", "to", " ", "you", ".\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "response", "\\u", "format_", "=_", "response", "\\u", "format_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "reply_", "._", "repl", "y", "\\u", "to_", "=_", "message_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "form_", "=_", "Messag", "e", "Repl", "y", "Form_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "user_", ",_", "message_", "._", "stream", "\\u", "id_", ",_", "message_", ",_", "request_", "._", "POST_", ",_", "instance_", "=_", "reply_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "form_", "._", "is", "\\u", "valid_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "reply_", "=_", "form_", "._", "save_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "reply_", "._", "set\\u", "user", "\\u", "from", "\\u", "request_", "(_", "request_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Add", " ", "author", " ", "to", " ", "recipients_", "\\u\\u\\uNL\\u\\u\\u_", "reply_", "._", "recipients_", "._", "add_", "(_", "reply_", "._", "author_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "message_", "._", "read", "\\u", "by_", "._", "clear_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "if", " ", "email", " ", "enter", "ed", " ", "create", " ", "contact", " ", "and", " ", "add", " ", "to", " ", "recipients_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "'", "multico", "mplet", "e\\u", "recip", "ients", "'_", "in_", "request_", "._", "POST_", "and_", "request_", "._", "POST_", "[_", "'", "multico", "mplet", "e\\u", "recip", "ients", "'_", "]_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "conf_", "=_", "Modul", "e", "Setting_", "._", "get", "\\u", "for", "\\u", "module_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "'", "treei", "o", ".", "mess", "agin", "g", "'_", ",_", "'", "default", "\\u", "contact", "\\u", "type", "'_", ")_", "[_", "0_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "default", "\\u", "contact", "\\u", "type_", "=_", "Conta", "ct", "Type_", "._", "objects_", "._", "get_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "pk_", "=_", "long_", "(_", "conf_", "._", "value_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "Exception_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "default", "\\u", "contact", "\\u", "type_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "emails_", "=_", "request_", "._", "POST_", "[_", "\\u\\u\\uNL\\u\\u\\u_", "'", "multico", "mplet", "e\\u", "recip", "ients", "'_", "]_", "._", "split_", "(_", "','_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "email_", "in_", "emails_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "email", "str_", "=_", "unicode_", "(_", "email_", ")_", "._", "strip_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "re_", "._", "match_", "(_", "'[", "a", "-", "z", "A", "-", "Z", "0", "-", "9", "+\\u", "\\\\-\\", "\\", ".]+", "@[", "0", "-", "9", "a", "-", "z", "A", "-", "Z", "][", ".-", "0", "-", "9", "a", "-", "z", "A", "-", "Z", "]*", ".", "[", "a", "-", "z", "A", "-", "Z", "]+'_", ",_", "email", "str_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "contact_", ",_", "created_", "=_", "Contact_", "._", "get", "\\u", "or", "\\u", "create", "\\u", "by", "\\u", "email_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "email", "str_", ",_", "contact", "\\u", "type_", "=_", "default", "\\u", "contact", "\\u", "type_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "reply_", "._", "recipients_", "._", "add_", "(_", "contact_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "created_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "contact_", "._", "set\\u", "user", "\\u", "from", "\\u", "request_", "(_", "request_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "pass_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Add", " ", "each", " ", "recip", "ient", " ", "of", " ", "the", " ", "repl", "y", " ", "to", " ", "the", " ", "original", " ", "message_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "for_", "recipient_", "in_", "reply_", "._", "recipients_", "._", "all_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "message_", "._", "recipients_", "._", "add_", "(_", "recipient_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "send", " ", "email", " ", "to", " ", "all", " ", "recipients_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "reply_", "._", "send", "\\u", "email_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "return_", "Http", "Respons", "e", "Redirect_", "(_", "reverse_", "(_", "'", "mess", "agin", "g", "\\u", "message", "\\u", "view", "'_", ",_", "args_", "=_", "[_", "message_", "._", "id_", "]_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "form_", "=_", "Messag", "e", "Repl", "y", "Form_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "request_", "._", "user_", "._", "profile_", ",_", "message_", "._", "stream", "\\u", "id_", ",_", "message_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "replies_", "=_", "Object_", "._", "filter", "\\u", "by", "\\u", "request_", "(_", "request_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "Message_", "._", "objects_", "._", "filter_", "(_", "repl", "y", "\\u", "to_", "=_", "message_", ")_", "._", "order", "\\u", "by_", "(_", "'", "date", "\\u", "created", "'_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "context_", "=_", "\\u", "get", "\\u", "default", "\\u", "context_", "(_", "request_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "context_", "._", "update_", "(_", "{_", "'", "message", "'_", ":_", "message_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "message", "s", "'_", ":_", "replies_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "form", "'_", ":_", "form_", "}_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "return_", "render", "\\u", "to", "\\u", "response_", "(_", "'", "mess", "agin", "g", "/", "message", "\\u", "view", "'_", ",_", "context_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "context", "\\u", "instance_", "=_", "Request", "Context_", "(_", "request_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "response", "\\u", "format_", "=_", "response", "\\u", "format_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "@_", "handle", "\\u", "response", "\\u", "format_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "@_", "treei", "o", "\\u", "login", "\\u", "required_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "settings", "\\u", "view_", "(_", "request_", ",_", "response", "\\u", "format_", "=_", "'", "html", "'_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"", "Sett", "ings", " ", "admin", " ", "view", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "default", " ", "content", " ", "type_", "\\u\\u\\uNL\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "conf_", "=_", "Modul", "e", "Setting_", "._", "get", "\\u", "for", "\\u", "module_", "(_", "'", "treei", "o", ".", "mess", "agin", "g", "'_", ",_", "'", "default", "\\u", "contact", "\\u", "type", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "user_", "=_", "request_", "._", "user_", "._", "profile_", ")_", "[_", "0_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "default", "\\u", "contact", "\\u", "type_", "=_", "Conta", "ct", "Type_", "._", "objects_", "._", "get_", "(_", "pk_", "=_", "long_", "(_", "conf_", "._", "value_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "default", "\\u", "contact", "\\u", "type_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "default", " ", "imap", " ", "folder_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "conf_", "=_", "Modul", "e", "Setting_", "._", "get", "\\u", "for", "\\u", "module_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "'", "treei", "o", ".", "mess", "agin", "g", "'_", ",_", "'", "default", "\\u", "imap", "\\u", "folder", "'_", ")_", "[_", "0_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "default", "\\u", "imap", "\\u", "folder_", "=_", "conf_", "._", "value_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "default", "\\u", "imap", "\\u", "folder_", "=_", "getattr_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "settings_", ",_", "'", "HARD", "TREE", "\\u", "MES", "SA", "GING", "\\u", "IMAP", "\\u", "DEF", "AUL", "T", "\\u", "FOLDER", "\\u", "NAME", "'_", ",_", "'", "UNS", "EE", "N", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "signature_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "conf_", "=_", "Modul", "e", "Setting_", "._", "get", "\\u", "for", "\\u", "module_", "(_", "'", "treei", "o", ".", "mess", "agin", "g", "'_", ",_", "'", "signa", "ture", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "user_", "=_", "request_", "._", "user_", "._", "profile_", ",_", "strict_", "=_", "True_", ")_", "[_", "0_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "signature_", "=_", "conf_", "._", "value_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "signature_", "=_", "''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "types_", "=_", "Object_", "._", "filter", "\\u", "by", "\\u", "request_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "request_", ",_", "Conta", "ct", "Type_", "._", "objects_", "._", "order", "\\u", "by_", "(_", "'", "name", "'_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "context_", "=_", "\\u", "get", "\\u", "default", "\\u", "context_", "(_", "request_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "context_", "._", "update_", "(_", "{_", "'", "types", "'_", ":_", "types_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "signa", "ture", "'_", ":_", "signature_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "default", "\\u", "contact", "\\u", "type", "'_", ":_", "default", "\\u", "contact", "\\u", "type_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "default", "\\u", "imap", "\\u", "folder", "'_", ":_", "default", "\\u", "imap", "\\u", "folder_", "}_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "return_", "render", "\\u", "to", "\\u", "response_", "(_", "'", "mess", "agin", "g", "/", "settings", "\\u", "view", "'_", ",_", "context_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "context", "\\u", "instance_", "=_", "Request", "Context_", "(_", "request_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "response", "\\u", "format_", "=_", "response", "\\u", "format_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_" ]
[ 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,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fd/lfd/rapprentice/compute_decomps.py
[ { "content": "import h5py\nimport numpy as np\nimport scipy.linalg\nimport argparse\n\nfrom lfd.rapprentice.tps import tps_kernel_matrix \n\n\n\n\n\nif __name__=='__main__':\n main()\n \n", "metadata": "root", "header": "['module', '___EOS___']", "index": 0 }, { "content": "def parse_arguments():\n parser = argparse.ArgumentParser()\n parser.add_argument('datafile', type=str)\n parser.add_argument('--bend_coeff_init', type=float, default=10)\n parser.add_argument('--bend_coeff_final', type=float, default=.1)\n parser.add_argument('--n_iter', type=int, default=20)\n parser.add_argument('--verbose', action='store_true')\n return parser.parse_args()", "metadata": "root.parse_arguments", "header": "['module', '___EOS___']", "index": 7 }, { "content": "def get_lu_decomp(x_na, bend_coef, rot_coef):\n \"\"\"\n precomputes the LU decomposition and other intermediate results needed\n to fit a TPS to x_na with bend_coeff\n\n all thats needed is to compute the righthand side and do a forward solve\n \"\"\"\n \n n,d = x_na.shape\n Q = np.c_[np.ones((n,1)), x_na, K_nn]\n QWQ = Q.T.dot(WQ)\n H = Q.T.dot(Q)\n H[d+1:,d+1:] += bend_coef * K_nn\n rot_coefs = np.ones(d) * rot_coef if np.isscalar(rot_coef) else rot_coef\n H[1:d+1, 1:d+1] += np.diag(rot_coefs)\n\n A = np.r_[np.zeros((d+1,d+1)), np.c_[np.ones((n,1)), x_na]].T\n\n # f = -WQ.T.dot(y_ng)\n # f[1:d+1,0:d] -= np.diag(rot_coefs)\n\n _u,_s,_vh = np.linalg.svd(A.T)\n N = _u[:,n_cnts:]\n\n p, l, u, = scipy.linalg.lu(N.T.dot(H.dot(N)))\n\n # z = np.linalg.solve(N.T.dot(H.dot(N)), -N.T.dot(f))\n # x = N.dot(z)\n\n res_dict = {'p' : p, 'l' : l, 'u' : u, 'N' : N, 'rot_coeffs' : rot_coeffs}\n\n return bend_coeff, res_dict", "metadata": "root.get_lu_decomp", "header": "['module', '___EOS___']", "index": 16 }, { "content": "def main():\n args = parse_arguments()\n\n f = h5py.File(args.datafile, 'r')\n \n bend_coefs = np.loglinspace(args.bend_coef_init, args.bend_coeff_final, args.n_iter)\n\n for seg_name, seg_info in f.iteritems():\n if 'LU' not in seg_info:\n lu_group = seg_info.create_group('LU')\n else:\n lu_group = seg_info['LU']\n x_na = seg_info['cloud_xyz'][:]\n for bend_coeff in bend_coeffs:\n if str(bend_coeff) in lu_group:\n continue\n \n bend_coeff_g = lu_group.create_group(str(bend_coeff))\n _, res = get_lu_decomp(x_na, bend_coeff)\n for k, v in res.iteritems():\n bend_coeff_g[k] = v\n\n if args.verbose:\n print 'segment {} bend_coeff {}'.format(seg_name, bend_coeff)\n\n f.close()", "metadata": "root.main", "header": "['module', '___EOS___']", "index": 50 } ]
[ { "span": "from lfd.rapprentice.tps import tps_kernel_matrix ", "start_line": 5, "start_column": 0, "end_line": 5, "end_column": 49 } ]
[]
1
false
[ "[CLS]_", "Un", "used_", "import_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "import_", "h5py_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "numpy_", "as_", "np_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "scipy_", "._", "linalg_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "argparse_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "from_", "lf", "d_", "._", "rapp", "rent", "ice_", "._", "tps", "_", "import_", "tps", "\\u", "kernel", "\\u", "matrix_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "\\u\\u", "name\\u\\u_", "==_", "'\\u", "\\u", "main", "\\u\\u'_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "main_", "(_", ")_", "\\u\\u\\uDEDENT\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "parse", "\\u", "arguments_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "parser_", "=_", "argparse_", "._", "Arg", "ument", "Parser_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "parser_", "._", "add", "\\u", "argument_", "(_", "'", "datafile", "'_", ",_", "type_", "=_", "str_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "parser_", "._", "add", "\\u", "argument_", "(_", "'--", "bend", "\\u", "coef", "f", "\\u", "init", "'_", ",_", "type_", "=_", "float_", ",_", "default_", "=_", "10_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "parser_", "._", "add", "\\u", "argument_", "(_", "'--", "bend", "\\u", "coef", "f", "\\u", "final", "'_", ",_", "type_", "=_", "float_", ",_", "default_", "=_", ".1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "parser_", "._", "add", "\\u", "argument_", "(_", "'--", "n", "\\u", "iter", "'_", ",_", "type_", "=_", "int_", ",_", "default_", "=_", "20_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "parser_", "._", "add", "\\u", "argument_", "(_", "'--", "verbo", "se", "'_", ",_", "action_", "=_", "'", "store", "\\u", "true", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "parser_", "._", "parse", "\\u", "args_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "get", "\\u", "lu", "\\u", "decomp", "_", "(_", "x", "\\u", "na_", ",_", "bend", "\\u", "coef_", ",_", "rot", "\\u", "coef_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "precompute", "s", " ", "the", " ", "LU", " ", "decomposition", " ", "and", " ", "other", " ", "intermediate", " ", "results", " ", "need", "ed", "\\", "10", ";", " ", " ", " ", " ", "to", " ", "fit", " ", "a", " ", "TP", "S", " ", "to", " ", "x", "\\u", "na", " ", "with", " ", "bend", "\\u", "coef", "f", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "all", " ", "tha", "ts", " ", "need", "ed", " ", "is", " ", "to", " ", "compute", " ", "the", " ", "right", "hand", " ", "side", " ", "and", " ", "do", " ", "a", " ", "forward", " ", "solve", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "n_", ",_", "d_", "=_", "x", "\\u", "na_", "._", "shape_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "Q_", "=_", "np_", "._", "c\\u", "_", "[_", "np_", "._", "ones_", "(_", "(_", "n_", ",_", "1_", ")_", ")_", ",_", "x", "\\u", "na_", ",_", "K", "\\u", "nn_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "QW", "Q_", "=_", "Q_", "._", "T_", "._", "dot_", "(_", "WQ", "_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "H_", "=_", "Q_", "._", "T_", "._", "dot_", "(_", "Q_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "H_", "[_", "d_", "+_", "1_", ":_", ",_", "d_", "+_", "1_", ":_", "]_", "+=_", "bend", "\\u", "coef_", "*_", "K", "\\u", "nn_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "rot", "\\u", "coefs_", "=_", "np_", "._", "ones_", "(_", "d_", ")_", "*_", "rot", "\\u", "coef_", "if_", "np_", "._", "iss", "cala", "r_", "(_", "rot", "\\u", "coef_", ")_", "else_", "rot", "\\u", "coef_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "H_", "[_", "1_", ":_", "d_", "+_", "1_", ",_", "1_", ":_", "d_", "+_", "1_", "]_", "+=_", "np_", "._", "diag_", "(_", "rot", "\\u", "coefs_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "A_", "=_", "np_", "._", "r\\u_", "[_", "np_", "._", "zeros_", "(_", "(_", "d_", "+_", "1_", ",_", "d_", "+_", "1_", ")_", ")_", ",_", "np_", "._", "c\\u", "_", "[_", "np_", "._", "ones_", "(_", "(_", "n_", ",_", "1_", ")_", ")_", ",_", "x", "\\u", "na_", "]_", "]_", "._", "T_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "f", " ", "=", " ", "-", "WQ", ".", "T", ".", "dot", "(", "y", "\\u", "ng", ")_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "f", "[", "1", ":", "d", "+", "1", ",", "0", ":", "d", "]", " ", "-=", " ", "np", ".", "diag", "(", "rot", "\\u", "coef", "s", ")_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u", "u_", ",_", "\\u", "s_", ",_", "\\u", "vh", "_", "=_", "np_", "._", "linalg_", "._", "svd_", "(_", "A_", "._", "T_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "N_", "=_", "\\u", "u_", "[_", ":_", ",_", "n", "\\u", "cnt", "s_", ":_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "p_", ",_", "l_", ",_", "u_", ",_", "=_", "scipy_", "._", "linalg_", "._", "lu_", "(_", "N_", "._", "T_", "._", "dot_", "(_", "H_", "._", "dot_", "(_", "N_", ")_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "z", " ", "=", " ", "np", ".", "linalg", ".", "solve", "(", "N", ".", "T", ".", "dot", "(", "H", ".", "dot", "(", "N", "))", ",", " ", "-", "N", ".", "T", ".", "dot", "(", "f", "))", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "x", " ", "=", " ", "N", ".", "dot", "(", "z", ")_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "res", "\\u", "dict_", "=_", "{_", "'", "p", "'_", ":_", "p_", ",_", "'", "l", "'_", ":_", "l_", ",_", "'", "u", "'_", ":_", "u_", ",_", "'", "N", "'_", ":_", "N_", ",_", "'", "rot", "\\u", "coeffs", "'_", ":_", "rot", "\\u", "coeffs_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "return_", "bend", "\\u", "coeff_", ",_", "res", "\\u", "dict_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "main_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "args_", "=_", "parse", "\\u", "arguments_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "f_", "=_", "h5py_", "._", "File_", "(_", "args_", "._", "datafile_", ",_", "'", "r", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "bend", "\\u", "coefs_", "=_", "np_", "._", "logl", "insp", "ace_", "(_", "args_", "._", "bend", "\\u", "coef\\u", "init_", ",_", "args_", "._", "bend", "\\u", "coef", "f", "\\u", "final_", ",_", "args_", "._", "n", "\\u", "iter_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "for_", "seg", "\\u", "name_", ",_", "seg", "\\u", "info_", "in_", "f_", "._", "iteritems_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "'", "LU", "'_", "not_", "in_", "seg", "\\u", "info_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "lu", "\\u", "group_", "=_", "seg", "\\u", "info_", "._", "create", "\\u", "group_", "(_", "'", "LU", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "lu", "\\u", "group_", "=_", "seg", "\\u", "info_", "[_", "'", "LU", "'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "x", "\\u", "na_", "=_", "seg", "\\u", "info_", "[_", "'", "cloud", "\\u", "xyz", "'_", "]_", "[_", ":_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "bend", "\\u", "coeff_", "in_", "bend", "\\u", "coeffs_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "str_", "(_", "bend", "\\u", "coeff_", ")_", "in_", "lu", "\\u", "group_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "continue_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "bend", "\\u", "coef", "f", "\\u", "g_", "=_", "lu", "\\u", "group_", "._", "create", "\\u", "group_", "(_", "str_", "(_", "bend", "\\u", "coeff_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u_", ",_", "res_", "=_", "get", "\\u", "lu", "\\u", "decomp", "_", "(_", "x", "\\u", "na_", ",_", "bend", "\\u", "coeff_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "k_", ",_", "v_", "in_", "res_", "._", "iteritems_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "bend", "\\u", "coef", "f", "\\u", "g_", "[_", "k_", "]_", "=_", "v_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "args_", "._", "verbose_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "print_", "'", "segment", " ", "{}", " ", " ", "bend", "\\u", "coef", "f", " ", "{}'_", "._", "format_", "(_", "seg", "\\u", "name_", ",_", "bend", "\\u", "coeff_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "f_", "._", "close_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_" ]
[ 4, 4, 4, 4, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,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, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 ]
Except block handles 'BaseException'
aerospike/aerospike-client-python/test/old_tests/test_admin_revoke_roles.py
[ { "content": "# -*- coding: utf-8 -*-\n\nimport pytest\nimport sys\nimport time\nfrom .test_base_class import TestBaseClass\nfrom aerospike import exception as e\n\naerospike = pytest.importorskip(\"aerospike\")\ntry:\n import aerospike\nexcept:\n print(\"Please install aerospike python client.\")\n sys.exit(1)\n\n\n", "metadata": "root", "header": "['module', '___EOS___']", "index": 0 }, { "content": " def setup_method(self, method):\n \"\"\"\n Setup method\n \"\"\"\n hostlist, user, password = TestBaseClass().get_hosts()\n config = {\"hosts\": hostlist}\n TestRevokeRoles.Me = self\n self.client = aerospike.client(config).connect(user, password)\n try:\n self.client.admin_drop_user(\"example-test\")\n except:\n pass\n policy = {}\n user = \"example-test\"\n password = \"foo2\"\n roles = [\"read-write\", \"sys-admin\", \"read\"]\n\n self.client.admin_create_user(user, password, roles, policy)\n\n self.delete_users = []", "metadata": "root.TestRevokeRoles.setup_method", "header": "['class', 'TestRevokeRoles', '(', 'TestBaseClass', ')', ':', '___EOS___']", "index": 22 } ]
[ { "span": "except:", "start_line": 11, "start_column": 0, "end_line": 11, "end_column": 7 }, { "span": "except:", "start_line": 32, "start_column": 8, "end_line": 32, "end_column": 15 } ]
[]
1
true
[ "[CLS]_", "Except", "_", "block_", "handles_", "'", "Base", "Except", "ion", "'_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "#", " ", "-*-", " ", "codi", "ng", ":", " ", "utf", "-", "8", " ", "-*-", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "import_", "pytest_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "sys_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "time_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "._", "test\\u", "base", "\\u", "class_", "import_", "Test", "Base", "Class_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "aeros", "pike", "_", "import_", "exception_", "as_", "e_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "aeros", "pike", "_", "=_", "pytest_", "._", "import", "ors", "kip", "_", "(_", "\"", "aeros", "pike", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "import_", "aeros", "pike", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "print_", "(_", "\"", "Ple", "ase", " ", "install", " ", "aeros", "pike", " ", "python", " ", "client", ".\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "sys_", "._", "exit_", "(_", "1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "[SEP]_", "class_", "Test", "Revo", "ke", "Roles_", "(_", "Test", "Base", "Class_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "setup", "\\u", "method_", "(_", "self_", ",_", "method_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Set", "up", " ", "method", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "host", "list_", ",_", "user_", ",_", "password_", "=_", "Test", "Base", "Class_", "(_", ")_", "._", "get", "\\u", "hosts_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "config_", "=_", "{_", "\"", "host", "s", "\"_", ":_", "host", "list_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "Test", "Revo", "ke", "Roles_", "._", "Me_", "=_", "self_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "client_", "=_", "aeros", "pike", "_", "._", "client_", "(_", "config_", ")_", "._", "connect_", "(_", "user_", ",_", "password_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "client_", "._", "admin", "\\u", "drop", "\\u", "user_", "(_", "\"", "example", "-", "test", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "pass_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "policy_", "=_", "{_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "user_", "=_", "\"", "example", "-", "test", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "password_", "=_", "\"", "foo", "2", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "roles_", "=_", "[_", "\"", "read", "-", "write", "\"_", ",_", "\"", "sys", "-", "admin", "\"_", ",_", "\"", "read", "\"_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "client_", "._", "admin", "\\u", "create", "\\u", "user_", "(_", "user_", ",_", "password_", ",_", "roles_", ",_", "policy_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "delete", "\\u", "users_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_" ]
[ 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 ]
Unused import
gferreira/hTools2/Lib/hTools2/dialogs/font/vmetrics_adjust2.py
[ { "content": "# [h] adjust vertical metrics\n\n# import\n\ntry:\n from mojo.roboFont import CurrentFont, CurrentGlyph\n\nexcept ImportError:\n from robofab.world import CurrentFont, CurrentGlyph\n\nfrom vanilla import *\n\nfrom hTools2 import hDialog\nfrom hTools2.dialogs.misc import Spinner\nfrom hTools2.modules.fontutils import get_full_name\nfrom hTools2.modules.messages import no_font_open\n\n# object\n\n", "metadata": "root", "header": "['module', '___EOS___']", "index": 0 }, { "content": "class adjustVerticalMetrics(hDialog):\n\n \"\"\"A dialog to adjust the vertical metrics of the font.\n\n .. image:: imgs/font/adjust-vmetrics.png\n\n \"\"\"\n\n ascender_min = 1\n capheight_min = 1\n xheight_min = 1\n descender_min = 1\n\n column_1 = 80\n column_2 = 200\n column_3 = 45\n\n moveX = 0\n moveY = 0\n", "metadata": "root.adjustVerticalMetrics", "header": "['module', '___EOS___']", "index": 19 }, { "content": " def __init__(self):\n self.title = \"vmetrics\"\n self.height = (self.spinner_height*5) + (self.padding_y*6) + 1\n self.w = FloatingWindow((self.width, self.height), self.title)\n x = 0\n y = self.padding_y\n self.w.emsquare = Spinner(\n (x, y),\n default='1000',\n scale=1,\n integer=True,\n label='ems')\n y += self.spinner_height + self.padding_y\n self.w.xheight = Spinner(\n (x, y),\n default='500',\n scale=1,\n integer=True,\n label='xht')\n y += self.spinner_height + self.padding_y\n self.w.capheight = Spinner(\n (x, y),\n default='700',\n scale=1,\n integer=True,\n label='cap')\n y += self.spinner_height + self.padding_y\n self.w.ascender = Spinner(\n (x, y),\n default='800',\n scale=1,\n integer=True,\n label='asc')\n y += self.spinner_height + self.padding_y\n self.w.descender = Spinner(\n (x, y),\n default='200',\n scale=1,\n integer=True,\n label='dsc')\n y += self.spinner_height + self.padding_y\n self.w.open()", "metadata": "root.adjustVerticalMetrics.__init__", "header": "['class', 'adjustVerticalMetrics', '(', 'hDialog', ')', ':', '___EOS___']", "index": 39 } ]
[ { "span": "from mojo.roboFont import CurrentFont, CurrentGlyph", "start_line": 5, "start_column": 4, "end_line": 5, "end_column": 55 }, { "span": "from robofab.world import CurrentFont, CurrentGlyph", "start_line": 8, "start_column": 4, "end_line": 8, "end_column": 55 }, { "span": "from hTools2.modules.fontutils import get_full_name", "start_line": 14, "start_column": 0, "end_line": 14, "end_column": 51 }, { "span": "from hTools2.modules.messages import no_font_open", "start_line": 15, "start_column": 0, "end_line": 15, "end_column": 49 } ]
[]
1
false
[ "[CLS]_", "Un", "used_", "import_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "#", " ", "[", "h", "]", " ", "adjust", " ", "vertical", " ", "metrics_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "import_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "from_", "mo", "jo", "_", "._", "robo", "Font_", "import_", "Curr", "ent", "Font_", ",_", "Curr", "ent", "Glyph_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "Import", "Error_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "from_", "robo", "fab", "_", "._", "world_", "import_", "Curr", "ent", "Font_", ",_", "Curr", "ent", "Glyph_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "from_", "vanilla", "_", "import_", "*_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "from_", "h", "Tool", "s2_", "import_", "h", "Dialog_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "h", "Tool", "s2_", "._", "dialogs_", "._", "misc_", "import_", "Spin", "ner_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "h", "Tool", "s2_", "._", "modules_", "._", "font", "utils_", "import_", "get", "\\u", "full", "\\u", "name_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "h", "Tool", "s2_", "._", "modules_", "._", "messages_", "import_", "no", "\\u", "font", "\\u", "open_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "object_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "class_", "adjust", "Vertica", "l", "Metrics_", "(_", "h", "Dialog_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "A", " ", "dialog", " ", "to", " ", "adjust", " ", "the", " ", "vertical", " ", "metric", "s", " ", "of", " ", "the", " ", "font", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "..", " ", "image", "::", " ", "imgs", "/", "font", "/", "adjust", "-", "vme", "tric", "s", ".", "png", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "ascen", "der", "\\u", "min_", "=_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "cap", "height", "\\u", "min_", "=_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "xh", "eight", "\\u", "min_", "=_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "descend", "er", "\\u", "min_", "=_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "column", "\\u", "1_", "=_", "80_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "column", "\\u", "2_", "=_", "200_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "column", "\\u", "3_", "=_", "45_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "move", "X_", "=_", "0_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "move", "Y_", "=_", "0_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "[SEP]_", "class_", "adjust", "Vertica", "l", "Metrics_", "(_", "h", "Dialog_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "\\u\\u", "init\\u\\u_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "title_", "=_", "\"", "vme", "tric", "s", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "height_", "=_", "(_", "self_", "._", "spinn", "er", "\\u", "height_", "*_", "5_", ")_", "+_", "(_", "self_", "._", "padd", "ing", "\\u", "y_", "*_", "6_", ")_", "+_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "w_", "=_", "Float", "ing", "Window_", "(_", "(_", "self_", "._", "width_", ",_", "self_", "._", "height_", ")_", ",_", "self_", "._", "title_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "x_", "=_", "0_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "y_", "=_", "self_", "._", "padd", "ing", "\\u", "y_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "w_", "._", "ems", "quare", "_", "=_", "Spin", "ner_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "x_", ",_", "y_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "default_", "=_", "'", "1000", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "scale_", "=_", "1_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "integer_", "=_", "True_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "label_", "=_", "'", "ems", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "y_", "+=_", "self_", "._", "spinn", "er", "\\u", "height_", "+_", "self_", "._", "padd", "ing", "\\u", "y_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "w_", "._", "xh", "eight_", "=_", "Spin", "ner_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "x_", ",_", "y_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "default_", "=_", "'", "500", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "scale_", "=_", "1_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "integer_", "=_", "True_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "label_", "=_", "'", "xh", "t", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "y_", "+=_", "self_", "._", "spinn", "er", "\\u", "height_", "+_", "self_", "._", "padd", "ing", "\\u", "y_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "w_", "._", "cap", "height_", "=_", "Spin", "ner_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "x_", ",_", "y_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "default_", "=_", "'", "700", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "scale_", "=_", "1_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "integer_", "=_", "True_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "label_", "=_", "'", "cap", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "y_", "+=_", "self_", "._", "spinn", "er", "\\u", "height_", "+_", "self_", "._", "padd", "ing", "\\u", "y_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "w_", "._", "ascen", "der_", "=_", "Spin", "ner_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "x_", ",_", "y_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "default_", "=_", "'", "800", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "scale_", "=_", "1_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "integer_", "=_", "True_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "label_", "=_", "'", "asc", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "y_", "+=_", "self_", "._", "spinn", "er", "\\u", "height_", "+_", "self_", "._", "padd", "ing", "\\u", "y_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "w_", "._", "descend", "er_", "=_", "Spin", "ner_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "x_", ",_", "y_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "default_", "=_", "'", "200", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "scale_", "=_", "1_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "integer_", "=_", "True_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "label_", "=_", "'", "dsc", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "y_", "+=_", "self_", "._", "spinn", "er", "\\u", "height_", "+_", "self_", "._", "padd", "ing", "\\u", "y_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "w_", "._", "open_", "(_", ")_" ]
[ 4, 4, 4, 4, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,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2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 ]
Unused local variable
taoliu/taolib/Scripts/wig_correlation.py
[ { "content": "def main():\n usage = \"usage: %prog <-r rfile> [options] <wiggle files> ...\"\n description = \"Draw correlation plot for many wiggle files. Based on qc_chIP_whole.py\"\n \n optparser = OptionParser(version=\"%prog 0.1\",description=description,usage=usage,add_help_option=False)\n optparser.add_option(\"-h\",\"--help\",action=\"help\",help=\"Show this help message and exit.\")\n optparser.add_option(\"-d\",\"--db\",type=\"str\",dest=\"dbname\",help=\"UCSC db name for the assembly. Default: ce4\",default=\"ce4\")\n optparser.add_option(\"-r\",\"--rfile\",dest=\"rfile\",\n help=\"R output file. If not set, do not save R file.\")\n optparser.add_option(\"-s\",\"--step\",dest=\"step\",type=\"int\",\n help=\"sampling step in kbps. default: 100, minimal: 1\",default=100)\n optparser.add_option(\"-z\",\"--imgsize\",dest=\"imgsize\",type=\"int\",\n help=\"image size in inches, note the PNG dpi is 72. default: 10, minimal: 10\",default=10) \n optparser.add_option(\"-f\",\"--format\",dest=\"imgformat\",type=\"string\",\n help=\"image format. PDF or PNG\",default='PDF')\n optparser.add_option(\"-m\",\"--method\",dest=\"method\",type=\"string\",default=\"median\",\n help=\"method to process the paired two sets of data in the sampling step. Choices are 'median', 'mean', and 'sample' (just take one point out of a data set). Default: median\")\n optparser.add_option(\"-l\",\"--wig-label\",dest=\"wiglabel\",type=\"string\",action=\"append\",\n help=\"the wiggle file labels in the figure. No space is allowed. This option should be used same times as wiggle files, and please input them in the same order as -w option. default: will use the wiggle file filename as labels.\")\n optparser.add_option(\"--min-score\",dest=\"minscore\",type=\"float\",default=-10000,\n help=\"minimum score included in calculation. Points w/ score lower than this will be discarded.\")\n optparser.add_option(\"--max-score\",dest=\"maxscore\",type=\"float\",default=10000,\n help=\"maximum score included in calculation. Points w/ score larger than this will be discarded.\")\n optparser.add_option(\"-H\",\"--heatmap\",dest=\"heatmap\",action=\"store_true\",default=False,\n help=\"If True, a heatmap image will be generated instead of paired scatterplot image.\")\n \n (options,wigfiles) = optparser.parse_args()\n\n imgfmt = options.imgformat.upper()\n if imgfmt != 'PDF' and imgfmt != 'PNG':\n print \"unrecognized format: %s\" % imgfmt\n sys.exit(1)\n\n method = options.method.lower()\n if method == 'median':\n medfunc = median\n elif method == 'mean':\n medfunc = mean\n elif method == 'sample':\n medfunc = lambda u: u[-1]\n else:\n print \"unrecognized method: %s\" % (method)\n sys.exit(1)\n\n wigfilenum = len(wigfiles)\n\n # must provide >=2 wiggle files\n if wigfilenum < 2 or not options.rfile:\n optparser.print_help()\n sys.exit(1)\n\n # wig labels\n if options.wiglabel and len(options.wiglabel) == wigfilenum:\n wiglabel = options.wiglabel\n else: # or use the filename\n wiglabel = map(lambda x:os.path.basename(x),wigfiles)\n \n\n if options.step < 1:\n error(\"Step can not be lower than 1!\")\n sys.exit(1)\n if options.imgsize < 10:\n error(\"Image size can not be lower than 10!\")\n sys.exit(1)\n\n # check the files\n for f in wigfiles:\n if not os.path.isfile(f):\n error(\"%s is not valid!\" % f)\n sys.exit(1)\n \n wigfhds = map(open,wigfiles) # file handlers for wiggle files\n\n info(\"number of wiggle files: %d\" % wigfilenum)\n # get chromosome length info from UCSC\n info(\"connect to UCSC to get chromosome length information\")\n try:\n chrom_len = get_chrom_length(options.dbname)\n except:\n error(\"Error!\")\n sys.exit(1)\n\n # get the common chromosome list:\n chromsdict = {}\n for wigfhd in wigfhds:\n tmpset = set([])\n for l in wigfhd:\n if l.find(\"chrom=\") != -1:\n c = re.search(\"chrom=(\\w+)\",l).group(1)\n tmpset.add(c)\n for c in tmpset:\n chromsdict[c] = chromsdict.setdefault(c,0)+1\n chroms = []\n for c in chromsdict.keys():\n if chromsdict[c]==wigfilenum:\n chroms.append(c)\n\n info(\"common chromosomes are %s...\" % \",\".join(chroms))\n\n if options.rfile:\n rfhd = open(options.rfile,\"w\")\n rfhd.write('''\nrequire(\"RColorBrewer\") ## from CRAN\n''')\n\n # for each wig file, sample...\n for i in range(len(wigfhds)):\n wigfhd = wigfhds[i]\n wigfhd.seek(0) # reset\n info(\"read wiggle track from wiggle file #%d\" % (i+1))\n wig = WiggleIO.WiggleIO(wigfhd).build_binKeeper(chromLenDict=chrom_len,bin=options.step)\n p = [] # size of p is number of cages in binkeeper\n ap = p.append\n for chrom in chroms:\n step_region = []\n step_region_a = step_region.append\n try:\n end_of_chrom = chrom_len[chrom]\n except:\n warn(\"chromosome %s can not be found in UCSC... skip...\" % chrom)\n continue\n bkeeper = wig[chrom] # binkeeper object\n for (parray,varray) in bkeeper.cage: # for each cage in binkeeper, there are [position array] and [value array].\n if varray:\n ap(medfunc(varray))\n else:\n ap(None)\n info(\"write values to r file\")\n rfhd.write(\"p%d <- c(\" % i )\n if p[0]:\n rfhd.write(\"%f\" % p[0])\n else:\n rfhd.write(\"NA\")\n for v in p[1:]:\n if v:\n rfhd.write(\",%f\" % v)\n else:\n rfhd.write(\",NA\")\n rfhd.write(\")\\n\")\n \n rfhd.write(\"c <- cbind(p0\")\n for i in range(wigfilenum-1):\n rfhd.write(\",p%d\" % (i+1))\n rfhd.write(\")\\n\")\n \n rfhd.write(\"c <- c[ c[,1]<=%f & c[,1]>=%f \" % (options.maxscore,options.minscore))\n for i in range(wigfilenum-1):\n rfhd.write(\"& c[,%d]<=%f & c[,%d]>=%f \" % (i+2,options.maxscore,i+2,options.minscore))\n rfhd.write(\",]\\n\")\n if imgfmt == 'PDF':\n rfhd.write(\"pdf(\\\"%s.pdf\\\",width=%d,height=%d)\\n\" % (options.rfile,options.imgsize,options.imgsize))\n elif imgfmt == 'PNG':\n rfhd.write(\"png(\\\"%s.png\\\",units=\\\"in\\\",res=150,width=%d,height=%d)\\n\" % (options.rfile,options.imgsize,options.imgsize))\n\n if options.heatmap: # heatmap\n rfhd.write('library(gplots)\\n')\n rfhd.write('''\nm <- cor(c, method=\"pearson\", use=\"pairwise.complete.obs\")\n''')\n labels = \",\".join(map(lambda x:\"\\\"\"+x+\"\\\"\",wiglabel))\n rfhd.write(\"rownames(m) <- c(%s)\\n\" % labels)\n rfhd.write(\"colnames(m) <- c(%s)\\n\" % labels) \n rfhd.write('# draw the heatmap using gplots heatmap.2\\n') \n# rfhd.write('bitmap(\"%s.bmp\",width=%d,height=%d)\\n' % (options.rfile,options.imgsize,options.imgsize))\n rfhd.write('mn <- -1\\n')\n rfhd.write('mx <- 1\\n')\n rfhd.write('n <- 98\\n')\n rfhd.write('bias <- 1\\n')\n rfhd.write('mc <- matrix(as.character(round(m, 2)), ncol=dim(m)[2])\\n')\n rfhd.write('breaks <- seq(mn, mx, (mx-mn)/(n))\\n')\n rfhd.write('cr <- colorRampPalette(colors = c(\"#2927FF\",\"#FFFFFF\",\"#DF5C5C\"), bias=bias)\\n')\n rfhd.write('heatmap.2(m, col = cr(n), breaks=breaks, trace=\"none\", cellnote=mc, notecol=\"black\", notecex=1.8, keysize=0.5, density.info=\"histogram\", margins=c(27.0,27.0), cexRow=2.20, cexCol=2.20, revC=T, symm=T)\\n')\n else: # scatterplot\n rfhd.write('''\npanel.plot <- function( x,y, ... )\n{\n par(new=TRUE)\n m <- cbind(x,y)\n plot(m,col=densCols(m),pch=20)\n lines(lowess(m[!is.na(m[,1])&!is.na(m[,2]),]),col=\"red\") \n}\n \npanel.cor <- function(x, y, digits=2, prefix=\"\", cex.cor, ...)\n{\n usr <- par(\"usr\"); on.exit(par(usr))\n par(usr = c(0, 1, 0, 1))\n r <- cor(x, y,use=\"complete.obs\")\n txt <- format(c(r, 0.123456789), digits=digits)[1]\n txt <- paste(prefix, txt, sep=\"\")\n if(missing(cex.cor)) cex.cor <- 0.8/strwidth(txt)\n text(0.5, 0.5, txt, cex = cex.cor * abs(r))\n}\n''')\n labels = \",\".join(map(lambda x:\"\\\"\"+x+\"\\\"\",wiglabel))\n rfhd.write('''\npairs(c, lower.panel=panel.plot, upper.panel=panel.cor, labels=c(%s))\n''' % (labels))\n\n rfhd.write(\"dev.off()\\n\")\n rfhd.close()\n\n # try to call R\n try:\n subprocess.call(['Rscript',options.rfile])\n except:\n info(\"Please check %s\" % options.rfile)\n else:\n info(\"Please check %s\" % (options.rfile+'.bmp'))", "metadata": "root.main", "header": "['module', '___EOS___']", "index": 95 } ]
[ { "span": "step_region_a ", "start_line": 210, "start_column": 12, "end_line": 210, "end_column": 25 }, { "span": "end_of_chrom ", "start_line": 212, "start_column": 16, "end_line": 212, "end_column": 28 } ]
[]
1
true
[ "[CLS]_", "Un", "used_", "local_", "variable_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "main_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "usage_", "=_", "\"", "usage", ":", " ", "%", "prog", " ", "<-", "r", " ", "rfil", "e", ">", " ", "[", "options", "]", " ", "<", "wig", "gle", " ", "files", ">", " ", "...\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "description_", "=_", "\"", "Draw", " ", "correlation", " ", "plot", " ", "for", " ", "many", " ", "wig", "gle", " ", "files", ".", " ", "Base", "d", " ", "on", " ", "qc", "\\u", "ch", "IP", "\\u", "whole", ".", "py", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "optparse", "r_", "=_", "Optio", "n", "Parser_", "(_", "version_", "=_", "\"%", "prog", " ", "0.", "1", "\"_", ",_", "description_", "=_", "description_", ",_", "usage_", "=_", "usage_", ",_", "add", "\\u", "help", "\\u", "option_", "=_", "False_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "optparse", "r_", "._", "add", "\\u", "option_", "(_", "\"-", "h", "\"_", ",_", "\"--", "help", "\"_", ",_", "action_", "=_", "\"", "help", "\"_", ",_", "help_", "=_", "\"", "Show", " ", "this", " ", "help", " ", "message", " ", "and", " ", "exit", ".\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "optparse", "r_", "._", "add", "\\u", "option_", "(_", "\"-", "d", "\"_", ",_", "\"--", "db", "\"_", ",_", "type_", "=_", "\"", "str", "\"_", ",_", "dest_", "=_", "\"", "db", "name", "\"_", ",_", "help_", "=_", "\"", "UCS", "C", " ", "db", " ", "name", " ", "for", " ", "the", " ", "assem", "bly", ".", " ", "Default", ":", " ", "ce", "4", "\"_", ",_", "default_", "=_", "\"", "ce", "4", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "optparse", "r_", "._", "add", "\\u", "option_", "(_", "\"-", "r", "\"_", ",_", "\"--", "rfil", "e", "\"_", ",_", "dest_", "=_", "\"", "rfil", "e", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "help_", "=_", "\"", "R", " ", "output", " ", "file", ".", " ", "If", " ", "not", " ", "set", ",", " ", "do", " ", "not", " ", "save", " ", "R", " ", "file", ".\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "optparse", "r_", "._", "add", "\\u", "option_", "(_", "\"-", "s", "\"_", ",_", "\"--", "step", "\"_", ",_", "dest_", "=_", "\"", "step", "\"_", ",_", "type_", "=_", "\"", "int", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "help_", "=_", "\"", "samp", "ling", " ", "step", " ", "in", " ", "kb", "ps", ".", " ", "default", ":", " ", "100", ",", " ", "minima", "l", ":", " ", "1", "\"_", ",_", "default_", "=_", "100_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "optparse", "r_", "._", "add", "\\u", "option_", "(_", "\"-", "z", "\"_", ",_", "\"--", "imgs", "ize", "\"_", ",_", "dest_", "=_", "\"", "imgs", "ize", "\"_", ",_", "type_", "=_", "\"", "int", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "help_", "=_", "\"", "image", " ", "size", " ", "in", " ", "inch", "es", ",", " ", "note", " ", "the", " ", "PNG", " ", "dp", "i", " ", "is", " ", "72.", " ", "default", ":", " ", "10", ",", " ", "minima", "l", ":", " ", "10", "\"_", ",_", "default_", "=_", "10_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "optparse", "r_", "._", "add", "\\u", "option_", "(_", "\"-", "f", "\"_", ",_", "\"--", "format", "\"_", ",_", "dest_", "=_", "\"", "img", "format", "\"_", ",_", "type_", "=_", "\"", "string", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "help_", "=_", "\"", "image", " ", "format", ".", " ", "PD", "F", " ", "or", " ", "PNG", "\"_", ",_", "default_", "=_", "'", "PD", "F", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "optparse", "r_", "._", "add", "\\u", "option_", "(_", "\"-", "m", "\"_", ",_", "\"--", "method", "\"_", ",_", "dest_", "=_", "\"", "method", "\"_", ",_", "type_", "=_", "\"", "string", "\"_", ",_", "default_", "=_", "\"", "median", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "help_", "=_", "\"", "method", " ", "to", " ", "process", " ", "the", " ", "paired", " ", "two", " ", "sets", " ", "of", " ", "data", " ", "in", " ", "the", " ", "samp", "ling", " ", "step", ".", " ", "Choi", "ces", " ", "are", " ", "'", "median", "',", " ", "'", "mean", "',", " ", "and", " ", "'", "sample", "'", " ", "(", "just", " ", "take", " ", "one", " ", "point", " ", "out", " ", "of", " ", "a", " ", "data", " ", "set", ").", " ", "Default", ":", " ", "median", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "optparse", "r_", "._", "add", "\\u", "option_", "(_", "\"-", "l", "\"_", ",_", "\"--", "wig", "-", "label", "\"_", ",_", "dest_", "=_", "\"", "wig", "label", "\"_", ",_", "type_", "=_", "\"", "string", "\"_", ",_", "action_", "=_", "\"", "append", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "help_", "=_", "\"", "the", " ", "wig", "gle", " ", "file", " ", "labels", " ", "in", " ", "the", " ", "figure", ".", " ", "No", " ", "space", " ", "is", " ", "allow", "ed", ".", " ", "Thi", "s", " ", "option", " ", "shou", "ld", " ", "be", " ", "used", " ", "same", " ", "times", " ", "as", " ", "wig", "gle", " ", "files", ",", " ", "and", " ", "plea", "se", " ", "input", " ", "them", " ", "in", " ", "the", " ", "same", " ", "order", " ", "as", " ", "-", "w", " ", "option", ".", " ", "default", ":", " ", "will", " ", "use", " ", "the", " ", "wig", "gle", " ", "file", " ", "filename", " ", "as", " ", "labels", ".\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "optparse", "r_", "._", "add", "\\u", "option_", "(_", "\"--", "min", "-", "score", "\"_", ",_", "dest_", "=_", "\"", "mins", "core", "\"_", ",_", "type_", "=_", "\"", "float", "\"_", ",_", "default_", "=_", "-_", "10000_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "help_", "=_", "\"", "minim", "um", " ", "score", " ", "include", "d", " ", "in", " ", "calculati", "on", ".", " ", "Point", "s", " ", "w", "/", " ", "score", " ", "lower", " ", "than", " ", "this", " ", "will", " ", "be", " ", "discard", "ed", ".\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "optparse", "r_", "._", "add", "\\u", "option_", "(_", "\"--", "max", "-", "score", "\"_", ",_", "dest_", "=_", "\"", "maxs", "core", "\"_", ",_", "type_", "=_", "\"", "float", "\"_", ",_", "default_", "=_", "10000_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "help_", "=_", "\"", "maxim", "um", " ", "score", " ", "include", "d", " ", "in", " ", "calculati", "on", ".", " ", "Point", "s", " ", "w", "/", " ", "score", " ", "large", "r", " ", "than", " ", "this", " ", "will", " ", "be", " ", "discard", "ed", ".\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "optparse", "r_", "._", "add", "\\u", "option_", "(_", "\"-", "H", "\"_", ",_", "\"--", "heatmap", "\"_", ",_", "dest_", "=_", "\"", "heatmap", "\"_", ",_", "action_", "=_", "\"", "store", "\\u", "true", "\"_", ",_", "default_", "=_", "False_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "help_", "=_", "\"", "If", " ", "Tru", "e", ",", " ", "a", " ", "heatmap", " ", "image", " ", "will", " ", "be", " ", "generat", "ed", " ", "inst", "ead", " ", "of", " ", "paired", " ", "scatter", "plot", " ", "image", ".\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "options_", ",_", "wig", "files_", ")_", "=_", "optparse", "r_", "._", "parse", "\\u", "args_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "img", "fmt_", "=_", "options_", "._", "img", "format_", "._", "upper_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "img", "fmt_", "!=_", "'", "PD", "F", "'_", "and_", "img", "fmt_", "!=_", "'", "PNG", "'_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "print_", "\"", "unre", "cogni", "zed", " ", "format", ":", " ", "%", "s", "\"_", "%_", "img", "fmt_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "sys_", "._", "exit_", "(_", "1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "method_", "=_", "options_", "._", "method_", "._", "lower_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "method_", "==_", "'", "median", "'_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "med", "func_", "=_", "median_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "method_", "==_", "'", "mean", "'_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "med", "func_", "=_", "mean_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "method_", "==_", "'", "sample", "'_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "med", "func_", "=_", "lambda_", "u_", ":_", "u_", "[_", "-_", "1_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "print_", "\"", "unre", "cogni", "zed", " ", "method", ":", " ", "%", "s", "\"_", "%_", "(_", "method_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "sys_", "._", "exit_", "(_", "1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "wig", "filen", "um_", "=_", "len_", "(_", "wig", "files_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "must", " ", "provide", " ", ">=", "2", " ", "wig", "gle", " ", "files_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "wig", "filen", "um_", "<_", "2_", "or_", "not_", "options_", "._", "rfile_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "optparse", "r_", "._", "print", "\\u", "help_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "sys_", "._", "exit_", "(_", "1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "wig", " ", "labels_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "options_", "._", "wig", "label_", "and_", "len_", "(_", "options_", "._", "wig", "label_", ")_", "==_", "wig", "filen", "um_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "wig", "label_", "=_", "options_", "._", "wig", "label_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "#", " ", "or", " ", "use", " ", "the", " ", "filename_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "wig", "label_", "=_", "map_", "(_", "lambda_", "x_", ":_", "os_", "._", "path_", "._", "basename_", "(_", "x_", ")_", ",_", "wig", "files_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "options_", "._", "step_", "<_", "1_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "error_", "(_", "\"", "Step", " ", "can", " ", "not", " ", "be", " ", "lower", " ", "than", " ", "1", "!\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "sys_", "._", "exit_", "(_", "1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "options_", "._", "imgs", "ize_", "<_", "10_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "error_", "(_", "\"", "Image", " ", "size", " ", "can", " ", "not", " ", "be", " ", "lower", " ", "than", " ", "10", "!\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "sys_", "._", "exit_", "(_", "1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "check", " ", "the", " ", "files_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "for_", "f_", "in_", "wig", "files_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "not_", "os_", "._", "path_", "._", "isfile_", "(_", "f_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "error_", "(_", "\"%", "s", " ", "is", " ", "not", " ", "valid", "!\"_", "%_", "f_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "sys_", "._", "exit_", "(_", "1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "wig", "fh", "ds_", "=_", "map_", "(_", "open_", ",_", "wig", "files_", ")_", "#", " ", "file", " ", "handler", "s", " ", "for", " ", "wig", "gle", " ", "files_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "info_", "(_", "\"", "number", " ", "of", " ", "wig", "gle", " ", "files", ":", " ", "%", "d", "\"_", "%_", "wig", "filen", "um_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "get", " ", "chromo", "some", " ", "length", " ", "info", " ", "from", " ", "UCS", "C_", "\\u\\u\\uNL\\u\\u\\u_", "info_", "(_", "\"", "connect", " ", "to", " ", "UCS", "C", " ", "to", " ", "get", " ", "chromo", "some", " ", "length", " ", "informati", "on", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "chrom", "\\u", "len_", "=_", "get", "\\u", "chrom", "\\u", "length_", "(_", "options_", "._", "dbname_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "error_", "(_", "\"", "Error", "!\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "sys_", "._", "exit_", "(_", "1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "get", " ", "the", " ", "common", " ", "chromo", "some", " ", "list", ":_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "chrom", "sdi", "ct_", "=_", "{_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "wig", "fh", "d_", "in_", "wig", "fh", "ds_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "tmps", "et_", "=_", "set_", "(_", "[_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "l_", "in_", "wig", "fh", "d_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "l_", "._", "find_", "(_", "\"", "chrom", "=\"_", ")_", "!=_", "-_", "1_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "c_", "=_", "re_", "._", "search_", "(_", "\"", "chrom", "=(", "\\\\", "w", "+)\"_", ",_", "l_", ")_", "._", "group_", "(_", "1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "tmps", "et_", "._", "add_", "(_", "c_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "for_", "c_", "in_", "tmps", "et_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "chrom", "sdi", "ct_", "[_", "c_", "]_", "=_", "chrom", "sdi", "ct_", "._", "setdefault_", "(_", "c_", ",_", "0_", ")_", "+_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "chrom", "s_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "c_", "in_", "chrom", "sdi", "ct_", "._", "keys_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "chrom", "sdi", "ct_", "[_", "c_", "]_", "==_", "wig", "filen", "um_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "chrom", "s_", "._", "append_", "(_", "c_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "info_", "(_", "\"", "common", " ", "chromosomes", " ", "are", " ", "%", "s", "...\"_", "%_", "\",\"_", "._", "join_", "(_", "chrom", "s_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "options_", "._", "rfile_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "rf", "hd_", "=_", "open_", "(_", "options_", "._", "rfile_", ",_", "\"", "w", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "rf", "hd_", "._", "write_", "(_", "'''", "\\", "10", ";", "require", "(\"", "RC", "olor", "Bre", "wer", "\")", " ", "##", " ", "from", " ", "CRA", "N", "\\", "10", ";'", "''_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "for", " ", "each", " ", "wig", " ", "file", ",", " ", "sample", "..._", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "for_", "i_", "in_", "range_", "(_", "len_", "(_", "wig", "fh", "ds_", ")_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "wig", "fh", "d_", "=_", "wig", "fh", "ds_", "[_", "i_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "wig", "fh", "d_", "._", "seek_", "(_", "0_", ")_", "#", " ", "reset_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "info_", "(_", "\"", "read", " ", "wig", "gle", " ", "track", " ", "from", " ", "wig", "gle", " ", "file", " ", "#", "%", "d", "\"_", "%_", "(_", "i_", "+_", "1_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "wig", "_", "=_", "Wi", "ggle", "IO_", "._", "Wi", "ggle", "IO_", "(_", "wig", "fh", "d_", ")_", "._", "build", "\\u", "bin", "Keep", "er_", "(_", "chrom", "Len", "Dict_", "=_", "chrom", "\\u", "len_", ",_", "bin_", "=_", "options_", "._", "step_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "p_", "=_", "[_", "]_", "#", " ", "size", " ", "of", " ", "p", " ", "is", " ", "number", " ", "of", " ", "cag", "es", " ", "in", " ", "bin", "keeper", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "ap_", "=_", "p_", "._", "append_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "chrom_", "in_", "chrom", "s_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "step", "\\u", "region_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "step", "\\u", "region", "\\u", "a_", "=_", "step", "\\u", "region_", "._", "append_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "end", "\\u", "of", "\\u", "chrom_", "=_", "chrom", "\\u", "len_", "[_", "chrom_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "warn_", "(_", "\"", "chromo", "some", " ", "%", "s", " ", "can", " ", "not", " ", "be", " ", "found", " ", "in", " ", "UCS", "C", "...", " ", "skip", "...\"_", "%_", "chrom_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "continue_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "bk", "eep", "er_", "=_", "wig", "_", "[_", "chrom_", "]_", "#", " ", "bin", "keeper", " ", "object_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "(_", "parr", "ay_", ",_", "var", "ray_", ")_", "in_", "bk", "eep", "er_", "._", "cag", "e_", ":_", "#", " ", "for", " ", "each", " ", "cag", "e", " ", "in", " ", "bin", "keeper", ",", " ", "there", " ", "are", " ", "[", "position", " ", "array", "]", " ", "and", " ", "[", "value", " ", "array", "].", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "var", "ray_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "ap_", "(_", "med", "func_", "(_", "var", "ray_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "ap_", "(_", "None_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "info_", "(_", "\"", "write", " ", "values", " ", "to", " ", "r", " ", "file", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "rf", "hd_", "._", "write_", "(_", "\"", "p", "%", "d", " ", "<-", " ", "c", "(\"_", "%_", "i_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "p_", "[_", "0_", "]_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "rf", "hd_", "._", "write_", "(_", "\"%", "f", "\"_", "%_", "p_", "[_", "0_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "rf", "hd_", "._", "write_", "(_", "\"", "NA", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "for_", "v_", "in_", "p_", "[_", "1_", ":_", "]_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "v_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "rf", "hd_", "._", "write_", "(_", "\",", "%", "f", "\"_", "%_", "v_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "rf", "hd_", "._", "write_", "(_", "\",", "NA", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "rf", "hd_", "._", "write_", "(_", "\")\\\\", "n", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "rf", "hd_", "._", "write_", "(_", "\"", "c", " ", "<-", " ", "cb", "ind", "(", "p0", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "i_", "in_", "range_", "(_", "wig", "filen", "um_", "-_", "1_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "rf", "hd_", "._", "write_", "(_", "\",", "p", "%", "d", "\"_", "%_", "(_", "i_", "+_", "1_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "rf", "hd_", "._", "write_", "(_", "\")\\\\", "n", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "rf", "hd_", "._", "write_", "(_", "\"", "c", " ", "<-", " ", "c", "[", " ", "c", "[", ",", "1", "]<", "=", "%", "f", " ", "&", " ", "c", "[", ",", "1", "]>", "=", "%", "f", " ", "\"_", "%_", "(_", "options_", "._", "maxs", "core_", ",_", "options_", "._", "mins", "core_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "i_", "in_", "range_", "(_", "wig", "filen", "um_", "-_", "1_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "rf", "hd_", "._", "write_", "(_", "\"&", " ", "c", "[", ",%", "d", "]<", "=", "%", "f", " ", "&", " ", "c", "[", ",%", "d", "]>", "=", "%", "f", " ", "\"_", "%_", "(_", "i_", "+_", "2_", ",_", "options_", "._", "maxs", "core_", ",_", "i_", "+_", "2_", ",_", "options_", "._", "mins", "core_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "rf", "hd_", "._", "write_", "(_", "\",", "]\\\\", "n", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "img", "fmt_", "==_", "'", "PD", "F", "'_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "rf", "hd_", "._", "write_", "(_", "\"", "pdf", "(\\\\\"", "%", "s", ".", "pdf", "\\\\\",", "widt", "h", "=", "%", "d", ",", "height", "=", "%", "d", ")\\\\", "n", "\"_", "%_", "(_", "options_", "._", "rfile_", ",_", "options_", "._", "imgs", "ize_", ",_", "options_", "._", "imgs", "ize_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "img", "fmt_", "==_", "'", "PNG", "'_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "rf", "hd_", "._", "write_", "(_", "\"", "png", "(\\\\\"", "%", "s", ".", "png", "\\\\\",", "unit", "s", "=\\\\\"", "in", "\\\\\",", "res", "=", "150", ",", "widt", "h", "=", "%", "d", ",", "height", "=", "%", "d", ")\\\\", "n", "\"_", "%_", "(_", "options_", "._", "rfile_", ",_", "options_", "._", "imgs", "ize_", ",_", "options_", "._", "imgs", "ize_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "options_", "._", "heatmap", "_", ":_", "#", " ", "heatmap", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "rf", "hd_", "._", "write_", "(_", "'", "librar", "y", "(", "gpl", "ots", ")\\\\", "n", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "rf", "hd_", "._", "write_", "(_", "'''", "\\", "10", ";", "m", " ", "<-", " ", "cor", "(", "c", ",", " ", "method", "=\"", "pearson", "\",", " ", "use", "=\"", "pairwise", ".", "complete", ".", "obs", "\")", "\\", "10", ";'", "''_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "labels_", "=_", "\",\"_", "._", "join_", "(_", "map_", "(_", "lambda_", "x_", ":_", "\"\\\\\"\"_", "+_", "x_", "+_", "\"\\\\\"\"_", ",_", "wig", "label_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "rf", "hd_", "._", "write_", "(_", "\"", "rown", "ames", "(", "m", ")", " ", "<-", " ", "c", "(%", "s", ")\\\\", "n", "\"_", "%_", "labels_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "rf", "hd_", "._", "write_", "(_", "\"", "coln", "ames", "(", "m", ")", " ", "<-", " ", "c", "(%", "s", ")\\\\", "n", "\"_", "%_", "labels_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "rf", "hd_", "._", "write_", "(_", "'#", " ", "draw", " ", "the", " ", "heatmap", " ", "usi", "ng", " ", "gpl", "ots", " ", "heatmap", ".2", "\\\\", "n", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", " ", " ", " ", "rf", "hd", ".", "write", "('", "bitmap", "(\"", "%", "s", ".", "bm", "p", "\",", "widt", "h", "=", "%", "d", ",", "height", "=", "%", "d", ")\\\\", "n", "'", " ", "%", " ", "(", "options", ".", "rfil", "e", ",", "options", ".", "imgs", "ize", ",", "options", ".", "imgs", "ize", "))", "_", "\\u\\u\\uNL\\u\\u\\u_", "rf", "hd_", "._", "write_", "(_", "'", "mn", " ", "<-", " ", "-1", "\\\\", "n", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "rf", "hd_", "._", "write_", "(_", "'", "mx", " ", "<-", " ", "1", "\\\\", "n", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "rf", "hd_", "._", "write_", "(_", "'", "n", " ", "<-", " ", "98", "\\\\", "n", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "rf", "hd_", "._", "write_", "(_", "'", "bias", " ", "<-", " ", "1", "\\\\", "n", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "rf", "hd_", "._", "write_", "(_", "'", "mc", " ", "<-", " ", "matrix", "(", "as", ".", "character", "(", "round", "(", "m", ",", " ", "2", "))", ",", " ", "ncol", "=", "dim", "(", "m", ")[", "2", "])\\\\", "n", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "rf", "hd_", "._", "write_", "(_", "'", "breaks", " ", "<-", " ", "seq", "(", "mn", ",", " ", "mx", ",", " ", "(", "mx", "-", "mn", ")/(", "n", "))\\", "\\", "n", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "rf", "hd_", "._", "write_", "(_", "'", "cr", " ", "<-", " ", "color", "Ramp", "Palette", "(", "colors", " ", "=", " ", "c", "(\"", "#", "292", "7", "FF", "\",\"", "#", "FFFF", "FF", "\",\"", "#", "DF", "5", "C5", "C", "\")", ",", " ", "bias", "=", "bias", ")\\\\", "n", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "rf", "hd_", "._", "write_", "(_", "'", "heatmap", ".2", "(", "m", ",", " ", "col", " ", "=", " ", "cr", "(", "n", "),", " ", "breaks", "=", "breaks", ",", " ", "trace", "=\"", "none", "\",", " ", "cell", "note", "=", "mc", ",", " ", "note", "col", "=\"", "black", "\",", " ", "note", "ce", "x", "=", "1.8", ",", " ", "keys", "ize", "=", "0.", "5", ",", " ", "densit", "y", ".", "info", "=\"", "histo", "gram", "\",", " ", "margins", "=", "c", "(", "27.", "0", ",", "27.", "0", "),", " ", "ce", "x", "Row", "=", "2.2", "0", ",", " ", "ce", "x", "Col", "=", "2.2", "0", ",", " ", "rev", "C", "=", "T", ",", " ", "symm", "=", "T", ")\\\\", "n", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "#", " ", "scatter", "plot_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "rf", "hd_", "._", "write_", "(_", "'''", "\\", "10", ";", "panel", ".", "plot", " ", "<-", " ", "function", "(", " ", "x", ",", "y", ",", " ", "...", " ", ")", "\\", "10", ";", "{", "\\", "10", ";", " ", " ", "par", "(", "new", "=", "TRU", "E", ")", "\\", "10", ";", " ", " ", "m", " ", "<-", " ", "cb", "ind", "(", "x", ",", "y", ")", "\\", "10", ";", " ", " ", "plot", "(", "m", ",", "col", "=", "dens", "Col", "s", "(", "m", "),", "pch", "=", "20", ")", "\\", "10", ";", " ", " ", "lines", "(", "lowe", "ss", "(", "m", "[!", "is", ".", "na", "(", "m", "[", ",", "1", "])", "&", "!", "is", ".", "na", "(", "m", "[", ",", "2", "])", ",]", "),", "col", "=\"", "red", "\")", " ", " ", "\\", "10", ";}", "\\", "10", ";", " ", " ", " ", " ", "\\", "10", ";", "panel", ".", "cor", " ", "<-", " ", "function", "(", "x", ",", " ", "y", ",", " ", "digit", "s", "=", "2", ",", " ", "prefix", "=\"\"", ",", " ", "ce", "x", ".", "cor", ",", " ", "...)", "\\", "10", ";", "{", "\\", "10", ";", " ", " ", "usr", " ", "<-", " ", "par", "(\"", "usr", "\");", " ", "on", ".", "exit", "(", "par", "(", "usr", "))\\", "10", ";", " ", " ", "par", "(", "usr", " ", "=", " ", "c", "(", "0", ",", " ", "1", ",", " ", "0", ",", " ", "1", "))\\", "10", ";", " ", " ", "r", " ", "<-", " ", "cor", "(", "x", ",", " ", "y", ",", "use", "=\"", "complete", ".", "obs", "\")", "\\", "10", ";", " ", " ", "txt", " ", "<-", " ", "format", "(", "c", "(", "r", ",", " ", "0.12", "3456", "789", "),", " ", "digit", "s", "=", "digit", "s", ")[", "1", "]", "\\", "10", ";", " ", " ", "txt", " ", "<-", " ", "paste", "(", "prefix", ",", " ", "txt", ",", " ", "sep", "=\"\"", ")", "\\", "10", ";", " ", " ", "if", "(", "missi", "ng", "(", "ce", "x", ".", "cor", "))", " ", "ce", "x", ".", "cor", " ", "<-", " ", "0.", "8", "/", "str", "widt", "h", "(", "txt", ")", "\\", "10", ";", " ", " ", "text", "(", "0.", "5", ",", " ", "0.", "5", ",", " ", "txt", ",", " ", "ce", "x", " ", "=", " ", "ce", "x", ".", "cor", " ", "*", " ", "abs", "(", "r", "))\\", "10", ";}", "\\", "10", ";'", "''_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "labels_", "=_", "\",\"_", "._", "join_", "(_", "map_", "(_", "lambda_", "x_", ":_", "\"\\\\\"\"_", "+_", "x_", "+_", "\"\\\\\"\"_", ",_", "wig", "label_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "rf", "hd_", "._", "write_", "(_", "'''", "\\", "10", ";", "pair", "s", "(", "c", ",", " ", "lower", ".", "panel", "=", "panel", ".", "plot", ",", " ", "upper", ".", "panel", "=", "panel", ".", "cor", ",", " ", "labels", "=", "c", "(%", "s", "))\\", "10", ";'", "''_", "%_", "(_", "labels_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "rf", "hd_", "._", "write_", "(_", "\"", "dev", ".", "off", "()", "\\\\", "n", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "rf", "hd_", "._", "close_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "try", " ", "to", " ", "call", " ", "R_", "\\u\\u\\uNL\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "subprocess_", "._", "call_", "(_", "[_", "'", "Rs", "cript", "'_", ",_", "options_", "._", "rfile_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "info_", "(_", "\"", "Ple", "ase", " ", "check", " ", "%", "s", "\"_", "%_", "options_", "._", "rfile_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "info_", "(_", "\"", "Ple", "ase", " ", "check", " ", "%", "s", "\"_", "%_", "(_", "options_", "._", "rfile_", "+_", "'.", "bm", "p", "'_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_" ]
[ 4, 4, 4, 4, 4, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2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, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 ]
Unused import
jumoconnect/openjumo/jumodjango/mailer/messager_tasks.py
[ { "content": "from celery.task import task\nfrom donation.models import Donor\nimport logging\nfrom message.models import Message, Publication\nimport socket\n\n\n\n", "metadata": "root", "header": "['module', '___EOS___']", "index": 0 }, { "content": "@task(ignore_result=True, rate_limit='10/s')\ndef _send_user_message(message_id, campaign_id):\n message = Message.get(message_id)\n pub_id = message.publication_id\n publication = Publication.get(pub_id)\n donor_ids = publication.get_subscribed_donor_ids()\n\n for donor_id in donor_ids:\n _email_donor.delay(donor_id, message.id)", "metadata": "root._send_user_message", "header": "['module', '___EOS___']", "index": 7 }, { "content": "def send_user_message(message_id):\n \"\"\" Make this call appear synchronous. Usage:\n\n send_user_message(1)\n\n Actually an asynchronous task\n \"\"\"\n\n try:\n _send_user_message.delay(message_id)\n except socket.timeout:\n logging.error(\"Couldn't send message due to socket timeout. Rabbit may be down\")", "metadata": "root.send_user_message", "header": "['module', '___EOS___']", "index": 17 } ]
[ { "span": "from donation.models import Donor", "start_line": 1, "start_column": 0, "end_line": 1, "end_column": 33 } ]
[]
1
false
[ "[CLS]_", "Un", "used_", "import_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "from_", "celery_", "._", "task_", "import_", "task_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "donation", "_", "._", "models_", "import_", "Donor", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "logging_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "message_", "._", "models_", "import_", "Message_", ",_", "Public", "ation_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "socket_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "@_", "task_", "(_", "ignore", "\\u", "result_", "=_", "True_", ",_", "rate", "\\u", "limit_", "=_", "'", "10", "/", "s", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "\\u", "send", "\\u", "user", "\\u", "message_", "(_", "message", "\\u", "id_", ",_", "camp", "aig", "n", "\\u", "id_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "message_", "=_", "Message_", "._", "get_", "(_", "message", "\\u", "id_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "pub", "\\u", "id_", "=_", "message_", "._", "publicat", "ion", "\\u", "id_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "publicat", "ion_", "=_", "Public", "ation_", "._", "get_", "(_", "pub", "\\u", "id_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "donor", "\\u", "ids_", "=_", "publicat", "ion_", "._", "get", "\\u", "subscribed", "\\u", "donor", "\\u", "ids_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "for_", "donor", "\\u", "id_", "in_", "donor", "\\u", "ids_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\\u", "email", "\\u", "donor", "_", "._", "delay_", "(_", "donor", "\\u", "id_", ",_", "message_", "._", "id_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "send", "\\u", "user", "\\u", "message_", "(_", "message", "\\u", "id_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", " ", "Make", " ", "this", " ", "call", " ", "appear", " ", "synchron", "ous", ".", " ", "Us", "age", ":", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "send", "\\u", "user", "\\u", "message", "(", "1", ")", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "Actual", "ly", " ", "an", " ", "async", "hronous", " ", "task", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\\u", "send", "\\u", "user", "\\u", "message_", "._", "delay_", "(_", "message", "\\u", "id_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "socket_", "._", "timeout_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "logging_", "._", "error_", "(_", "\"", "Cou", "ld", "n", "'", "t", " ", "send", " ", "message", " ", "due", " ", "to", " ", "socket", " ", "timeo", "ut", ".", " ", "Ra", "bbi", "t", " ", "may", " ", "be", " ", "down", "\"_", ")_" ]
[ 4, 4, 4, 4, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 ]
Testing equality to None
aerospike/aerospike-client-python/test/old_tests/test_admin_query_user.py
[ { "content": "class TestQueryUser(TestBaseClass):\n\n pytestmark = pytest.mark.skipif(\n TestBaseClass().get_hosts()[1] == None,\n reason=\"No user specified, may be not secured cluster.\")\n\n\n\n\n\n\n\n\n\n\n\n", "metadata": "root.TestQueryUser", "header": "['module', '___EOS___']", "index": 16 } ]
[ { "span": "TestBaseClass().get_hosts()[1] == None,", "start_line": 19, "start_column": 8, "end_line": 19, "end_column": 46 } ]
[]
1
true
[ "[CLS]_", "Test", "ing_", "equality", "_", "to_", "None_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "class_", "Test", "Query", "User_", "(_", "Test", "Base", "Class_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "pytest", "mark_", "=_", "pytest_", "._", "mark_", "._", "skipif_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "Test", "Base", "Class_", "(_", ")_", "._", "get", "\\u", "hosts_", "(_", ")_", "[_", "1_", "]_", "==_", "None_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "reason_", "=_", "\"", "No", " ", "user", " ", "specified", ",", " ", "may", " ", "be", " ", "not", " ", "secure", "d", " ", "cluster", ".\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_" ]
[ 4, 4, 4, 4, 4, 4, 4, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 ]
Module is imported with 'import' and 'import from'
Yelp/mrjob/mrjob/util.py
[ { "content": "# Copyright 2009-2015 Yelp and Contributors\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file except in compliance with the License.\n# You may obtain a copy of the License at\n#\n# http://www.apache.org/licenses/LICENSE-2.0\n#\n# Unless required by applicable law or agreed to in writing, software\n# distributed under the License is distributed on an \"AS IS\" BASIS,\n# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n# See the License for the specific language governing permissions and\n# limitations under the License.\n\"\"\"Utility functions for MRJob that have no external dependencies.\"\"\"\n\n# don't add imports here that aren't part of the standard Python library,\n# since MRJobs need to run in Amazon's generic EMR environment\nimport contextlib\nimport glob\nimport itertools\nimport logging\nimport os\nimport pipes\nimport random\nimport shlex\nimport shutil\nimport sys\nimport tarfile\nimport zipfile\nimport zlib\nfrom collections import defaultdict\nfrom copy import deepcopy\nfrom datetime import timedelta\nfrom distutils.spawn import find_executable\nfrom logging import getLogger\n\ntry:\n import bz2\n bz2 # redefine bz2 for pepflakes\nexcept ImportError:\n bz2 = None\n\nfrom mrjob.py2 import PY2\n\nlog = getLogger(__name__)\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n# Thanks to http://lybniz2.sourceforge.net/safeeval.html for\n# explaining how to do this!\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n", "metadata": "root", "header": "['module', '___EOS___']", "index": 0 } ]
[ { "span": "import logging", "start_line": 20, "start_column": 0, "end_line": 20, "end_column": 14 } ]
[]
1
true
[ "[CLS]_", "Module_", "is_", "imported_", "with_", "'", "import", "'_", "and_", "'", "import", " ", "from", "'_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "#", " ", "Copy", "right", " ", "200", "9", "-", "201", "5", " ", "Ye", "lp", " ", "and", " ", "Contributor", "s_", "\\u\\u\\uNL\\u\\u\\u_", "#", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "License", "d", " ", "under", " ", "the", " ", "Ap", "ache", " ", "License", ",", " ", "Version", " ", "2.0", " ", "(", "the", " ", "\"", "License", "\");", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "you", " ", "may", " ", "not", " ", "use", " ", "this", " ", "file", " ", "except", " ", "in", " ", "compli", "anc", "e", " ", "with", " ", "the", " ", "License", "._", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "You", " ", "may", " ", "obtain", " ", "a", " ", "copy", " ", "of", " ", "the", " ", "License", " ", "at_", "\\u\\u\\uNL\\u\\u\\u_", "#", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "http", "://", "www", ".", "apa", "che", ".", "org", "/", "license", "s", "/", "LICENSE", "-", "2.0_", "\\u\\u\\uNL\\u\\u\\u_", "#", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Un", "less", " ", "require", "d", " ", "by", " ", "applica", "ble", " ", "law", " ", "or", " ", "agree", "d", " ", "to", " ", "in", " ", "writ", "ing", ",", " ", "software", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "distributed", " ", "under", " ", "the", " ", "License", " ", "is", " ", "distributed", " ", "on", " ", "an", " ", "\"", "AS", " ", "IS", "\"", " ", "BAS", "IS", ",_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "WITH", "OUT", " ", "WAR", "RAN", "TIES", " ", "OR", " ", "CONDITION", "S", " ", "OF", " ", "ANY", " ", "KIND", ",", " ", "eit", "her", " ", "express", " ", "or", " ", "impli", "ed", "._", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "See", " ", "the", " ", "License", " ", "for", " ", "the", " ", "specific", " ", "language", " ", "govern", "ing", " ", "permissi", "ons", " ", "and_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "limit", "ation", "s", " ", "under", " ", "the", " ", "License", "._", "\\u\\u\\uNL\\u\\u\\u_", "\"\"\"", "Utili", "ty", " ", "function", "s", " ", "for", " ", "MR", "Jo", "b", " ", "tha", "t", " ", "have", " ", "no", " ", "external", " ", "dependen", "cies", ".\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "don", "'", "t", " ", "add", " ", "import", "s", " ", "here", " ", "tha", "t", " ", "are", "n", "'", "t", " ", "part", " ", "of", " ", "the", " ", "standard", " ", "Pyth", "on", " ", "librar", "y", ",_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "sinc", "e", " ", "MR", "Jo", "bs", " ", "need", " ", "to", " ", "run", " ", "in", " ", "Ama", "zon", "'", "s", " ", "gener", "ic", " ", "EM", "R", " ", "environment_", "\\u\\u\\uNL\\u\\u\\u_", "import_", "contextlib_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "glob_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "itertools_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "logging_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "os_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "pipes_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "random_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "shlex_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "shutil_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "sys_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "tarfile_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "zipfile_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "zlib_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "collections_", "import_", "defaultdict_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "copy_", "import_", "deepcopy_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "datetime_", "import_", "timedelta_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "distutils_", "._", "spawn_", "import_", "find", "\\u", "executable_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "logging_", "import_", "get", "Logger_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "import_", "bz2", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "bz2", "_", "#", " ", "rede", "fine", " ", "bz2", " ", "for", " ", "pep", "flake", "s_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "Import", "Error_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "bz2", "_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "from_", "mr", "job_", "._", "py2", "_", "import_", "PY", "2_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "log_", "=_", "get", "Logger_", "(_", "\\u\\u", "name\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Thanks", " ", "to", " ", "http", "://", "ly", "bn", "iz", "2", ".", "sourcef", "org", "e", ".", "net", "/", "safe", "eval", ".", "html", " ", "for_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "explain", "ing", " ", "how", " ", "to", " ", "do", " ", "this", "!", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_" ]
[ 4, 4, 4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 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 ]
Except block handles 'BaseException'
mrknow/filmkodi/plugin.video.specto/resources/lib/libraries/simpledownloader.py
[ { "content": "def download(name, image, url):\n\n from resources.lib.libraries import control\n\n if url == None:\n return control.infoDialog(control.lang(30501).encode('utf-8'))\n\n try: headers = dict(urlparse.parse_qsl(url.rsplit('|', 1)[1]))\n except: headers = dict('')\n\n url = url.split('|')[0]\n\n content = re.compile('(.+?)\\sS(\\d*)E\\d*$').findall(name)\n transname = name.translate(None, '\\/:*?\"<>|').strip('.')\n levels =['../../../..', '../../..', '../..', '..']\n\n if len(content) == 0:\n dest = control.setting('movie_downloads')\n dest = control.transPath(dest)\n for level in levels:\n try: control.makeFile(os.path.abspath(os.path.join(dest, level)))\n except: pass\n control.makeFile(dest)\n dest = os.path.join(dest, transname)\n control.makeFile(dest)\n else:\n dest = control.setting('tv_downloads')\n dest = control.transPath(dest)\n for level in levels:\n try: control.makeFile(os.path.abspath(os.path.join(dest, level)))\n except: pass\n control.makeFile(dest)\n transtvshowtitle = content[0][0].translate(None, '\\/:*?\"<>|').strip('.')\n dest = os.path.join(dest, transtvshowtitle)\n control.makeFile(dest)\n dest = os.path.join(dest, 'Season %01d' % int(content[0][1]))\n control.makeFile(dest)\n\n ext = os.path.splitext(urlparse.urlparse(url).path)[1][1:]\n if not ext in ['mp4', 'mkv', 'flv', 'avi', 'mpg']: ext = 'mp4'\n dest = os.path.join(dest, transname + '.' + ext)\n\n sysheaders = urllib.quote_plus(json.dumps(headers))\n\n sysurl = urllib.quote_plus(url)\n\n systitle = urllib.quote_plus(name)\n\n sysimage = urllib.quote_plus(image)\n\n sysdest = urllib.quote_plus(dest)\n\n script = inspect.getfile(inspect.currentframe())\n cmd = 'RunScript(%s, %s, %s, %s, %s, %s)' % (script, sysurl, sysdest, systitle, sysimage, sysheaders)\n\n xbmc.executebuiltin(cmd)", "metadata": "root.download", "header": "['module', '___EOS___']", "index": 32 }, { "content": "def getResponse(url, headers, size):\n try:\n if size > 0:\n size = int(size)\n headers['Range'] = 'bytes=%d-' % size\n\n req = urllib2.Request(url, headers=headers)\n\n resp = urllib2.urlopen(req, timeout=30)\n return resp\n except:\n return None", "metadata": "root.getResponse", "header": "['module', '___EOS___']", "index": 90 }, { "content": "def doDownload(url, dest, title, image, headers):\n\n headers = json.loads(urllib.unquote_plus(headers))\n\n url = urllib.unquote_plus(url)\n\n title = urllib.unquote_plus(title)\n\n image = urllib.unquote_plus(image)\n\n dest = urllib.unquote_plus(dest)\n\n file = dest.rsplit(os.sep, 1)[-1]\n\n resp = getResponse(url, headers, 0)\n\n if not resp:\n xbmcgui.Dialog().ok(title, dest, 'Download failed', 'No response from server')\n return\n\n try: content = int(resp.headers['Content-Length'])\n except: content = 0\n\n try: resumable = 'bytes' in resp.headers['Accept-Ranges'].lower()\n except: resumable = False\n\n #print \"Download Header\"\n #print resp.headers\n if resumable:\n print \"Download is resumable\"\n\n if content < 1:\n xbmcgui.Dialog().ok(title, file, 'Unknown filesize', 'Unable to download')\n return\n\n size = 1024 * 1024\n mb = content / (1024 * 1024)\n\n if content < size:\n size = content\n\n total = 0\n notify = 0\n errors = 0\n count = 0\n resume = 0\n sleep = 0\n\n if xbmcgui.Dialog().yesno(title + ' - Confirm Download', file, 'Complete file is %dMB' % mb, 'Continue with download?', 'Confirm', 'Cancel') == 1:\n return\n\n print 'Download File Size : %dMB %s ' % (mb, dest)\n\n #f = open(dest, mode='wb')\n f = xbmcvfs.File(dest, 'w')\n\n chunk = None\n chunks = []\n\n while True:\n downloaded = total\n for c in chunks:\n downloaded += len(c)\n percent = min(100 * downloaded / content, 100)\n if percent >= notify:\n xbmc.executebuiltin( \"XBMC.Notification(%s,%s,%i,%s)\" % ( title + ' - Download Progress - ' + str(percent)+'%', dest, 10000, image))\n\n print 'Download percent : %s %s %dMB downloaded : %sMB File Size : %sMB' % (str(percent)+'%', dest, mb, downloaded / 1000000, content / 1000000)\n\n notify += 10\n\n chunk = None\n error = False\n\n try: \n chunk = resp.read(size)\n if not chunk:\n if percent < 99:\n error = True\n else:\n while len(chunks) > 0:\n c = chunks.pop(0)\n f.write(c)\n del c\n\n f.close()\n print '%s download complete' % (dest)\n return done(title, dest, True)\n\n except Exception, e:\n print str(e)\n error = True\n sleep = 10\n errno = 0\n\n if hasattr(e, 'errno'):\n errno = e.errno\n\n if errno == 10035: # 'A non-blocking socket operation could not be completed immediately'\n pass\n\n if errno == 10054: #'An existing connection was forcibly closed by the remote host'\n errors = 10 #force resume\n sleep = 30\n\n if errno == 11001: # 'getaddrinfo failed'\n errors = 10 #force resume\n sleep = 30\n\n if chunk:\n errors = 0\n chunks.append(chunk)\n if len(chunks) > 5:\n c = chunks.pop(0)\n f.write(c)\n total += len(c)\n del c\n\n if error:\n errors += 1\n count += 1\n print '%d Error(s) whilst downloading %s' % (count, dest)\n xbmc.sleep(sleep*1000)\n\n if (resumable and errors > 0) or errors >= 10:\n if (not resumable and resume >= 50) or resume >= 500:\n #Give up!\n print '%s download canceled - too many error whilst downloading' % (dest)\n return done(title, dest, False)\n\n resume += 1\n errors = 0\n if resumable:\n chunks = []\n #create new response\n print 'Download resumed (%d) %s' % (resume, dest)\n resp = getResponse(url, headers, total)\n else:\n #use existing response\n pass", "metadata": "root.doDownload", "header": "['module', '___EOS___']", "index": 124 } ]
[ { "span": "except: ", "start_line": 40, "start_column": 4, "end_line": 40, "end_column": 11 }, { "span": "except: ", "start_line": 53, "start_column": 12, "end_line": 53, "end_column": 19 }, { "span": "except: ", "start_line": 62, "start_column": 12, "end_line": 62, "end_column": 19 }, { "span": "except:", "start_line": 100, "start_column": 4, "end_line": 100, "end_column": 11 }, { "span": "except: ", "start_line": 145, "start_column": 4, "end_line": 145, "end_column": 11 }, { "span": "except: ", "start_line": 148, "start_column": 4, "end_line": 148, "end_column": 11 } ]
[]
1
true
[ "[CLS]_", "Except", "_", "block_", "handles_", "'", "Base", "Except", "ion", "'_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "download_", "(_", "name_", ",_", "image_", ",_", "url_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "from_", "resources_", "._", "lib_", "._", "libraries_", "import_", "control_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "url_", "==_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "control_", "._", "info", "Dialog_", "(_", "control_", "._", "lang_", "(_", "305", "01_", ")_", "._", "encode_", "(_", "'", "utf", "-", "8", "'_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "try_", ":_", "headers_", "=_", "dict_", "(_", "urlparse_", "._", "parse", "\\u", "qs", "l_", "(_", "url_", "._", "rsplit_", "(_", "'|'_", ",_", "1_", ")_", "[_", "1_", "]_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "except_", ":_", "headers_", "=_", "dict_", "(_", "''_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "url_", "=_", "url_", "._", "split_", "(_", "'|'_", ")_", "[_", "0_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "content_", "=_", "re_", "._", "compile_", "(_", "'(", ".+?)", "\\\\", "s", "S", "(\\\\", "d", "*)", "E", "\\\\", "d", "*$'_", ")_", "._", "findall_", "(_", "name_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "trans", "name_", "=_", "name_", "._", "translate_", "(_", "None_", ",_", "'\\\\", "/", ":*", "?\"", "<>", "|'_", ")_", "._", "strip_", "(_", "'.'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "levels_", "=_", "[_", "'../../", "..", "/.", ".'_", ",_", "'../../", "..'_", ",_", "'../", "..'_", ",_", "'..'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "len_", "(_", "content_", ")_", "==_", "0_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "dest_", "=_", "control_", "._", "setting_", "(_", "'", "movie", "\\u", "download", "s", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "dest_", "=_", "control_", "._", "trans", "Path_", "(_", "dest_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "level_", "in_", "levels_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "try_", ":_", "control_", "._", "make", "File_", "(_", "os_", "._", "path_", "._", "abspath_", "(_", "os_", "._", "path_", "._", "join_", "(_", "dest_", ",_", "level_", ")_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "except_", ":_", "pass_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "control_", "._", "make", "File_", "(_", "dest_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "dest_", "=_", "os_", "._", "path_", "._", "join_", "(_", "dest_", ",_", "trans", "name_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "control_", "._", "make", "File_", "(_", "dest_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "dest_", "=_", "control_", "._", "setting_", "(_", "'", "tv", "\\u", "download", "s", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "dest_", "=_", "control_", "._", "trans", "Path_", "(_", "dest_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "level_", "in_", "levels_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "try_", ":_", "control_", "._", "make", "File_", "(_", "os_", "._", "path_", "._", "abspath_", "(_", "os_", "._", "path_", "._", "join_", "(_", "dest_", ",_", "level_", ")_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "except_", ":_", "pass_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "control_", "._", "make", "File_", "(_", "dest_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "trans", "tvshow", "title_", "=_", "content_", "[_", "0_", "]_", "[_", "0_", "]_", "._", "translate_", "(_", "None_", ",_", "'\\\\", "/", ":*", "?\"", "<>", "|'_", ")_", "._", "strip_", "(_", "'.'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "dest_", "=_", "os_", "._", "path_", "._", "join_", "(_", "dest_", ",_", "trans", "tvshow", "title_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "control_", "._", "make", "File_", "(_", "dest_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "dest_", "=_", "os_", "._", "path_", "._", "join_", "(_", "dest_", ",_", "'", "Season", " ", "%", "01", "d", "'_", "%_", "int_", "(_", "content_", "[_", "0_", "]_", "[_", "1_", "]_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "control_", "._", "make", "File_", "(_", "dest_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "ext_", "=_", "os_", "._", "path_", "._", "splitext_", "(_", "urlparse_", "._", "urlparse_", "(_", "url_", ")_", "._", "path_", ")_", "[_", "1_", "]_", "[_", "1_", ":_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "not_", "ext_", "in_", "[_", "'", "mp", "4", "'_", ",_", "'", "mkv", "'_", ",_", "'", "fl", "v", "'_", ",_", "'", "avi", "'_", ",_", "'", "mpg", "'_", "]_", ":_", "ext_", "=_", "'", "mp", "4", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "dest_", "=_", "os_", "._", "path_", "._", "join_", "(_", "dest_", ",_", "trans", "name_", "+_", "'.'_", "+_", "ext_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "sys", "headers_", "=_", "urllib_", "._", "quote", "\\u", "plus_", "(_", "json_", "._", "dumps_", "(_", "headers_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "sys", "url_", "=_", "urllib_", "._", "quote", "\\u", "plus_", "(_", "url_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "syst", "itle_", "=_", "urllib_", "._", "quote", "\\u", "plus_", "(_", "name_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "sysi", "mage_", "=_", "urllib_", "._", "quote", "\\u", "plus_", "(_", "image_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "sys", "dest_", "=_", "urllib_", "._", "quote", "\\u", "plus_", "(_", "dest_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "script_", "=_", "inspect_", "._", "getfile", "_", "(_", "inspect_", "._", "currentframe_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "cmd_", "=_", "'", "Run", "Script", "(%", "s", ",", " ", "%", "s", ",", " ", "%", "s", ",", " ", "%", "s", ",", " ", "%", "s", ",", " ", "%", "s", ")'_", "%_", "(_", "script_", ",_", "sys", "url_", ",_", "sys", "dest_", ",_", "syst", "itle_", ",_", "sysi", "mage_", ",_", "sys", "headers_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "xbmc_", "._", "executebuiltin_", "(_", "cmd_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "get", "Response_", "(_", "url_", ",_", "headers_", ",_", "size_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "size_", ">_", "0_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "size_", "=_", "int_", "(_", "size_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "headers_", "[_", "'", "Range", "'_", "]_", "=_", "'", "bytes", "=", "%", "d", "-'_", "%_", "size_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "req_", "=_", "urllib2_", "._", "Request_", "(_", "url_", ",_", "headers_", "=_", "headers_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "resp_", "=_", "urllib2_", "._", "urlopen_", "(_", "req_", ",_", "timeout_", "=_", "30_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "resp_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "do", "Download_", "(_", "url_", ",_", "dest_", ",_", "title_", ",_", "image_", ",_", "headers_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "headers_", "=_", "json_", "._", "loads_", "(_", "urllib_", "._", "unqu", "ote", "\\u", "plus_", "(_", "headers_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "url_", "=_", "urllib_", "._", "unqu", "ote", "\\u", "plus_", "(_", "url_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "title_", "=_", "urllib_", "._", "unqu", "ote", "\\u", "plus_", "(_", "title_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "image_", "=_", "urllib_", "._", "unqu", "ote", "\\u", "plus_", "(_", "image_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "dest_", "=_", "urllib_", "._", "unqu", "ote", "\\u", "plus_", "(_", "dest_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "file_", "=_", "dest_", "._", "rsplit_", "(_", "os_", "._", "sep_", ",_", "1_", ")_", "[_", "-_", "1_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "resp_", "=_", "get", "Response_", "(_", "url_", ",_", "headers_", ",_", "0_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "not_", "resp_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "xbmcgui_", "._", "Dialog_", "(_", ")_", "._", "ok_", "(_", "title_", ",_", "dest_", ",_", "'", "Down", "load", " ", "fail", "ed", "'_", ",_", "'", "No", " ", "response", " ", "from", " ", "server", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "try_", ":_", "content_", "=_", "int_", "(_", "resp_", "._", "headers_", "[_", "'", "Conten", "t", "-", "Length", "'_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "except_", ":_", "content_", "=_", "0_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "try_", ":_", "resum", "able_", "=_", "'", "bytes", "'_", "in_", "resp_", "._", "headers_", "[_", "'", "Accept", "-", "Range", "s", "'_", "]_", "._", "lower_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "except_", ":_", "resum", "able_", "=_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", "print", " ", "\"", "Down", "load", " ", "Head", "er", "\"_", "\\u\\u\\uNL\\u\\u\\u_", "#", "print", " ", "resp", ".", "headers_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "resum", "able_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "print_", "\"", "Down", "load", " ", "is", " ", "resum", "able", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "content_", "<_", "1_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "xbmcgui_", "._", "Dialog_", "(_", ")_", "._", "ok_", "(_", "title_", ",_", "file_", ",_", "'", "Un", "know", "n", " ", "files", "ize", "'_", ",_", "'", "Una", "ble", " ", "to", " ", "download", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "size_", "=_", "1024_", "*_", "1024_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "mb_", "=_", "content_", "/_", "(_", "1024_", "*_", "1024_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "content_", "<_", "size_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "size_", "=_", "content_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "total_", "=_", "0_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "notify_", "=_", "0_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "errors_", "=_", "0_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "count_", "=_", "0_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "resume_", "=_", "0_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "sleep_", "=_", "0_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "xbmcgui_", "._", "Dialog_", "(_", ")_", "._", "yesno", "_", "(_", "title_", "+_", "'", " ", "-", " ", "Confirm", " ", "Down", "load", "'_", ",_", "file_", ",_", "'", "Complete", " ", "file", " ", "is", " ", "%", "d", "MB", "'_", "%_", "mb_", ",_", "'", "Continu", "e", " ", "with", " ", "download", "?'_", ",_", "'", "Confirm", "'_", ",_", "'", "Cancel", "'_", ")_", "==_", "1_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "print_", "'", "Down", "load", " ", "File", " ", "Size", " ", ":", " ", "%", "d", "MB", " ", "%", "s", " ", "'_", "%_", "(_", "mb_", ",_", "dest_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", "f", " ", "=", " ", "open", "(", "dest", ",", " ", "mode", "='", "wb", "')", "_", "\\u\\u\\uNL\\u\\u\\u_", "f_", "=_", "xbmcvfs_", "._", "File_", "(_", "dest_", ",_", "'", "w", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "chunk_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "chunks_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "while_", "True_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "downloaded_", "=_", "total_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "c_", "in_", "chunks_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "downloaded_", "+=_", "len_", "(_", "c_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "percent_", "=_", "min_", "(_", "100_", "*_", "downloaded_", "/_", "content_", ",_", "100_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "percent_", ">=_", "notify_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "xbmc_", "._", "executebuiltin_", "(_", "\"", "XB", "MC", ".", "Notifi", "cation", "(%", "s", ",%", "s", ",%", "i", ",%", "s", ")\"_", "%_", "(_", "title_", "+_", "'", " ", "-", " ", "Down", "load", " ", "Progres", "s", " ", "-", " ", "'_", "+_", "str_", "(_", "percent_", ")_", "+_", "'%'_", ",_", "dest_", ",_", "10000_", ",_", "image_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "print_", "'", "Down", "load", " ", "percent", " ", ":", " ", "%", "s", " ", "%", "s", " ", "%", "d", "MB", " ", "download", "ed", " ", ":", " ", "%", "s", "MB", " ", "File", " ", "Size", " ", ":", " ", "%", "s", "MB", "'_", "%_", "(_", "str_", "(_", "percent_", ")_", "+_", "'%'_", ",_", "dest_", ",_", "mb_", ",_", "downloaded_", "/_", "1000000_", ",_", "content_", "/_", "1000000_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "notify_", "+=_", "10_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "chunk_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "error_", "=_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "chunk_", "=_", "resp_", "._", "read_", "(_", "size_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "not_", "chunk_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "percent_", "<_", "99_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "error_", "=_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "while_", "len_", "(_", "chunks_", ")_", ">_", "0_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "c_", "=_", "chunks_", "._", "pop_", "(_", "0_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "f_", "._", "write_", "(_", "c_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "del_", "c_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "f_", "._", "close_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "print_", "'%", "s", " ", "download", " ", "complete", "'_", "%_", "(_", "dest_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "done_", "(_", "title_", ",_", "dest_", ",_", "True_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "Exception_", ",_", "e_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "print_", "str_", "(_", "e_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "error_", "=_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "sleep_", "=_", "10_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "errno_", "=_", "0_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "hasattr_", "(_", "e_", ",_", "'", "errno", "'_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "errno_", "=_", "e_", "._", "errno_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "errno_", "==_", "1003", "5_", ":_", "#", " ", "'", "A", " ", "non", "-", "blockin", "g", " ", "socket", " ", "operati", "on", " ", "coul", "d", " ", "not", " ", "be", " ", "complete", "d", " ", "immediate", "ly", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "pass_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "errno_", "==_", "1005", "4_", ":_", "#'", "An", " ", "exist", "ing", " ", "connecti", "on", " ", "was", " ", "for", "cib", "ly", " ", "close", "d", " ", "by", " ", "the", " ", "remote", " ", "host", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "errors_", "=_", "10_", "#", "force", " ", "resume_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "sleep_", "=_", "30_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "errno_", "==_", "1100", "1_", ":_", "#", " ", "'", "getadd", "rin", "fo", " ", "fail", "ed", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "errors_", "=_", "10_", "#", "force", " ", "resume_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "sleep_", "=_", "30_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "chunk_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "errors_", "=_", "0_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "chunks_", "._", "append_", "(_", "chunk_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "len_", "(_", "chunks_", ")_", ">_", "5_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "c_", "=_", "chunks_", "._", "pop_", "(_", "0_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "f_", "._", "write_", "(_", "c_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "total_", "+=_", "len_", "(_", "c_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "del_", "c_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "error_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "errors_", "+=_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "count_", "+=_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "print_", "'%", "d", " ", "Error", "(", "s", ")", " ", "whi", "lst", " ", "download", "ing", " ", "%", "s", "'_", "%_", "(_", "count_", ",_", "dest_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "xbmc_", "._", "sleep_", "(_", "sleep_", "*_", "1000_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "(_", "resum", "able_", "and_", "errors_", ">_", "0_", ")_", "or_", "errors_", ">=_", "10_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "(_", "not_", "resum", "able_", "and_", "resume_", ">=_", "50_", ")_", "or_", "resume_", ">=_", "500_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", "Give", " ", "up", "!", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "print_", "'%", "s", " ", "download", " ", "cancel", "ed", " ", "-", " ", "too", " ", "many", " ", "error", " ", "whi", "lst", " ", "download", "ing", "'_", "%_", "(_", "dest_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "done_", "(_", "title_", ",_", "dest_", ",_", "False_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "resume_", "+=_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "errors_", "=_", "0_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "resum", "able_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "chunks_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", "create", " ", "new", " ", "response_", "\\u\\u\\uNL\\u\\u\\u_", "print_", "'", "Down", "load", " ", "resum", "ed", " ", "(%", "d", ")", " ", "%", "s", "'_", "%_", "(_", "resume_", ",_", "dest_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "resp_", "=_", "get", "Response_", "(_", "url_", ",_", "headers_", ",_", "total_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", "use", " ", "exist", "ing", " ", "response_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "pass_", "\\u\\u\\uNEWLINE\\u\\u\\u_" ]
[ 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,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, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 ]
Unused local variable
iancmcc/ouimeaux/ouimeaux/device/api/xsd/service.py
[ { "content": " def gds_validate_integer_list(self, input_data, node, input_name=''):\n values = input_data.split()\n for value in values:\n try:\n fvalue = float(value)\n except (TypeError, ValueError), exp:\n raise_parse_error(node, 'Requires sequence of integers')\n return input_data", "metadata": "root.GeneratedsSuper.gds_validate_integer_list", "header": "['class', 'GeneratedsSuper', '(', 'object', ')', ':', '___EOS___']", "index": 103 }, { "content": " def gds_validate_float_list(self, input_data, node, input_name=''):\n values = input_data.split()\n for value in values:\n try:\n fvalue = float(value)\n except (TypeError, ValueError), exp:\n raise_parse_error(node, 'Requires sequence of floats')\n return input_data", "metadata": "root.GeneratedsSuper.gds_validate_float_list", "header": "['class', 'GeneratedsSuper', '(', 'object', ')', ':', '___EOS___']", "index": 117 }, { "content": " def gds_validate_double_list(self, input_data, node, input_name=''):\n values = input_data.split()\n for value in values:\n try:\n fvalue = float(value)\n except (TypeError, ValueError), exp:\n raise_parse_error(node, 'Requires sequence of doubles')\n return input_data", "metadata": "root.GeneratedsSuper.gds_validate_double_list", "header": "['class', 'GeneratedsSuper', '(', 'object', ')', ':', '___EOS___']", "index": 131 }, { "content": " def exportChildren(self, outfile, level, namespace_='', name_='scpd', fromsubclass_=False, pretty_print=True):\n if pretty_print:\n eol_ = '\\n'\n else:\n eol_ = ''\n if self.specVersion is not None:\n self.specVersion.export(outfile, level, namespace_, name_='specVersion', pretty_print=pretty_print)\n if self.actionList is not None:\n self.actionList.export(outfile, level, namespace_, name_='actionList', pretty_print=pretty_print)\n if self.serviceStateTable is not None:\n self.serviceStateTable.export(outfile, level, namespace_, name_='serviceStateTable', pretty_print=pretty_print)", "metadata": "root.scpd.exportChildren", "header": "['class', 'scpd', '(', 'GeneratedsSuper', ')', ':', '___EOS___']", "index": 517 }, { "content": " def exportChildren(self, outfile, level, namespace_='', name_='ActionListType', fromsubclass_=False, pretty_print=True):\n if pretty_print:\n eol_ = '\\n'\n else:\n eol_ = ''\n for action_ in self.action:\n action_.export(outfile, level, namespace_, name_='action', pretty_print=pretty_print)", "metadata": "root.ActionListType.exportChildren", "header": "['class', 'ActionListType', '(', 'GeneratedsSuper', ')', ':', '___EOS___']", "index": 716 }, { "content": " def exportChildren(self, outfile, level, namespace_='', name_='ArgumentListType', fromsubclass_=False, pretty_print=True):\n if pretty_print:\n eol_ = '\\n'\n else:\n eol_ = ''\n for argument_ in self.argument:\n argument_.export(outfile, level, namespace_, name_='argument', pretty_print=pretty_print)", "metadata": "root.ArgumentListType.exportChildren", "header": "['class', 'ArgumentListType', '(', 'GeneratedsSuper', ')', ':', '___EOS___']", "index": 889 }, { "content": " def exportChildren(self, outfile, level, namespace_='', name_='ServiceStateTableType', fromsubclass_=False, pretty_print=True):\n if pretty_print:\n eol_ = '\\n'\n else:\n eol_ = ''\n for stateVariable_ in self.stateVariable:\n stateVariable_.export(outfile, level, namespace_, name_='stateVariable', pretty_print=pretty_print)", "metadata": "root.ServiceStateTableType.exportChildren", "header": "['class', 'ServiceStateTableType', '(', 'GeneratedsSuper', ')', ':', '___EOS___']", "index": 1090 }, { "content": "def parse(inFileName):\n doc = parsexml_(inFileName)\n rootNode = doc.getroot()\n rootTag, rootClass = get_root_tag(rootNode)\n if rootClass is None:\n rootTag = 'scpd'\n rootClass = scpd\n rootObj = rootClass.factory()\n rootObj.build(rootNode)\n # Enable Python to collect the space used by the DOM.\n doc = None\n return rootObj", "metadata": "root.parse", "header": "['module', '___EOS___']", "index": 1566 }, { "content": "def parseString(inString):\n from StringIO import StringIO\n doc = parsexml_(StringIO(inString))\n rootNode = doc.getroot()\n rootTag, rootClass = get_root_tag(rootNode)\n if rootClass is None:\n rootTag = 'scpd'\n rootClass = scpd\n rootObj = rootClass.factory()\n rootObj.build(rootNode)\n # Enable Python to collect the space used by the DOM.\n doc = None\n return rootObj", "metadata": "root.parseString", "header": "['module', '___EOS___']", "index": 1580 }, { "content": "def parseLiteral(inFileName):\n doc = parsexml_(inFileName)\n rootNode = doc.getroot()\n rootTag, rootClass = get_root_tag(rootNode)\n if rootClass is None:\n rootTag = 'scpd'\n rootClass = scpd\n rootObj = rootClass.factory()\n rootObj.build(rootNode)\n # Enable Python to collect the space used by the DOM.\n doc = None\n sys.stdout.write('#from service import *\\n\\n')\n sys.stdout.write('from datetime import datetime as datetime_\\n\\n')\n sys.stdout.write('import service as model_\\n\\n')\n sys.stdout.write('rootObj = model_.rootTag(\\n')\n rootObj.exportLiteral(sys.stdout, 0, name_=rootTag)\n sys.stdout.write(')\\n')\n return rootObj", "metadata": "root.parseLiteral", "header": "['module', '___EOS___']", "index": 1595 } ]
[ { "span": "fvalue ", "start_line": 107, "start_column": 20, "end_line": 107, "end_column": 26 }, { "span": "fvalue ", "start_line": 121, "start_column": 20, "end_line": 121, "end_column": 26 }, { "span": "fvalue ", "start_line": 135, "start_column": 20, "end_line": 135, "end_column": 26 }, { "span": "eol_ ", "start_line": 519, "start_column": 12, "end_line": 519, "end_column": 16 }, { "span": "eol_ ", "start_line": 521, "start_column": 12, "end_line": 521, "end_column": 16 }, { "span": "eol_ ", "start_line": 718, "start_column": 12, "end_line": 718, "end_column": 16 }, { "span": "eol_ ", "start_line": 720, "start_column": 12, "end_line": 720, "end_column": 16 }, { "span": "eol_ ", "start_line": 891, "start_column": 12, "end_line": 891, "end_column": 16 }, { "span": "eol_ ", "start_line": 893, "start_column": 12, "end_line": 893, "end_column": 16 }, { "span": "eol_ ", "start_line": 1092, "start_column": 12, "end_line": 1092, "end_column": 16 }, { "span": "eol_ ", "start_line": 1094, "start_column": 12, "end_line": 1094, "end_column": 16 }, { "span": "rootTag ", "start_line": 1571, "start_column": 8, "end_line": 1571, "end_column": 15 }, { "span": "doc ", "start_line": 1576, "start_column": 4, "end_line": 1576, "end_column": 7 }, { "span": "rootTag ", "start_line": 1586, "start_column": 8, "end_line": 1586, "end_column": 15 }, { "span": "doc ", "start_line": 1591, "start_column": 4, "end_line": 1591, "end_column": 7 }, { "span": "doc ", "start_line": 1605, "start_column": 4, "end_line": 1605, "end_column": 7 } ]
[]
1
true
[ "[CLS]_", "Un", "used_", "local_", "variable_", "[SEP]_", "class_", "Generate", "ds", "Super", "_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "gd", "s", "\\u", "validat", "e\\u", "integ", "er", "\\u", "list_", "(_", "self_", ",_", "input", "\\u", "data_", ",_", "node_", ",_", "input", "\\u", "name_", "=_", "''_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "values_", "=_", "input", "\\u", "data_", "._", "split_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "value_", "in_", "values_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "fval", "ue_", "=_", "float_", "(_", "value_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "(_", "Type", "Error_", ",_", "Value", "Error_", ")_", ",_", "exp_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "raise", "\\u", "parse", "\\u", "error_", "(_", "node_", ",_", "'", "Requ", "ires", " ", "sequence", " ", "of", " ", "integ", "ers", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "input", "\\u", "data_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Generate", "ds", "Super", "_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "gd", "s", "\\u", "validat", "e\\u", "float", "\\u", "list_", "(_", "self_", ",_", "input", "\\u", "data_", ",_", "node_", ",_", "input", "\\u", "name_", "=_", "''_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "values_", "=_", "input", "\\u", "data_", "._", "split_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "value_", "in_", "values_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "fval", "ue_", "=_", "float_", "(_", "value_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "(_", "Type", "Error_", ",_", "Value", "Error_", ")_", ",_", "exp_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "raise", "\\u", "parse", "\\u", "error_", "(_", "node_", ",_", "'", "Requ", "ires", " ", "sequence", " ", "of", " ", "float", "s", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "input", "\\u", "data_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Generate", "ds", "Super", "_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "gd", "s", "\\u", "validat", "e\\u", "double", "\\u", "list_", "(_", "self_", ",_", "input", "\\u", "data_", ",_", "node_", ",_", "input", "\\u", "name_", "=_", "''_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "values_", "=_", "input", "\\u", "data_", "._", "split_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "value_", "in_", "values_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "fval", "ue_", "=_", "float_", "(_", "value_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "(_", "Type", "Error_", ",_", "Value", "Error_", ")_", ",_", "exp_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "raise", "\\u", "parse", "\\u", "error_", "(_", "node_", ",_", "'", "Requ", "ires", " ", "sequence", " ", "of", " ", "double", "s", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "input", "\\u", "data_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "scp", "d_", "(_", "Generate", "ds", "Super", "_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "export", "Children_", "(_", "self_", ",_", "outfile_", ",_", "level_", ",_", "namespace\\u_", "=_", "''_", ",_", "name\\u_", "=_", "'", "scp", "d", "'_", ",_", "froms", "ubc", "lass\\u", "_", "=_", "False_", ",_", "pretty", "\\u", "print_", "=_", "True_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "pretty", "\\u", "print_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "eol\\u_", "=_", "'\\\\", "n", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "eol\\u_", "=_", "''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "self_", "._", "spec", "Version_", "is_", "not_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "spec", "Version_", "._", "export_", "(_", "outfile_", ",_", "level_", ",_", "namespace\\u_", ",_", "name\\u_", "=_", "'", "spec", "Version", "'_", ",_", "pretty", "\\u", "print_", "=_", "pretty", "\\u", "print_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "self_", "._", "action", "List_", "is_", "not_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "action", "List_", "._", "export_", "(_", "outfile_", ",_", "level_", ",_", "namespace\\u_", ",_", "name\\u_", "=_", "'", "action", "List", "'_", ",_", "pretty", "\\u", "print_", "=_", "pretty", "\\u", "print_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "self_", "._", "service", "State", "Table_", "is_", "not_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "service", "State", "Table_", "._", "export_", "(_", "outfile_", ",_", "level_", ",_", "namespace\\u_", ",_", "name\\u_", "=_", "'", "service", "State", "Table", "'_", ",_", "pretty", "\\u", "print_", "=_", "pretty", "\\u", "print_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Action", "List", "Type_", "(_", "Generate", "ds", "Super", "_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "export", "Children_", "(_", "self_", ",_", "outfile_", ",_", "level_", ",_", "namespace\\u_", "=_", "''_", ",_", "name\\u_", "=_", "'", "Action", "List", "Type", "'_", ",_", "froms", "ubc", "lass\\u", "_", "=_", "False_", ",_", "pretty", "\\u", "print_", "=_", "True_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "pretty", "\\u", "print_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "eol\\u_", "=_", "'\\\\", "n", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "eol\\u_", "=_", "''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "for_", "action", "\\u_", "in_", "self_", "._", "action_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "action", "\\u_", "._", "export_", "(_", "outfile_", ",_", "level_", ",_", "namespace\\u_", ",_", "name\\u_", "=_", "'", "action", "'_", ",_", "pretty", "\\u", "print_", "=_", "pretty", "\\u", "print_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Arg", "ument", "List", "Type_", "(_", "Generate", "ds", "Super", "_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "export", "Children_", "(_", "self_", ",_", "outfile_", ",_", "level_", ",_", "namespace\\u_", "=_", "''_", ",_", "name\\u_", "=_", "'", "Arg", "ument", "List", "Type", "'_", ",_", "froms", "ubc", "lass\\u", "_", "=_", "False_", ",_", "pretty", "\\u", "print_", "=_", "True_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "pretty", "\\u", "print_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "eol\\u_", "=_", "'\\\\", "n", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "eol\\u_", "=_", "''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "for_", "argu", "ment", "\\u_", "in_", "self_", "._", "argument_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "argu", "ment", "\\u_", "._", "export_", "(_", "outfile_", ",_", "level_", ",_", "namespace\\u_", ",_", "name\\u_", "=_", "'", "argu", "ment", "'_", ",_", "pretty", "\\u", "print_", "=_", "pretty", "\\u", "print_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Service", "State", "Table", "Type_", "(_", "Generate", "ds", "Super", "_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "export", "Children_", "(_", "self_", ",_", "outfile_", ",_", "level_", ",_", "namespace\\u_", "=_", "''_", ",_", "name\\u_", "=_", "'", "Service", "State", "Table", "Type", "'_", ",_", "froms", "ubc", "lass\\u", "_", "=_", "False_", ",_", "pretty", "\\u", "print_", "=_", "True_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "pretty", "\\u", "print_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "eol\\u_", "=_", "'\\\\", "n", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "eol\\u_", "=_", "''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "for_", "state", "Varia", "ble", "\\u_", "in_", "self_", "._", "state", "Variable_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "state", "Varia", "ble", "\\u_", "._", "export_", "(_", "outfile_", ",_", "level_", ",_", "namespace\\u_", ",_", "name\\u_", "=_", "'", "state", "Varia", "ble", "'_", ",_", "pretty", "\\u", "print_", "=_", "pretty", "\\u", "print_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "parse_", "(_", "in", "File", "Name_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "doc_", "=_", "parse", "xml", "\\u_", "(_", "in", "File", "Name_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "root", "Node_", "=_", "doc_", "._", "getroot_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "root", "Tag_", ",_", "root", "Class_", "=_", "get", "\\u", "root", "\\u", "tag_", "(_", "root", "Node_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "root", "Class_", "is_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "root", "Tag_", "=_", "'", "scp", "d", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "root", "Class_", "=_", "scp", "d_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "root", "Obj_", "=_", "root", "Class_", "._", "factory_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "root", "Obj_", "._", "build_", "(_", "root", "Node_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Enable", " ", "Pyth", "on", " ", "to", " ", "collect", " ", "the", " ", "space", " ", "used", " ", "by", " ", "the", " ", "DOM", "._", "\\u\\u\\uNL\\u\\u\\u_", "doc_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "root", "Obj_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "parse", "String_", "(_", "in", "String_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "from_", "String", "IO_", "import_", "String", "IO_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "doc_", "=_", "parse", "xml", "\\u_", "(_", "String", "IO_", "(_", "in", "String_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "root", "Node_", "=_", "doc_", "._", "getroot_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "root", "Tag_", ",_", "root", "Class_", "=_", "get", "\\u", "root", "\\u", "tag_", "(_", "root", "Node_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "root", "Class_", "is_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "root", "Tag_", "=_", "'", "scp", "d", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "root", "Class_", "=_", "scp", "d_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "root", "Obj_", "=_", "root", "Class_", "._", "factory_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "root", "Obj_", "._", "build_", "(_", "root", "Node_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Enable", " ", "Pyth", "on", " ", "to", " ", "collect", " ", "the", " ", "space", " ", "used", " ", "by", " ", "the", " ", "DOM", "._", "\\u\\u\\uNL\\u\\u\\u_", "doc_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "root", "Obj_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "parse", "Literal_", "(_", "in", "File", "Name_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "doc_", "=_", "parse", "xml", "\\u_", "(_", "in", "File", "Name_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "root", "Node_", "=_", "doc_", "._", "getroot_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "root", "Tag_", ",_", "root", "Class_", "=_", "get", "\\u", "root", "\\u", "tag_", "(_", "root", "Node_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "root", "Class_", "is_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "root", "Tag_", "=_", "'", "scp", "d", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "root", "Class_", "=_", "scp", "d_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "root", "Obj_", "=_", "root", "Class_", "._", "factory_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "root", "Obj_", "._", "build_", "(_", "root", "Node_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Enable", " ", "Pyth", "on", " ", "to", " ", "collect", " ", "the", " ", "space", " ", "used", " ", "by", " ", "the", " ", "DOM", "._", "\\u\\u\\uNL\\u\\u\\u_", "doc_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "sys_", "._", "stdout_", "._", "write_", "(_", "'#", "from", " ", "service", " ", "import", " ", "*\\\\", "n", "\\\\", "n", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "sys_", "._", "stdout_", "._", "write_", "(_", "'", "from", " ", "datetime", " ", "import", " ", "datetime", " ", "as", " ", "datetime", "\\u\\\\", "n", "\\\\", "n", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "sys_", "._", "stdout_", "._", "write_", "(_", "'", "import", " ", "service", " ", "as", " ", "model", "\\u\\\\", "n", "\\\\", "n", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "sys_", "._", "stdout_", "._", "write_", "(_", "'", "root", "Obj", " ", "=", " ", "model", "\\u.", "root", "Ta", "g", "(\\\\", "n", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "root", "Obj_", "._", "export", "Literal_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 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 ]
Implicit string concatenation in a list
ubernostrum/django-registration/registration/validators.py
[ { "content": "\"\"\"\nError messages, data and custom validation code used in\ndjango-registration's various user-registration form classes.\n\n\"\"\"\n\nfrom django.core.exceptions import ValidationError\nfrom django.utils.translation import ugettext_lazy as _\n\n\nDUPLICATE_EMAIL = _(u\"This email address is already in use. \"\n u\"Please supply a different email address.\")\nFREE_EMAIL = _(u\"Registration using free email addresses is prohibited. \"\n u\"Please supply a different email address.\")\nRESERVED_NAME = _(u\"This value is reserved and cannot be registered.\")\nTOS_REQUIRED = _(u\"You must agree to the terms to register\")\n\n\n# Below we construct a large but non-exhaustive list of names which\n# users probably should not be able to register with, due to various\n# risks:\n#\n# * For a site which creates email addresses from username, important\n# common addresses must be reserved.\n#\n# * For a site which creates subdomains from usernames, important\n# common hostnames/domain names must be reserved.\n#\n# * For a site which uses the username to generate a URL to the user's\n# profile, common well-known filenames must be reserved.\n#\n# etc., etc.\n#\n# Credit for basic idea and most of the list to Geoffrey Thomas's blog\n# post about names to reserve:\n# https://ldpreload.com/blog/names-to-reserve\nSPECIAL_HOSTNAMES = [\n # Hostnames with special/reserved meaning.\n 'autoconfig', # Thunderbird autoconfig\n 'autodiscover', # MS Outlook/Exchange autoconfig\n 'broadcasthost', # Network broadcast hostname\n 'isatap', # IPv6 tunnel autodiscovery\n 'localdomain', # Loopback\n 'localhost', # Loopback\n 'wpad', # Proxy autodiscovery\n]\n\n\nPROTOCOL_HOSTNAMES = [\n # Common protocol hostnames.\n 'ftp',\n 'imap',\n 'mail',\n 'news',\n 'pop',\n 'pop3',\n 'smtp',\n 'usenet',\n 'uucp',\n 'webmail',\n 'www',\n]\n\n\nCA_ADDRESSES = [\n # Email addresses known used by certificate authorities during\n # verification.\n 'admin',\n 'administrator',\n 'hostmaster',\n 'info',\n 'is',\n 'it',\n 'mis',\n 'postmaster',\n 'root',\n 'ssladmin',\n 'ssladministrator',\n 'sslwebmaster',\n 'sysadmin',\n 'webmaster',\n]\n\n\nRFC_2142 = [\n # RFC-2142-defined names not already covered.\n 'abuse',\n 'marketing',\n 'noc',\n 'sales',\n 'security',\n 'support',\n]\n\n\nNOREPLY_ADDRESSES = [\n # Common no-reply email addresses.\n 'mailer-daemon',\n 'nobody',\n 'noreply',\n 'no-reply',\n]\n\n\nSENSITIVE_FILENAMES = [\n # Sensitive filenames.\n 'clientaccesspolicy.xml', # Silverlight cross-domain policy file.\n 'crossdomain.xml', # Flash cross-domain policy file.\n 'favicon.ico',\n 'humans.txt',\n 'robots.txt',\n '.htaccess',\n '.htpasswd',\n]\n\n\nOTHER_SENSITIVE_NAMES = [\n # Other names which could be problems depending on URL/subdomain\n # structure.\n 'account',\n 'accounts',\n 'blog',\n 'buy',\n 'clients',\n 'contact',\n 'contactus',\n 'contact-us',\n 'copyright',\n 'dashboard',\n 'doc',\n 'docs',\n 'download',\n 'downloads',\n 'enquiry',\n 'faq',\n 'help',\n 'inquiry',\n 'license',\n 'login',\n 'logout',\n 'payments',\n 'plans',\n 'portfolio',\n 'preferences',\n 'pricing',\n 'privacy',\n 'profile',\n 'register'\n 'secure',\n 'signup',\n 'ssl',\n 'status',\n 'subscribe',\n 'terms',\n 'tos',\n 'user',\n 'users'\n 'weblog',\n 'work',\n]\n\n\nDEFAULT_RESERVED_NAMES = (SPECIAL_HOSTNAMES + PROTOCOL_HOSTNAMES +\n CA_ADDRESSES + RFC_2142 + NOREPLY_ADDRESSES +\n SENSITIVE_FILENAMES + OTHER_SENSITIVE_NAMES)\n\n\n", "metadata": "root", "header": "['module', '___EOS___']", "index": 0 } ]
[ { "span": "'register'\n 'secure',", "start_line": 147, "start_column": 4, "end_line": 148, "end_column": 12 }, { "span": "'users'\n 'weblog',", "start_line": 156, "start_column": 4, "end_line": 157, "end_column": 12 } ]
[]
1
true
[ "[CLS]_", "Implicit", "_", "string_", "concate", "nation_", "in_", "a_", "list_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\"\"\"", "\\", "10", ";", "Error", " ", "message", "s", ",", " ", "data", " ", "and", " ", "custom", " ", "validation", " ", "code", " ", "used", " ", "in", "\\", "10", ";", "django", "-", "registration", "'", "s", " ", "vari", "ous", " ", "user", "-", "registration", " ", "form", " ", "classe", "s", ".", "\\", "10", ";", "\\", "10", ";\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "from_", "django_", "._", "core_", "._", "exceptions_", "import_", "Validat", "ion", "Error_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "django_", "._", "utils_", "._", "translation_", "import_", "uge", "ttext", "\\u", "lazy_", "as_", "\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "DUPL", "ICAT", "E", "\\u", "EMAIL_", "=_", "\\u_", "(_", "u", "\"", "Thi", "s", " ", "email", " ", "address", " ", "is", " ", "alr", "ead", "y", " ", "in", " ", "use", ".", " ", "\"_", "\\u\\u\\uNL\\u\\u\\u_", "u", "\"", "Ple", "ase", " ", "supply", " ", "a", " ", "different", " ", "email", " ", "address", ".\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "FREE", "\\u", "EMAIL_", "=_", "\\u_", "(_", "u", "\"", "Registration", " ", "usi", "ng", " ", "free", " ", "email", " ", "addresse", "s", " ", "is", " ", "pro", "hibit", "ed", ".", " ", "\"_", "\\u\\u\\uNL\\u\\u\\u_", "u", "\"", "Ple", "ase", " ", "supply", " ", "a", " ", "different", " ", "email", " ", "address", ".\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "RESERVED", "\\u", "NAME_", "=_", "\\u_", "(_", "u", "\"", "Thi", "s", " ", "value", " ", "is", " ", "reserve", "d", " ", "and", " ", "cann", "ot", " ", "be", " ", "register", "ed", ".\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "TOS", "\\u", "REQUIRED_", "=_", "\\u_", "(_", "u", "\"", "You", " ", "must", " ", "agree", " ", "to", " ", "the", " ", "term", "s", " ", "to", " ", "register", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Below", " ", "we", " ", "construct", " ", "a", " ", "large", " ", "but", " ", "non", "-", "exhaust", "ive", " ", "list", " ", "of", " ", "names", " ", "which_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "users", " ", "probab", "ly", " ", "shou", "ld", " ", "not", " ", "be", " ", "able", " ", "to", " ", "register", " ", "with", ",", " ", "due", " ", "to", " ", "vari", "ous_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "risk", "s", ":_", "\\u\\u\\uNL\\u\\u\\u_", "#", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "*", " ", "For", " ", "a", " ", "site", " ", "whi", "ch", " ", "create", "s", " ", "email", " ", "addresse", "s", " ", "from", " ", "user", "name", ",", " ", "importa", "nt_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", " ", " ", "common", " ", "addresse", "s", " ", "must", " ", "be", " ", "reserve", "d", "._", "\\u\\u\\uNL\\u\\u\\u_", "#", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "*", " ", "For", " ", "a", " ", "site", " ", "whi", "ch", " ", "create", "s", " ", "subdomain", "s", " ", "from", " ", "usernames", ",", " ", "importa", "nt_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", " ", " ", "common", " ", "hostnames", "/", "domain", " ", "names", " ", "must", " ", "be", " ", "reserve", "d", "._", "\\u\\u\\uNL\\u\\u\\u_", "#", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "*", " ", "For", " ", "a", " ", "site", " ", "whi", "ch", " ", "use", "s", " ", "the", " ", "user", "name", " ", "to", " ", "generat", "e", " ", "a", " ", "URL", " ", "to", " ", "the", " ", "user", "'", "s_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", " ", " ", "profile", ",", " ", "common", " ", "well", "-", "know", "n", " ", "filename", "s", " ", "must", " ", "be", " ", "reserve", "d", "._", "\\u\\u\\uNL\\u\\u\\u_", "#", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "etc", ".,", " ", "etc", "._", "\\u\\u\\uNL\\u\\u\\u_", "#", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Credit", " ", "for", " ", "basic", " ", "idea", " ", "and", " ", "most", " ", "of", " ", "the", " ", "list", " ", "to", " ", "Geo", "ff", "rey", " ", "Tho", "mas", "'", "s", " ", "blog_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "post", " ", "abo", "ut", " ", "names", " ", "to", " ", "reserve", ":_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "https", "://", "ldp", "relo", "ad", ".", "com", "/", "blog", "/", "names", "-", "to", "-", "reserve", "_", "\\u\\u\\uNL\\u\\u\\u_", "SPECIAL", "\\u", "HOSTNAME", "S_", "=_", "[_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Host", "names", " ", "with", " ", "special", "/", "reserve", "d", " ", "meaning", "._", "\\u\\u\\uNL\\u\\u\\u_", "'", "autocon", "fig", "'_", ",_", "#", " ", "Thu", "nder", "bird", " ", "autocon", "fig_", "\\u\\u\\uNL\\u\\u\\u_", "'", "autodiscover", "'_", ",_", "#", " ", "MS", " ", "Outl", "ook", "/", "Exc", "hange", " ", "autocon", "fig_", "\\u\\u\\uNL\\u\\u\\u_", "'", "broadcast", "host", "'_", ",_", "#", " ", "Network", " ", "broadcast", " ", "hostname_", "\\u\\u\\uNL\\u\\u\\u_", "'", "isat", "ap", "'_", ",_", "#", " ", "IP", "v6", " ", "tunnel", " ", "autodiscover", "y_", "\\u\\u\\uNL\\u\\u\\u_", "'", "locald", "omain", "'_", ",_", "#", " ", "Loop", "back_", "\\u\\u\\uNL\\u\\u\\u_", "'", "local", "host", "'_", ",_", "#", " ", "Loop", "back_", "\\u\\u\\uNL\\u\\u\\u_", "'", "wpa", "d", "'_", ",_", "#", " ", "Pro", "xy", " ", "autodiscover", "y_", "\\u\\u\\uNL\\u\\u\\u_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "PROTOCOL", "\\u", "HOSTNAME", "S_", "=_", "[_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Common", " ", "protoc", "ol", " ", "hostnames", "._", "\\u\\u\\uNL\\u\\u\\u_", "'", "ftp", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "imap", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "mail", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "news", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "pop", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "pop", "3", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "smt", "p", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "use", "net", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "uu", "cp", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "webm", "ail", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "www", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "CA", "\\u", "ADDR", "ESS", "ES_", "=_", "[_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Ema", "il", " ", "addresse", "s", " ", "know", "n", " ", "used", " ", "by", " ", "certifica", "te", " ", "authorities", " ", "dur", "ing_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "verification", "._", "\\u\\u\\uNL\\u\\u\\u_", "'", "admin", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "administrat", "or", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "host", "master", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "info", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "is", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "it", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "mis", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "post", "master", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "root", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "ssl", "admin", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "ssl", "administrat", "or", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "ssl", "webm", "aster", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "sys", "admin", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "webm", "aster", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "RF", "C", "\\u", "214", "2_", "=_", "[_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "RF", "C", "-", "214", "2", "-", "defin", "ed", " ", "names", " ", "not", " ", "alr", "ead", "y", " ", "covered", "._", "\\u\\u\\uNL\\u\\u\\u_", "'", "abu", "se", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "market", "ing", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "noc", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "sales", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "security", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "support", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "NOR", "EP", "LY", "\\u", "ADDR", "ESS", "ES_", "=_", "[_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Common", " ", "no", "-", "repl", "y", " ", "email", " ", "addresse", "s", "._", "\\u\\u\\uNL\\u\\u\\u_", "'", "mailer", "-", "daemon", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "nob", "ody", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "nore", "ply", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "no", "-", "repl", "y", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "SENS", "ITIVE", "\\u", "FILE", "NAMES_", "=_", "[_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Sensitiv", "e", " ", "filename", "s", "._", "\\u\\u\\uNL\\u\\u\\u_", "'", "client", "access", "policy", ".", "xml", "'_", ",_", "#", " ", "Sil", "ver", "light", " ", "cross", "-", "domain", " ", "policy", " ", "file", "._", "\\u\\u\\uNL\\u\\u\\u_", "'", "cross", "domain", ".", "xml", "'_", ",_", "#", " ", "Fla", "sh", " ", "cross", "-", "domain", " ", "policy", " ", "file", "._", "\\u\\u\\uNL\\u\\u\\u_", "'", "fav", "icon", ".", "ico", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "human", "s", ".", "txt", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "robots", ".", "txt", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'.", "hta", "ccess", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'.", "ht", "passw", "d", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "OTHER", "\\u", "SENS", "ITIVE", "\\u", "NAMES_", "=_", "[_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Ot", "her", " ", "names", " ", "whi", "ch", " ", "coul", "d", " ", "be", " ", "problem", "s", " ", "depend", "ing", " ", "on", " ", "URL", "/", "subdomain_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "structure", "._", "\\u\\u\\uNL\\u\\u\\u_", "'", "account", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "account", "s", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "blog", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "buy", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "clients", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "contact", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "contact", "us", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "contact", "-", "us", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "copyr", "ight", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "dash", "board", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "doc", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "docs", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "download", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "download", "s", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "en", "quir", "y", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "faq", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "help", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "inqu", "ir", "y", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "license", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "login", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "logo", "ut", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "payments", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "plans", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "portfolio", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "preference", "s", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "pricing", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "privacy", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "profile", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "register", "'_", "\\u\\u\\uNL\\u\\u\\u_", "'", "secure", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "signup", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "ssl", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "status", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "subscribe", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "term", "s", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "tos", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "user", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "users", "'_", "\\u\\u\\uNL\\u\\u\\u_", "'", "web", "log", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "work", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "DEF", "AUL", "T", "\\u", "RESERVED", "\\u", "NAMES_", "=_", "(_", "SPECIAL", "\\u", "HOSTNAME", "S_", "+_", "PROTOCOL", "\\u", "HOSTNAME", "S_", "+_", "\\u\\u\\uNL\\u\\u\\u_", "CA", "\\u", "ADDR", "ESS", "ES_", "+_", "RF", "C", "\\u", "214", "2_", "+_", "NOR", "EP", "LY", "\\u", "ADDR", "ESS", "ES_", "+_", "\\u\\u\\uNL\\u\\u\\u_", "SENS", "ITIVE", "\\u", "FILE", "NAMES_", "+_", "OTHER", "\\u", "SENS", "ITIVE", "\\u", "NAMES_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_" ]
[ 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 ]
Except block handles 'BaseException'
severb/flowy/tests/test_swf_integration.py
[ { "content": "from __future__ import print_function\n\nimport os\nimport sys\nimport multiprocessing\nimport time\nimport json\nimport uuid\nimport random\nimport functools\nimport gzip\n\nimport vcr\nimport vcr.cassette\nimport vcr.errors\nimport vcr.serialize\nimport vcr.request\nfrom boto.swf.layer1 import Layer1\nfrom flowy import restart\nfrom flowy import wait\nfrom flowy import TaskError\nfrom flowy import SWFActivityConfig\nfrom flowy import SWFActivityWorker\nfrom flowy import SWFWorkflowConfig\nfrom flowy import SWFWorkflowStarter\nfrom flowy import SWFWorkflowWorker\n\nVERSION = 2\nHERE = os.path.dirname(os.path.realpath(__file__))\nA_CASSETTE = os.path.join(HERE, 'cassettes/a.yml.gz')\nW_CASSETTE = os.path.join(HERE, 'cassettes/w.yml.gz')\nDOMAIN = 'IntegrationTest'\nTASKLIST = 'tl'\nIDENTITY = 'test'\n\nRECORDING = False\n\nexit_event = multiprocessing.Event()\nwf_finished_event = multiprocessing.Event()\n\n\n# Patch vcr to use gzip files\n\n\n\n\n\nvcr.cassette.load_cassette = load_cassette\nvcr.cassette.save_cassette = save_cassette\n\n# Patch requests_match in cassette for speed-up\n\n\nvcr.cassette.requests_match = requests_match\n\n# Patch urpalse to speed-up for python3\ntry:\n from functools import lru_cache\n from urllib.parse import urlparse\n vcr.request.urlparse = lru_cache(maxsize=None)(urlparse)\nexcept ImportError:\n pass\n\n\n# patch uuid4 for consistent keys\n\nuuid.uuid4 = functools.partial(next, fake_uuid4())\n\n\n\n\n\n\n\n\n\n\na_conf = SWFActivityConfig(default_task_list=TASKLIST,\n default_schedule_to_start=30,\n default_schedule_to_close=60,\n default_start_to_close=15,\n default_heartbeat=10)\n\n\n\n\nempty_conf = SWFWorkflowConfig(default_task_list=TASKLIST,\n default_decision_duration=10,\n default_workflow_duration=20,\n default_child_policy='TERMINATE', )\nempty_conf.conf_activity('activity', VERSION, 'tactivity')\n\n\n\n\nconf_use_activities = SWFWorkflowConfig(default_task_list=TASKLIST,\n default_decision_duration=10,\n default_workflow_duration=60,\n default_child_policy='TERMINATE')\nconf_use_activities.conf_activity('task', VERSION, 'tactivity')\nconf_use_activities.conf_activity('short_task', VERSION, 'tactivity',\n schedule_to_close=1,\n retry=(0, ))\nconf_use_activities.conf_activity('delayed_task', VERSION, 'tactivity',\n retry=(3, ))\nconf_use_activities.conf_activity('non_existing_task', 1, 'xxx')\n\nconf_use_workflow = SWFWorkflowConfig(default_task_list=TASKLIST,\n default_decision_duration=10,\n default_workflow_duration=60,\n default_child_policy='TERMINATE')\nconf_use_workflow.conf_workflow('task', VERSION, 'TWorkflow')\nconf_use_workflow.conf_workflow('short_task', VERSION, 'TWorkflow',\n workflow_duration=1,\n retry=(0, ))\nconf_use_workflow.conf_workflow('delayed_task', VERSION, 'TWorkflow',\n retry=(3, ))\nconf_use_workflow.conf_workflow('non_existing_task', 1, 'xxx')\n\n\n\n\n\n\n\n\nwworker = TestSWFWorkflowWorker()\nwworker.scan(package=sys.modules[__name__])\naworker = TestSWFActivityWorker()\naworker.scan(package=sys.modules[__name__])\n\n\nbody_cache = {}\n\n\n\n\nvcr.default_vcr.register_matcher('dict_body', body_as_dict)\nvcr.default_vcr.register_matcher('esc_headers', body_as_dict)\n\ncassette_args = {\n 'match_on': ['dict_body', 'esc_headers', 'query', 'method', 'uri', 'host',\n 'port', 'path'],\n 'filter_headers': ['authorization', 'x-amz-date', 'content-length',\n 'user-agent']\n}\n\n\n\n\n\n\n\n\n\n\nif __name__ == '__main__':\n RECORDING = True\n try:\n os.remove(A_CASSETTE)\n except:\n pass\n try:\n os.remove(W_CASSETTE)\n except:\n pass\n\n a_worker = multiprocessing.Process(target=start_activity_worker)\n w_worker = multiprocessing.Process(target=start_workflow_worker)\n\n a_worker.start()\n w_worker.start()\n\n time.sleep(5) # Wait for registration\n\n wfs = ['TestWorkflow', 'TestWorkflowW', 'RestartWorkflow']\n for wf in wfs:\n print('Starting', wf)\n SWFWorkflowStarter(DOMAIN, wf, VERSION)()\n wf_finished_event.wait()\n wf_finished_event.clear()\n\n # Must be the last one\n print('Prepare to exit')\n SWFWorkflowStarter(DOMAIN, 'ExitWorkflow', VERSION)()\n\n a_worker.join()\n w_worker.join()\n", "metadata": "root", "header": "['module', '___EOS___']", "index": 0 } ]
[ { "span": "except:", "start_line": 312, "start_column": 4, "end_line": 312, "end_column": 11 }, { "span": "except:", "start_line": 316, "start_column": 4, "end_line": 316, "end_column": 11 } ]
[]
1
true
[ "[CLS]_", "Except", "_", "block_", "handles_", "'", "Base", "Except", "ion", "'_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "from_", "\\u\\u", "future\\u\\u_", "import_", "print", "\\u", "function_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "import_", "os_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "sys_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "multiprocessing_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "time_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "json_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "uuid_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "random_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "functools_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "gzip_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "import_", "vcr", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "vcr", "_", "._", "cassette", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "vcr", "_", "._", "errors_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "vcr", "_", "._", "serialize_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "vcr", "_", "._", "request_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "boto_", "._", "swf", "_", "._", "layer", "1_", "import_", "Layer", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "flow", "y_", "import_", "restart_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "flow", "y_", "import_", "wait_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "flow", "y_", "import_", "Task", "Error_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "flow", "y_", "import_", "SW", "FA", "cti", "vity", "Config_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "flow", "y_", "import_", "SW", "FA", "cti", "vity", "Worker_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "flow", "y_", "import_", "SW", "FW", "ork", "flow", "Config_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "flow", "y_", "import_", "SW", "FW", "ork", "flow", "Start", "er_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "flow", "y_", "import_", "SW", "FW", "ork", "flow", "Worker_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "VERSION_", "=_", "2_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "HER", "E_", "=_", "os_", "._", "path_", "._", "dirname_", "(_", "os_", "._", "path_", "._", "realpath_", "(_", "\\u\\u", "file\\u\\u_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "A", "\\u", "CAS", "SET", "TE_", "=_", "os_", "._", "path_", "._", "join_", "(_", "HER", "E_", ",_", "'", "cassette", "s", "/", "a", ".", "yml", ".", "gz", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "W", "\\u", "CAS", "SET", "TE_", "=_", "os_", "._", "path_", "._", "join_", "(_", "HER", "E_", ",_", "'", "cassette", "s", "/", "w", ".", "yml", ".", "gz", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "DOMAIN_", "=_", "'", "Integrati", "on", "Test", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "TASK", "LIST_", "=_", "'", "tl", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "IDENTITY", "_", "=_", "'", "test", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "RECORD", "ING_", "=_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "exit", "\\u", "event_", "=_", "multiprocessing_", "._", "Event_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "wf", "\\u", "finish", "ed", "\\u", "event_", "=_", "multiprocessing_", "._", "Event_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Pat", "ch", " ", "vcr", " ", "to", " ", "use", " ", "gzip", " ", "files_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "vcr", "_", "._", "cassette", "_", "._", "load", "\\u", "cassette", "_", "=_", "load", "\\u", "cassette", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "vcr", "_", "._", "cassette", "_", "._", "save", "\\u", "cassette", "_", "=_", "save", "\\u", "cassette", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Pat", "ch", " ", "request", "s", "\\u", "match", " ", "in", " ", "cassette", " ", "for", " ", "speed", "-", "up_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "vcr", "_", "._", "cassette", "_", "._", "request", "s", "\\u", "match_", "=_", "request", "s", "\\u", "match_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Pat", "ch", " ", "ur", "pal", "se", " ", "to", " ", "speed", "-", "up", " ", "for", " ", "python", "3_", "\\u\\u\\uNL\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "from_", "functools_", "import_", "lr", "u\\u", "cache_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "urllib_", "._", "parse_", "import_", "urlparse_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "vcr", "_", "._", "request_", "._", "urlparse_", "=_", "lr", "u\\u", "cache_", "(_", "maxsize_", "=_", "None_", ")_", "(_", "urlparse_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "Import", "Error_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "pass_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "patch", " ", "uuid", "4", " ", "for", " ", "consistent", " ", "keys_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "uuid_", "._", "uuid4_", "=_", "functools_", "._", "partial_", "(_", "next_", ",_", "fake", "\\u", "uuid4_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "a", "\\u", "conf_", "=_", "SW", "FA", "cti", "vity", "Config_", "(_", "default", "\\u", "task", "\\u", "list_", "=_", "TASK", "LIST_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "default", "\\u", "schedule", "\\u", "to", "\\u", "start_", "=_", "30_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "default", "\\u", "schedule", "\\u", "to", "\\u", "close_", "=_", "60_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "default", "\\u", "start", "\\u", "to", "\\u", "close_", "=_", "15_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "default", "\\u", "heartbeat_", "=_", "10_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "empty", "\\u", "conf_", "=_", "SW", "FW", "ork", "flow", "Config_", "(_", "default", "\\u", "task", "\\u", "list_", "=_", "TASK", "LIST_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "default", "\\u", "decision", "\\u", "duration_", "=_", "10_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "default", "\\u", "workf", "low", "\\u", "duration_", "=_", "20_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "default", "\\u", "child", "\\u", "policy_", "=_", "'", "TERMINAT", "E", "'_", ",_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "empty", "\\u", "conf_", "._", "conf", "\\u", "activity_", "(_", "'", "activit", "y", "'_", ",_", "VERSION_", ",_", "'", "tac", "tiv", "it", "y", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "conf", "\\u", "use", "\\u", "activities_", "=_", "SW", "FW", "ork", "flow", "Config_", "(_", "default", "\\u", "task", "\\u", "list_", "=_", "TASK", "LIST_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "default", "\\u", "decision", "\\u", "duration_", "=_", "10_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "default", "\\u", "workf", "low", "\\u", "duration_", "=_", "60_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "default", "\\u", "child", "\\u", "policy_", "=_", "'", "TERMINAT", "E", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "conf", "\\u", "use", "\\u", "activities_", "._", "conf", "\\u", "activity_", "(_", "'", "task", "'_", ",_", "VERSION_", ",_", "'", "tac", "tiv", "it", "y", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "conf", "\\u", "use", "\\u", "activities_", "._", "conf", "\\u", "activity_", "(_", "'", "short", "\\u", "task", "'_", ",_", "VERSION_", ",_", "'", "tac", "tiv", "it", "y", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "schedule", "\\u", "to", "\\u", "close_", "=_", "1_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "retry_", "=_", "(_", "0_", ",_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "conf", "\\u", "use", "\\u", "activities_", "._", "conf", "\\u", "activity_", "(_", "'", "delayed", "\\u", "task", "'_", ",_", "VERSION_", ",_", "'", "tac", "tiv", "it", "y", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "retry_", "=_", "(_", "3_", ",_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "conf", "\\u", "use", "\\u", "activities_", "._", "conf", "\\u", "activity_", "(_", "'", "non", "\\u", "exist", "ing", "\\u", "task", "'_", ",_", "1_", ",_", "'", "xxx", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "conf", "\\u", "use", "\\u", "workflow_", "=_", "SW", "FW", "ork", "flow", "Config_", "(_", "default", "\\u", "task", "\\u", "list_", "=_", "TASK", "LIST_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "default", "\\u", "decision", "\\u", "duration_", "=_", "10_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "default", "\\u", "workf", "low", "\\u", "duration_", "=_", "60_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "default", "\\u", "child", "\\u", "policy_", "=_", "'", "TERMINAT", "E", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "conf", "\\u", "use", "\\u", "workflow_", "._", "conf", "\\u", "workflow_", "(_", "'", "task", "'_", ",_", "VERSION_", ",_", "'", "TW", "ork", "flow", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "conf", "\\u", "use", "\\u", "workflow_", "._", "conf", "\\u", "workflow_", "(_", "'", "short", "\\u", "task", "'_", ",_", "VERSION_", ",_", "'", "TW", "ork", "flow", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "workf", "low", "\\u", "duration_", "=_", "1_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "retry_", "=_", "(_", "0_", ",_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "conf", "\\u", "use", "\\u", "workflow_", "._", "conf", "\\u", "workflow_", "(_", "'", "delayed", "\\u", "task", "'_", ",_", "VERSION_", ",_", "'", "TW", "ork", "flow", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "retry_", "=_", "(_", "3_", ",_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "conf", "\\u", "use", "\\u", "workflow_", "._", "conf", "\\u", "workflow_", "(_", "'", "non", "\\u", "exist", "ing", "\\u", "task", "'_", ",_", "1_", ",_", "'", "xxx", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "ww", "ork", "er_", "=_", "Test", "SW", "FW", "ork", "flow", "Worker_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "ww", "ork", "er_", "._", "scan_", "(_", "package_", "=_", "sys_", "._", "modules_", "[_", "\\u\\u", "name\\u\\u_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "aw", "ork", "er_", "=_", "Test", "SW", "FA", "cti", "vity", "Worker_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "aw", "ork", "er_", "._", "scan_", "(_", "package_", "=_", "sys_", "._", "modules_", "[_", "\\u\\u", "name\\u\\u_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "body", "\\u", "cache_", "=_", "{_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "vcr", "_", "._", "default", "\\u", "vcr", "_", "._", "register", "\\u", "matcher_", "(_", "'", "dict", "\\u", "body", "'_", ",_", "body", "\\u", "as", "\\u", "dict_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "vcr", "_", "._", "default", "\\u", "vcr", "_", "._", "register", "\\u", "matcher_", "(_", "'", "esc", "\\u", "header", "s", "'_", ",_", "body", "\\u", "as", "\\u", "dict_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "cassette", "\\u", "args_", "=_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "'", "match", "\\u", "on", "'_", ":_", "[_", "'", "dict", "\\u", "body", "'_", ",_", "'", "esc", "\\u", "header", "s", "'_", ",_", "'", "query", "'_", ",_", "'", "method", "'_", ",_", "'", "uri", "'_", ",_", "'", "host", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "port", "'_", ",_", "'", "path", "'_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "filter", "\\u", "header", "s", "'_", ":_", "[_", "'", "authoriz", "ation", "'_", ",_", "'", "x", "-", "am", "z", "-", "date", "'_", ",_", "'", "content", "-", "length", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "user", "-", "agent", "'_", "]_", "\\u\\u\\uNL\\u\\u\\u_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "\\u\\u", "name\\u\\u_", "==_", "'\\u", "\\u", "main", "\\u\\u'_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "RECORD", "ING_", "=_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "os_", "._", "remove_", "(_", "A", "\\u", "CAS", "SET", "TE_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "pass_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "os_", "._", "remove_", "(_", "W", "\\u", "CAS", "SET", "TE_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "pass_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "a", "\\u", "worker_", "=_", "multiprocessing_", "._", "Process_", "(_", "target_", "=_", "start", "\\u", "activit", "y", "\\u", "worker_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "w", "\\u", "worker_", "=_", "multiprocessing_", "._", "Process_", "(_", "target_", "=_", "start", "\\u", "workf", "low", "\\u", "worker_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "a", "\\u", "worker_", "._", "start_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "w", "\\u", "worker_", "._", "start_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "time_", "._", "sleep_", "(_", "5_", ")_", "#", " ", "Wait", " ", "for", " ", "registration_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "wfs", "_", "=_", "[_", "'", "Test", "Work", "flow", "'_", ",_", "'", "Test", "Work", "flow", "W", "'_", ",_", "'", "Restart", "Work", "flow", "'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "wf_", "in_", "wfs", "_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "print_", "(_", "'", "Start", "ing", "'_", ",_", "wf_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "SW", "FW", "ork", "flow", "Start", "er_", "(_", "DOMAIN_", ",_", "wf_", ",_", "VERSION_", ")_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "wf", "\\u", "finish", "ed", "\\u", "event_", "._", "wait_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "wf", "\\u", "finish", "ed", "\\u", "event_", "._", "clear_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Mus", "t", " ", "be", " ", "the", " ", "last", " ", "one_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "print_", "(_", "'", "Prepare", " ", "to", " ", "exit", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "SW", "FW", "ork", "flow", "Start", "er_", "(_", "DOMAIN_", ",_", "'", "Exi", "t", "Work", "flow", "'_", ",_", "VERSION_", ")_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_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2, 2, 2, 2, 0, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 ]
Conflicting attributes in base classes
ga4gh/server/ga4gh/cli.py
[ { "content": "class AbstractQueryRunner(object):\n \"\"\"\n Abstract base class for runner classes\n \"\"\"", "metadata": "root.AbstractQueryRunner", "header": "['module', '___EOS___']", "index": 158 }, { "content": " def __init__(self, args):\n self._key = args.key\n # TODO this is an experimental addition which is useful for\n # testing. We should think about this and document it if we\n # this it's a useful feature. There is an argument for pushing\n # the backend instantiation into the client, and letting the\n # client be a factory, instantiating the correct Client class\n # depending on the prefix.\n filePrefix = \"file://\"\n if args.baseUrl.startswith(filePrefix):\n dataDir = args.baseUrl[len(filePrefix):]\n theBackend = backend.Backend(\n datarepo.FileSystemDataRepository(dataDir))\n self._client = client.LocalClient(theBackend)\n else:\n self._client = client.HttpClient(\n args.baseUrl, verbosityToLogLevel(args.verbose), self._key)", "metadata": "root.AbstractQueryRunner.__init__", "header": "['class', 'AbstractQueryRunner', '(', 'object', ')', ':', '___EOS___']", "index": 162 }, { "content": "class FormattedOutputRunner(AbstractQueryRunner):\n \"\"\"\n Superclass of runners that support output in common formats.\n \"\"\"\n\n", "metadata": "root.FormattedOutputRunner", "header": "['module', '___EOS___']", "index": 181 }, { "content": " def __init__(self, args):\n super(FormattedOutputRunner, self).__init__(args)\n self._output = self._textOutput\n if args.outputFormat == \"json\":\n self._output = self._jsonOutput", "metadata": "root.FormattedOutputRunner.__init__", "header": "['class', 'FormattedOutputRunner', '(', 'AbstractQueryRunner', ')', ':', '___EOS___']", "index": 185 }, { "content": " def _jsonOutput(self, gaObjects):\n \"\"\"\n Outputs the specified protocol objects as one JSON string per\n line.\n \"\"\"\n for gaObject in gaObjects:\n print(gaObject.toJsonString())", "metadata": "root.FormattedOutputRunner._jsonOutput", "header": "['class', 'FormattedOutputRunner', '(', 'AbstractQueryRunner', ')', ':', '___EOS___']", "index": 191 }, { "content": " def _textOutput(self, gaObjects):\n \"\"\"\n Outputs a text summary of the specified protocol objects, one\n per line.\n \"\"\"\n for gaObject in gaObjects:\n if hasattr(gaObject, 'name'):\n print(gaObject.id, gaObject.name, sep=\"\\t\")\n else:\n print(gaObject.id, sep=\"\\t\")", "metadata": "root.FormattedOutputRunner._textOutput", "header": "['class', 'FormattedOutputRunner', '(', 'AbstractQueryRunner', ')', ':', '___EOS___']", "index": 199 }, { "content": "class AbstractGetRunner(FormattedOutputRunner):\n \"\"\"\n Abstract base class for get runner classes\n \"\"\"\n", "metadata": "root.AbstractGetRunner", "header": "['module', '___EOS___']", "index": 211 }, { "content": " def __init__(self, args):\n super(AbstractGetRunner, self).__init__(args)\n self._id = args.id", "metadata": "root.AbstractGetRunner.__init__", "header": "['class', 'AbstractGetRunner', '(', 'FormattedOutputRunner', ')', ':', '___EOS___']", "index": 215 }, { "content": " def run(self):\n response = self._method(self._id)\n self._output([response])", "metadata": "root.AbstractGetRunner.run", "header": "['class', 'AbstractGetRunner', '(', 'FormattedOutputRunner', ')', ':', '___EOS___']", "index": 219 }, { "content": "class AbstractSearchRunner(FormattedOutputRunner):\n \"\"\"\n Abstract base class for search runner classes\n \"\"\"\n\n\n\n\n\n\n", "metadata": "root.AbstractSearchRunner", "header": "['module', '___EOS___']", "index": 224 }, { "content": " def __init__(self, args):\n super(AbstractSearchRunner, self).__init__(args)\n self._pageSize = args.pageSize\n self._client.setPageSize(self._pageSize)", "metadata": "root.AbstractSearchRunner.__init__", "header": "['class', 'AbstractSearchRunner', '(', 'FormattedOutputRunner', ')', ':', '___EOS___']", "index": 229 }, { "content": " def getAllDatasets(self):\n \"\"\"\n Returns all datasets on the server.\n \"\"\"\n return self._client.searchDatasets()", "metadata": "root.AbstractSearchRunner.getAllDatasets", "header": "['class', 'AbstractSearchRunner', '(', 'FormattedOutputRunner', ')', ':', '___EOS___']", "index": 234 }, { "content": " def getAllVariantSets(self):\n \"\"\"\n Returns all variant sets on the server.\n \"\"\"\n for dataset in self.getAllDatasets():\n iterator = self._client.searchVariantSets(datasetId=dataset.id)\n for variantSet in iterator:\n yield variantSet", "metadata": "root.AbstractSearchRunner.getAllVariantSets", "header": "['class', 'AbstractSearchRunner', '(', 'FormattedOutputRunner', ')', ':', '___EOS___']", "index": 240 }, { "content": " def getAllFeatureSets(self):\n \"\"\"\n Returns all feature sets on the server.\n \"\"\"\n for dataset in self.getAllDatasets():\n iterator = self._client.searchFeatureSets(datasetId=dataset.id)\n for featureSet in iterator:\n yield featureSet", "metadata": "root.AbstractSearchRunner.getAllFeatureSets", "header": "['class', 'AbstractSearchRunner', '(', 'FormattedOutputRunner', ')', ':', '___EOS___']", "index": 249 }, { "content": " def getAllReadGroupSets(self):\n \"\"\"\n Returns all readgroup sets on the server.\n \"\"\"\n for dataset in self.getAllDatasets():\n iterator = self._client.searchReadGroupSets(\n datasetId=dataset.id)\n for readGroupSet in iterator:\n yield readGroupSet", "metadata": "root.AbstractSearchRunner.getAllReadGroupSets", "header": "['class', 'AbstractSearchRunner', '(', 'FormattedOutputRunner', ')', ':', '___EOS___']", "index": 258 }, { "content": " def getAllReadGroups(self):\n \"\"\"\n Get all read groups in a read group set\n \"\"\"\n for dataset in self.getAllDatasets():\n iterator = self._client.searchReadGroupSets(\n datasetId=dataset.id)\n for readGroupSet in iterator:\n readGroupSet = self._client.getReadGroupSet(readGroupSet.id)\n for readGroup in readGroupSet.readGroups:\n yield readGroup.id", "metadata": "root.AbstractSearchRunner.getAllReadGroups", "header": "['class', 'AbstractSearchRunner', '(', 'FormattedOutputRunner', ')', ':', '___EOS___']", "index": 268 }, { "content": " def getAllReferenceSets(self):\n \"\"\"\n Returns all reference sets on the server.\n \"\"\"\n return self._client.searchReferenceSets()", "metadata": "root.AbstractSearchRunner.getAllReferenceSets", "header": "['class', 'AbstractSearchRunner', '(', 'FormattedOutputRunner', ')', ':', '___EOS___']", "index": 280 }, { "content": "class VariantFormatterMixin(object):\n \"\"\"\n Simple mixin to format variant objects.\n \"\"\"", "metadata": "root.VariantFormatterMixin", "header": "['module', '___EOS___']", "index": 441 }, { "content": " def _textOutput(self, gaObjects):\n \"\"\"\n Prints out the specified Variant objects in a VCF-like form.\n \"\"\"\n for variant in gaObjects:\n print(\n variant.id, variant.variantSetId, variant.names,\n variant.referenceName, variant.start, variant.end,\n variant.referenceBases, variant.alternateBases,\n sep=\"\\t\", end=\"\\t\")\n for key, value in variant.info.items():\n print(key, value, sep=\"=\", end=\";\")\n print(\"\\t\", end=\"\")\n for c in variant.calls:\n print(\n c.callSetId, c.genotype, c.genotypeLikelihood, c.info,\n c.phaseset, sep=\":\", end=\"\\t\")\n print()", "metadata": "root.VariantFormatterMixin._textOutput", "header": "['class', 'VariantFormatterMixin', '(', 'object', ')', ':', '___EOS___']", "index": 445 }, { "content": "class AnnotationFormatterMixin(object):\n \"\"\"\n Simple mixin to format variant objects.\n \"\"\"", "metadata": "root.AnnotationFormatterMixin", "header": "['module', '___EOS___']", "index": 465 }, { "content": " def _textOutput(self, gaObjects):\n \"\"\"\n Prints out the specified Variant objects in a VCF-like form.\n \"\"\"\n for variantAnnotation in gaObjects:\n print(\n variantAnnotation.id, variantAnnotation.variantId,\n variantAnnotation.variantAnnotationSetId,\n variantAnnotation.createDateTime, sep=\"\\t\", end=\"\\t\")\n for effect in variantAnnotation.transcriptEffects:\n print(effect.alternateBases, sep=\"|\", end=\"|\")\n for so in effect.effects:\n print(so.term, sep=\"&\", end=\"|\")\n print(so.id, sep=\"&\", end=\"|\")\n print(effect.hgvsAnnotation.transcript,\n effect.hgvsAnnotation.protein, sep=\"|\", end=\"\\t\")\n print()", "metadata": "root.AnnotationFormatterMixin._textOutput", "header": "['class', 'AnnotationFormatterMixin', '(', 'object', ')', ':', '___EOS___']", "index": 469 }, { "content": "class FeatureFormatterMixin(object):\n \"\"\"\n Mix-in class to format Feature (Sequence Annotation) objects\n \"\"\"", "metadata": "root.FeatureFormatterMixin", "header": "['module', '___EOS___']", "index": 488 }, { "content": " def _textOutput(self, gaObjects):\n for feature in gaObjects:\n print(\n feature.id, feature.parentId, feature.featureSetId,\n feature.referenceName, feature.start, feature.end,\n feature.strand, sep=\"\\t\", end=\"\\t\")\n print(\n \"FeatureType:\", feature.featureType.id,\n feature.featureType.term, end=\"\\t\")\n for attrkey in feature.attributes.vals.keys():\n print(\n attrkey, feature.attributes.vals[attrkey],\n sep=\":\", end=\"; \")\n print()", "metadata": "root.FeatureFormatterMixin._textOutput", "header": "['class', 'FeatureFormatterMixin', '(', 'object', ')', ':', '___EOS___']", "index": 492 }, { "content": "class SearchVariantsRunner(VariantFormatterMixin, AbstractSearchRunner):\n \"\"\"\n Runner class for the variants/search method.\n \"\"\"\n\n", "metadata": "root.SearchVariantsRunner", "header": "['module', '___EOS___']", "index": 508 }, { "content": "class SearchVariantAnnotationsRunner(\n AnnotationFormatterMixin, AbstractSearchRunner):\n \"\"\"\n Runner class for the variantannotations/search method.\n \"\"\"\n\n\n", "metadata": "root.SearchVariantAnnotationsRunner", "header": "['module', '___EOS___']", "index": 540 }, { "content": "class SearchFeaturesRunner(FeatureFormatterMixin, AbstractSearchRunner):\n \"\"\"\n Runner class for the features/search method.\n \"\"\"\n\n", "metadata": "root.SearchFeaturesRunner", "header": "['module', '___EOS___']", "index": 588 }, { "content": "class GetVariantRunner(VariantFormatterMixin, AbstractGetRunner):\n \"\"\"\n Runner class for the variants/{id} method\n \"\"\"", "metadata": "root.GetVariantRunner", "header": "['module', '___EOS___']", "index": 756 }, { "content": "class GetFeatureRunner(FeatureFormatterMixin, AbstractGetRunner):\n \"\"\"\n Runner class for the features/{id} method\n \"\"\"", "metadata": "root.GetFeatureRunner", "header": "['module', '___EOS___']", "index": 783 } ]
[ { "span": "class SearchVariantsRunner(VariantFormatterMixin, AbstractSearchRunner):", "start_line": 508, "start_column": 0, "end_line": 508, "end_column": 72 }, { "span": "class SearchVariantAnnotationsRunner(\n AnnotationFormatterMixin, AbstractSearchRunner):", "start_line": 540, "start_column": 0, "end_line": 541, "end_column": 56 }, { "span": "class SearchFeaturesRunner(FeatureFormatterMixin, AbstractSearchRunner):", "start_line": 588, "start_column": 0, "end_line": 588, "end_column": 72 }, { "span": "class GetVariantRunner(VariantFormatterMixin, AbstractGetRunner):", "start_line": 756, "start_column": 0, "end_line": 756, "end_column": 65 }, { "span": "class GetFeatureRunner(FeatureFormatterMixin, AbstractGetRunner):", "start_line": 783, "start_column": 0, "end_line": 783, "end_column": 65 } ]
[ { "span": "def _textOutput(self, gaObjects):", "start_line": 199, "start_column": 4, "end_line": 199, "end_column": 37 }, { "span": "def _textOutput(self, gaObjects):", "start_line": 445, "start_column": 4, "end_line": 445, "end_column": 37 }, { "span": "def _textOutput(self, gaObjects):", "start_line": 469, "start_column": 4, "end_line": 469, "end_column": 37 }, { "span": "def _textOutput(self, gaObjects):", "start_line": 492, "start_column": 4, "end_line": 492, "end_column": 37 } ]
1
false
[ "[CLS]_", "Confl", "ict", "ing_", "attributes_", "in_", "base_", "classes_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "class_", "Abstract", "Query", "Runner_", "(_", "object_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Abstract", " ", "base", " ", "class", " ", "for", " ", "runn", "er", " ", "classe", "s", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Abstract", "Query", "Runner_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "\\u\\u", "init\\u\\u_", "(_", "self_", ",_", "args_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "\\u", "key_", "=_", "args_", "._", "key_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "TOD", "O", " ", "this", " ", "is", " ", "an", " ", "experimental", " ", "addition", " ", "whi", "ch", " ", "is", " ", "usef", "ul", " ", "for_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "testi", "ng", ".", " ", "We", " ", "shou", "ld", " ", "think", " ", "abo", "ut", " ", "this", " ", "and", " ", "document", " ", "it", " ", "if", " ", "we", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "this", " ", "it", "'", "s", " ", "a", " ", "usef", "ul", " ", "feature", ".", " ", "There", " ", "is", " ", "an", " ", "argu", "ment", " ", "for", " ", "push", "ing_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "the", " ", "back", "end", " ", "instantiation", " ", "int", "o", " ", "the", " ", "client", ",", " ", "and", " ", "lett", "ing", " ", "the_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "client", " ", "be", " ", "a", " ", "factor", "y", ",", " ", "instant", "iati", "ng", " ", "the", " ", "correct", " ", "Client", " ", "class_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "depend", "ing", " ", "on", " ", "the", " ", "prefix", "._", "\\u\\u\\uNL\\u\\u\\u_", "file", "Prefix_", "=_", "\"", "file", "://\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "args_", "._", "base", "Url_", "._", "startswith_", "(_", "file", "Prefix_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "data", "Dir_", "=_", "args_", "._", "base", "Url_", "[_", "len_", "(_", "file", "Prefix_", ")_", ":_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "the", "Backend_", "=_", "backend_", "._", "Backend_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "datar", "epo", "_", "._", "File", "System", "Data", "Repository_", "(_", "data", "Dir_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "\\u", "client_", "=_", "client_", "._", "Local", "Client_", "(_", "the", "Backend_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "\\u", "client_", "=_", "client_", "._", "Http", "Client_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "args_", "._", "base", "Url_", ",_", "verbo", "sity", "To", "Log", "Level_", "(_", "args_", "._", "verbose_", ")_", ",_", "self_", "._", "\\u", "key_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "class_", "Formatt", "ed", "Output", "Runner_", "(_", "Abstract", "Query", "Runner_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Super", "class", " ", "of", " ", "runners", " ", "tha", "t", " ", "support", " ", "output", " ", "in", " ", "common", " ", "formats", ".", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "[SEP]_", "class_", "Formatt", "ed", "Output", "Runner_", "(_", "Abstract", "Query", "Runner_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "\\u\\u", "init\\u\\u_", "(_", "self_", ",_", "args_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "super_", "(_", "Formatt", "ed", "Output", "Runner_", ",_", "self_", ")_", "._", "\\u\\u", "init\\u\\u_", "(_", "args_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "\\u", "output_", "=_", "self_", "._", "\\u", "text", "Output_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "args_", "._", "output", "Format_", "==_", "\"", "json", "\"_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "\\u", "output_", "=_", "self_", "._", "\\u", "json", "Output_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Formatt", "ed", "Output", "Runner_", "(_", "Abstract", "Query", "Runner_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "\\u", "json", "Output_", "(_", "self_", ",_", "ga", "Objects_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Output", "s", " ", "the", " ", "specified", " ", "protoc", "ol", " ", "object", "s", " ", "as", " ", "one", " ", "JSO", "N", " ", "string", " ", "per", "\\", "10", ";", " ", " ", " ", " ", "line", ".", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "ga", "Object_", "in_", "ga", "Objects_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "print_", "(_", "ga", "Object_", "._", "to", "Js", "on", "String_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Formatt", "ed", "Output", "Runner_", "(_", "Abstract", "Query", "Runner_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "\\u", "text", "Output_", "(_", "self_", ",_", "ga", "Objects_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Output", "s", " ", "a", " ", "text", " ", "summar", "y", " ", "of", " ", "the", " ", "specified", " ", "protoc", "ol", " ", "object", "s", ",", " ", "one", "\\", "10", ";", " ", " ", " ", " ", "per", " ", "line", ".", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "ga", "Object_", "in_", "ga", "Objects_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "hasattr_", "(_", "ga", "Object_", ",_", "'", "name", "'_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "print_", "(_", "ga", "Object_", "._", "id_", ",_", "ga", "Object_", "._", "name_", ",_", "sep_", "=_", "\"\\\\", "t", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "print_", "(_", "ga", "Object_", "._", "id_", ",_", "sep_", "=_", "\"\\\\", "t", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "class_", "Abstract", "Get", "Runner_", "(_", "Formatt", "ed", "Output", "Runner_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Abstract", " ", "base", " ", "class", " ", "for", " ", "get", " ", "runn", "er", " ", "classe", "s", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "[SEP]_", "class_", "Abstract", "Get", "Runner_", "(_", "Formatt", "ed", "Output", "Runner_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "\\u\\u", "init\\u\\u_", "(_", "self_", ",_", "args_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "super_", "(_", "Abstract", "Get", "Runner_", ",_", "self_", ")_", "._", "\\u\\u", "init\\u\\u_", "(_", "args_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "\\u", "id_", "=_", "args_", "._", "id_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Abstract", "Get", "Runner_", "(_", "Formatt", "ed", "Output", "Runner_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "run_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "response_", "=_", "self_", "._", "\\u", "method_", "(_", "self_", "._", "\\u", "id_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "\\u", "output_", "(_", "[_", "response_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "class_", "Abstract", "Sear", "ch", "Runner_", "(_", "Formatt", "ed", "Output", "Runner_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Abstract", " ", "base", " ", "class", " ", "for", " ", "search", " ", "runn", "er", " ", "classe", "s", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "[SEP]_", "class_", "Abstract", "Sear", "ch", "Runner_", "(_", "Formatt", "ed", "Output", "Runner_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "\\u\\u", "init\\u\\u_", "(_", "self_", ",_", "args_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "super_", "(_", "Abstract", "Sear", "ch", "Runner_", ",_", "self_", ")_", "._", "\\u\\u", "init\\u\\u_", "(_", "args_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "\\u", "page", "Size_", "=_", "args_", "._", "page", "Size_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "\\u", "client_", "._", "set", "Page", "Size_", "(_", "self_", "._", "\\u", "page", "Size_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Abstract", "Sear", "ch", "Runner_", "(_", "Formatt", "ed", "Output", "Runner_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "get", "All", "Datasets", "_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Return", "s", " ", "all", " ", "dataset", "s", " ", "on", " ", "the", " ", "server", ".", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "self_", "._", "\\u", "client_", "._", "search", "Datasets", "_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Abstract", "Sear", "ch", "Runner_", "(_", "Formatt", "ed", "Output", "Runner_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "get", "All", "Varia", "nt", "Sets_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Return", "s", " ", "all", " ", "variant", " ", "sets", " ", "on", " ", "the", " ", "server", ".", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "dataset_", "in_", "self_", "._", "get", "All", "Datasets", "_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "iterator_", "=_", "self_", "._", "\\u", "client_", "._", "search", "Varia", "nt", "Sets_", "(_", "dataset", "Id_", "=_", "dataset_", "._", "id_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "variant", "Set_", "in_", "iterator_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "yield_", "variant", "Set_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Abstract", "Sear", "ch", "Runner_", "(_", "Formatt", "ed", "Output", "Runner_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "get", "All", "Feature", "Sets_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Return", "s", " ", "all", " ", "feature", " ", "sets", " ", "on", " ", "the", " ", "server", ".", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "dataset_", "in_", "self_", "._", "get", "All", "Datasets", "_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "iterator_", "=_", "self_", "._", "\\u", "client_", "._", "search", "Feature", "Sets_", "(_", "dataset", "Id_", "=_", "dataset_", "._", "id_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "feature", "Set_", "in_", "iterator_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "yield_", "feature", "Set_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Abstract", "Sear", "ch", "Runner_", "(_", "Formatt", "ed", "Output", "Runner_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "get", "All", "Read", "Group", "Sets_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Return", "s", " ", "all", " ", "read", "group", " ", "sets", " ", "on", " ", "the", " ", "server", ".", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "dataset_", "in_", "self_", "._", "get", "All", "Datasets", "_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "iterator_", "=_", "self_", "._", "\\u", "client_", "._", "search", "Read", "Group", "Sets_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "dataset", "Id_", "=_", "dataset_", "._", "id_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "read", "Group", "Set_", "in_", "iterator_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "yield_", "read", "Group", "Set_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Abstract", "Sear", "ch", "Runner_", "(_", "Formatt", "ed", "Output", "Runner_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "get", "All", "Read", "Groups_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Get", " ", "all", " ", "read", " ", "group", "s", " ", "in", " ", "a", " ", "read", " ", "group", " ", "set", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "dataset_", "in_", "self_", "._", "get", "All", "Datasets", "_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "iterator_", "=_", "self_", "._", "\\u", "client_", "._", "search", "Read", "Group", "Sets_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "dataset", "Id_", "=_", "dataset_", "._", "id_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "read", "Group", "Set_", "in_", "iterator_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "read", "Group", "Set_", "=_", "self_", "._", "\\u", "client_", "._", "get", "Read", "Group", "Set_", "(_", "read", "Group", "Set_", "._", "id_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "read", "Group_", "in_", "read", "Group", "Set_", "._", "read", "Groups_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "yield_", "read", "Group_", "._", "id_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Abstract", "Sear", "ch", "Runner_", "(_", "Formatt", "ed", "Output", "Runner_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "get", "All", "Reference", "Sets_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Return", "s", " ", "all", " ", "reference", " ", "sets", " ", "on", " ", "the", " ", "server", ".", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "self_", "._", "\\u", "client_", "._", "search", "Reference", "Sets_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "class_", "Varia", "nt", "Formatt", "er", "Mixin_", "(_", "object_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Simple", " ", "mix", "in", " ", "to", " ", "format", " ", "variant", " ", "object", "s", ".", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Varia", "nt", "Formatt", "er", "Mixin_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "\\u", "text", "Output_", "(_", "self_", ",_", "ga", "Objects_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Print", "s", " ", "out", " ", "the", " ", "specified", " ", "Varia", "nt", " ", "object", "s", " ", "in", " ", "a", " ", "VC", "F", "-", "like", " ", "form", ".", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "variant_", "in_", "ga", "Objects_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "print_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "variant_", "._", "id_", ",_", "variant_", "._", "variant", "Set", "Id_", ",_", "variant_", "._", "names_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "variant_", "._", "reference", "Name_", ",_", "variant_", "._", "start_", ",_", "variant_", "._", "end_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "variant_", "._", "reference", "Base", "s_", ",_", "variant_", "._", "alternat", "e", "Base", "s_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "sep_", "=_", "\"\\\\", "t", "\"_", ",_", "end_", "=_", "\"\\\\", "t", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "key_", ",_", "value_", "in_", "variant_", "._", "info_", "._", "items_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "print_", "(_", "key_", ",_", "value_", ",_", "sep_", "=_", "\"=\"_", ",_", "end_", "=_", "\";\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "print_", "(_", "\"\\\\", "t", "\"_", ",_", "end_", "=_", "\"\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "c_", "in_", "variant_", "._", "calls_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "print_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "c_", "._", "call", "Set", "Id_", ",_", "c_", "._", "genotype", "_", ",_", "c_", "._", "genotype", "Likelihood", "_", ",_", "c_", "._", "info_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "c_", "._", "phase", "set_", ",_", "sep_", "=_", "\":\"_", ",_", "end_", "=_", "\"\\\\", "t", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "print_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "class_", "Annot", "ation", "Formatt", "er", "Mixin_", "(_", "object_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Simple", " ", "mix", "in", " ", "to", " ", "format", " ", "variant", " ", "object", "s", ".", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Annot", "ation", "Formatt", "er", "Mixin_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "\\u", "text", "Output_", "(_", "self_", ",_", "ga", "Objects_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Print", "s", " ", "out", " ", "the", " ", "specified", " ", "Varia", "nt", " ", "object", "s", " ", "in", " ", "a", " ", "VC", "F", "-", "like", " ", "form", ".", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "variant", "Annotation_", "in_", "ga", "Objects_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "print_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "variant", "Annotation_", "._", "id_", ",_", "variant", "Annotation_", "._", "variant", "Id_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "variant", "Annotation_", "._", "variant", "Annot", "ation", "Set", "Id_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "variant", "Annotation_", "._", "create", "Date", "Time_", ",_", "sep_", "=_", "\"\\\\", "t", "\"_", ",_", "end_", "=_", "\"\\\\", "t", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "effect_", "in_", "variant", "Annotation_", "._", "transcri", "pt", "Effe", "cts_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "print_", "(_", "effect_", "._", "alternat", "e", "Base", "s_", ",_", "sep_", "=_", "\"|\"_", ",_", "end_", "=_", "\"|\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "so_", "in_", "effect_", "._", "effects_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "print_", "(_", "so_", "._", "term_", ",_", "sep_", "=_", "\"&\"_", ",_", "end_", "=_", "\"|\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "print_", "(_", "so_", "._", "id_", ",_", "sep_", "=_", "\"&\"_", ",_", "end_", "=_", "\"|\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "print_", "(_", "effect_", "._", "hg", "vs", "Annotation_", "._", "transcript_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "effect_", "._", "hg", "vs", "Annotation_", "._", "protein_", ",_", "sep_", "=_", "\"|\"_", ",_", "end_", "=_", "\"\\\\", "t", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "print_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "class_", "Feature", "Formatt", "er", "Mixin_", "(_", "object_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Mix", "-", "in", " ", "class", " ", "to", " ", "format", " ", "Feature", " ", "(", "Sequ", "ence", " ", "Annot", "ation", ")", " ", "object", "s", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Feature", "Formatt", "er", "Mixin_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "\\u", "text", "Output_", "(_", "self_", ",_", "ga", "Objects_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "for_", "feature_", "in_", "ga", "Objects_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "print_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "feature_", "._", "id_", ",_", "feature_", "._", "parent", "Id_", ",_", "feature_", "._", "feature", "Set", "Id_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "feature_", "._", "reference", "Name_", ",_", "feature_", "._", "start_", ",_", "feature_", "._", "end_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "feature_", "._", "strand_", ",_", "sep_", "=_", "\"\\\\", "t", "\"_", ",_", "end_", "=_", "\"\\\\", "t", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "print_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "Feature", "Type", ":\"_", ",_", "feature_", "._", "feature", "Type_", "._", "id_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "feature_", "._", "feature", "Type_", "._", "term_", ",_", "end_", "=_", "\"\\\\", "t", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "attr", "key_", "in_", "feature_", "._", "attributes_", "._", "vals_", "._", "keys_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "print_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "attr", "key_", ",_", "feature_", "._", "attributes_", "._", "vals_", "[_", "attr", "key_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "sep_", "=_", "\":\"_", ",_", "end_", "=_", "\";", " ", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "print_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "class_", "Sear", "ch", "Varia", "nts", "Runner_", "(_", "Varia", "nt", "Formatt", "er", "Mixin_", ",_", "Abstract", "Sear", "ch", "Runner_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Run", "ner", " ", "class", " ", "for", " ", "the", " ", "variant", "s", "/", "search", " ", "method", ".", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "class_", "Sear", "ch", "Varia", "nt", "Annotations", "Runner_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "Annot", "ation", "Formatt", "er", "Mixin_", ",_", "Abstract", "Sear", "ch", "Runner_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Run", "ner", " ", "class", " ", "for", " ", "the", " ", "variant", "annot", "ation", "s", "/", "search", " ", "method", ".", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "class_", "Sear", "ch", "Feature", "s", "Runner_", "(_", "Feature", "Formatt", "er", "Mixin_", ",_", "Abstract", "Sear", "ch", "Runner_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Run", "ner", " ", "class", " ", "for", " ", "the", " ", "features", "/", "search", " ", "method", ".", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "class_", "Get", "Varia", "nt", "Runner_", "(_", "Varia", "nt", "Formatt", "er", "Mixin_", ",_", "Abstract", "Get", "Runner_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Run", "ner", " ", "class", " ", "for", " ", "the", " ", "variant", "s", "/{", "id", "}", " ", "method", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "class_", "Get", "Feature", "Runner_", "(_", "Feature", "Formatt", "er", "Mixin_", ",_", "Abstract", "Get", "Runner_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Run", "ner", " ", "class", " ", "for", " ", "the", " ", "features", "/{", "id", "}", " ", "method", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_" ]
[ 4, 4, 4, 4, 4, 4, 4, 4, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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, 2, 2, 2, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 4, 2, 2, 2, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 ]
Unused local variable
AppScale/appscale/AppServer/lib/django-1.5/tests/modeltests/many_to_one/tests.py
[ { "content": " def test_selects(self):\n new_article = self.r.article_set.create(headline=\"John's second story\",\n pub_date=datetime(2005, 7, 29))\n new_article2 = self.r2.article_set.create(headline=\"Paul's story\",\n pub_date=datetime(2006, 1, 17))\n # Reporter objects have access to their related Article objects.\n self.assertQuerysetEqual(self.r.article_set.all(), [\n \"<Article: John's second story>\",\n \"<Article: This is a test>\",\n ])\n self.assertQuerysetEqual(self.r.article_set.filter(headline__startswith='This'),\n [\"<Article: This is a test>\"])\n self.assertEqual(self.r.article_set.count(), 2)\n self.assertEqual(self.r2.article_set.count(), 1)\n # Get articles by id\n self.assertQuerysetEqual(Article.objects.filter(id__exact=self.a.id),\n [\"<Article: This is a test>\"])\n self.assertQuerysetEqual(Article.objects.filter(pk=self.a.id),\n [\"<Article: This is a test>\"])\n # Query on an article property\n self.assertQuerysetEqual(Article.objects.filter(headline__startswith='This'),\n [\"<Article: This is a test>\"])\n # The API automatically follows relationships as far as you need.\n # Use double underscores to separate relationships.\n # This works as many levels deep as you want. There's no limit.\n # Find all Articles for any Reporter whose first name is \"John\".\n self.assertQuerysetEqual(Article.objects.filter(reporter__first_name__exact='John'),\n [\n \"<Article: John's second story>\",\n \"<Article: This is a test>\",\n ])\n # Check that implied __exact also works\n self.assertQuerysetEqual(Article.objects.filter(reporter__first_name='John'),\n [\n \"<Article: John's second story>\",\n \"<Article: This is a test>\",\n ])\n # Query twice over the related field.\n self.assertQuerysetEqual(\n Article.objects.filter(reporter__first_name__exact='John',\n reporter__last_name__exact='Smith'),\n [\n \"<Article: John's second story>\",\n \"<Article: This is a test>\",\n ])\n # The underlying query only makes one join when a related table is referenced twice.\n queryset = Article.objects.filter(reporter__first_name__exact='John',\n reporter__last_name__exact='Smith')\n self.assertNumQueries(1, list, queryset)\n self.assertEqual(queryset.query.get_compiler(queryset.db).as_sql()[0].count('INNER JOIN'), 1)\n\n # The automatically joined table has a predictable name.\n self.assertQuerysetEqual(\n Article.objects.filter(reporter__first_name__exact='John').extra(\n where=[\"many_to_one_reporter.last_name='Smith'\"]),\n [\n \"<Article: John's second story>\",\n \"<Article: This is a test>\",\n ])\n # ... and should work fine with the unicode that comes out of forms.Form.cleaned_data\n self.assertQuerysetEqual(\n Article.objects.filter(reporter__first_name__exact='John'\n ).extra(where=[\"many_to_one_reporter.last_name='%s'\" % 'Smith']),\n [\n \"<Article: John's second story>\",\n \"<Article: This is a test>\",\n ])\n # Find all Articles for a Reporter.\n # Use direct ID check, pk check, and object comparison\n self.assertQuerysetEqual(\n Article.objects.filter(reporter__id__exact=self.r.id),\n [\n \"<Article: John's second story>\",\n \"<Article: This is a test>\",\n ])\n self.assertQuerysetEqual(\n Article.objects.filter(reporter__pk=self.r.id),\n [\n \"<Article: John's second story>\",\n \"<Article: This is a test>\",\n ])\n self.assertQuerysetEqual(\n Article.objects.filter(reporter=self.r.id),\n [\n \"<Article: John's second story>\",\n \"<Article: This is a test>\",\n ])\n self.assertQuerysetEqual(\n Article.objects.filter(reporter=self.r),\n [\n \"<Article: John's second story>\",\n \"<Article: This is a test>\",\n ])\n self.assertQuerysetEqual(\n Article.objects.filter(reporter__in=[self.r.id,self.r2.id]).distinct(),\n [\n \"<Article: John's second story>\",\n \"<Article: Paul's story>\",\n \"<Article: This is a test>\",\n ])\n self.assertQuerysetEqual(\n Article.objects.filter(reporter__in=[self.r,self.r2]).distinct(),\n [\n \"<Article: John's second story>\",\n \"<Article: Paul's story>\",\n \"<Article: This is a test>\",\n ])\n # You can also use a queryset instead of a literal list of instances.\n # The queryset must be reduced to a list of values using values(),\n # then converted into a query\n self.assertQuerysetEqual(\n Article.objects.filter(\n reporter__in=Reporter.objects.filter(first_name='John').values('pk').query\n ).distinct(),\n [\n \"<Article: John's second story>\",\n \"<Article: This is a test>\",\n ])", "metadata": "root.ManyToOneTests.test_selects", "header": "['class', 'ManyToOneTests', '(', 'TestCase', ')', ':', '___EOS___']", "index": 118 }, { "content": " def test_reverse_selects(self):\n a3 = Article.objects.create(id=None, headline=\"Third article\",\n pub_date=datetime(2005, 7, 27), reporter_id=self.r.id)\n a4 = Article.objects.create(id=None, headline=\"Fourth article\",\n pub_date=datetime(2005, 7, 27), reporter_id=str(self.r.id))\n # Reporters can be queried\n self.assertQuerysetEqual(Reporter.objects.filter(id__exact=self.r.id),\n [\"<Reporter: John Smith>\"])\n self.assertQuerysetEqual(Reporter.objects.filter(pk=self.r.id),\n [\"<Reporter: John Smith>\"])\n self.assertQuerysetEqual(Reporter.objects.filter(first_name__startswith='John'),\n [\"<Reporter: John Smith>\"])\n # Reporters can query in opposite direction of ForeignKey definition\n self.assertQuerysetEqual(Reporter.objects.filter(article__id__exact=self.a.id),\n [\"<Reporter: John Smith>\"])\n self.assertQuerysetEqual(Reporter.objects.filter(article__pk=self.a.id),\n [\"<Reporter: John Smith>\"])\n self.assertQuerysetEqual(Reporter.objects.filter(article=self.a.id),\n [\"<Reporter: John Smith>\"])\n self.assertQuerysetEqual(Reporter.objects.filter(article=self.a),\n [\"<Reporter: John Smith>\"])\n self.assertQuerysetEqual(\n Reporter.objects.filter(article__in=[self.a.id,a3.id]).distinct(),\n [\"<Reporter: John Smith>\"])\n self.assertQuerysetEqual(\n Reporter.objects.filter(article__in=[self.a.id,a3]).distinct(),\n [\"<Reporter: John Smith>\"])\n self.assertQuerysetEqual(\n Reporter.objects.filter(article__in=[self.a,a3]).distinct(),\n [\"<Reporter: John Smith>\"])\n self.assertQuerysetEqual(\n Reporter.objects.filter(article__headline__startswith='T'),\n [\"<Reporter: John Smith>\", \"<Reporter: John Smith>\"])\n self.assertQuerysetEqual(\n Reporter.objects.filter(article__headline__startswith='T').distinct(),\n [\"<Reporter: John Smith>\"])\n\n # Counting in the opposite direction works in conjunction with distinct()\n self.assertEqual(\n Reporter.objects.filter(article__headline__startswith='T').count(), 2)\n self.assertEqual(\n Reporter.objects.filter(article__headline__startswith='T').distinct().count(), 1)\n\n # Queries can go round in circles.\n self.assertQuerysetEqual(\n Reporter.objects.filter(article__reporter__first_name__startswith='John'),\n [\n \"<Reporter: John Smith>\",\n \"<Reporter: John Smith>\",\n \"<Reporter: John Smith>\",\n ])\n self.assertQuerysetEqual(\n Reporter.objects.filter(article__reporter__first_name__startswith='John').distinct(),\n [\"<Reporter: John Smith>\"])\n self.assertQuerysetEqual(\n Reporter.objects.filter(article__reporter__exact=self.r).distinct(),\n [\"<Reporter: John Smith>\"])\n\n # Check that implied __exact also works.\n self.assertQuerysetEqual(\n Reporter.objects.filter(article__reporter=self.r).distinct(),\n [\"<Reporter: John Smith>\"])\n\n # It's possible to use values() calls across many-to-one relations.\n # (Note, too, that we clear the ordering here so as not to drag the\n # 'headline' field into the columns being used to determine uniqueness)\n d = {'reporter__first_name': 'John', 'reporter__last_name': 'Smith'}\n self.assertEqual([d],\n list(Article.objects.filter(reporter=self.r).distinct().order_by()\n .values('reporter__first_name', 'reporter__last_name')))", "metadata": "root.ManyToOneTests.test_reverse_selects", "header": "['class', 'ManyToOneTests', '(', 'TestCase', ')', ':', '___EOS___']", "index": 237 }, { "content": " def test_select_related(self):\n # Check that Article.objects.select_related().dates() works properly when\n # there are multiple Articles with the same date but different foreign-key\n # objects (Reporters).\n r1 = Reporter.objects.create(first_name='Mike', last_name='Royko', email='[email protected]')\n r2 = Reporter.objects.create(first_name='John', last_name='Kass', email='[email protected]')\n a1 = Article.objects.create(headline='First', pub_date=datetime(1980, 4, 23), reporter=r1)\n a2 = Article.objects.create(headline='Second', pub_date=datetime(1980, 4, 23), reporter=r2)\n self.assertEqual(list(Article.objects.select_related().dates('pub_date', 'day')),\n [\n datetime(1980, 4, 23, 0, 0),\n datetime(2005, 7, 27, 0, 0),\n ])\n self.assertEqual(list(Article.objects.select_related().dates('pub_date', 'month')),\n [\n datetime(1980, 4, 1, 0, 0),\n datetime(2005, 7, 1, 0, 0),\n ])\n self.assertEqual(list(Article.objects.select_related().dates('pub_date', 'year')),\n [\n datetime(1980, 1, 1, 0, 0),\n datetime(2005, 1, 1, 0, 0),\n ])", "metadata": "root.ManyToOneTests.test_select_related", "header": "['class', 'ManyToOneTests', '(', 'TestCase', ')', ':', '___EOS___']", "index": 308 }, { "content": " def test_delete(self):\n new_article = self.r.article_set.create(headline=\"John's second story\",\n pub_date=datetime(2005, 7, 29))\n new_article2 = self.r2.article_set.create(headline=\"Paul's story\",\n pub_date=datetime(2006, 1, 17))\n a3 = Article.objects.create(id=None, headline=\"Third article\",\n pub_date=datetime(2005, 7, 27), reporter_id=self.r.id)\n a4 = Article.objects.create(id=None, headline=\"Fourth article\",\n pub_date=datetime(2005, 7, 27), reporter_id=str(self.r.id))\n # If you delete a reporter, his articles will be deleted.\n self.assertQuerysetEqual(Article.objects.all(),\n [\n \"<Article: Fourth article>\",\n \"<Article: John's second story>\",\n \"<Article: Paul's story>\",\n \"<Article: Third article>\",\n \"<Article: This is a test>\",\n ])\n self.assertQuerysetEqual(Reporter.objects.order_by('first_name'),\n [\n \"<Reporter: John Smith>\",\n \"<Reporter: Paul Jones>\",\n ])\n self.r2.delete()\n self.assertQuerysetEqual(Article.objects.all(),\n [\n \"<Article: Fourth article>\",\n \"<Article: John's second story>\",\n \"<Article: Third article>\",\n \"<Article: This is a test>\",\n ])\n self.assertQuerysetEqual(Reporter.objects.order_by('first_name'),\n [\"<Reporter: John Smith>\"])\n # You can delete using a JOIN in the query.\n Reporter.objects.filter(article__headline__startswith='This').delete()\n self.assertQuerysetEqual(Reporter.objects.all(), [])\n self.assertQuerysetEqual(Article.objects.all(), [])", "metadata": "root.ManyToOneTests.test_delete", "header": "['class', 'ManyToOneTests', '(', 'TestCase', ')', ':', '___EOS___']", "index": 332 } ]
[ { "span": "new_article ", "start_line": 119, "start_column": 8, "end_line": 119, "end_column": 19 }, { "span": "new_article2 ", "start_line": 121, "start_column": 8, "end_line": 121, "end_column": 20 }, { "span": "a4 ", "start_line": 240, "start_column": 8, "end_line": 240, "end_column": 10 }, { "span": "a1 ", "start_line": 314, "start_column": 8, "end_line": 314, "end_column": 10 }, { "span": "a2 ", "start_line": 315, "start_column": 8, "end_line": 315, "end_column": 10 }, { "span": "new_article ", "start_line": 333, "start_column": 8, "end_line": 333, "end_column": 19 }, { "span": "new_article2 ", "start_line": 335, "start_column": 8, "end_line": 335, "end_column": 20 }, { "span": "a3 ", "start_line": 337, "start_column": 8, "end_line": 337, "end_column": 10 }, { "span": "a4 ", "start_line": 339, "start_column": 8, "end_line": 339, "end_column": 10 } ]
[]
1
true
[ "[CLS]_", "Un", "used_", "local_", "variable_", "[SEP]_", "class_", "Many", "To", "One", "Tests_", "(_", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "select", "s_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "new", "\\u", "article_", "=_", "self_", "._", "r_", "._", "article", "\\u", "set_", "._", "create_", "(_", "headline", "_", "=_", "\"", "Joh", "n", "'", "s", " ", "second", " ", "stor", "y", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "pub", "\\u", "date_", "=_", "datetime_", "(_", "2005", "_", ",_", "7_", ",_", "29_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "new", "\\u", "article", "2_", "=_", "self_", "._", "r2_", "._", "article", "\\u", "set_", "._", "create_", "(_", "headline", "_", "=_", "\"", "Paul", "'", "s", " ", "stor", "y", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "pub", "\\u", "date_", "=_", "datetime_", "(_", "2006", "_", ",_", "1_", ",_", "17_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Reporte", "r", " ", "object", "s", " ", "have", " ", "access", " ", "to", " ", "thei", "r", " ", "relate", "d", " ", "Artic", "le", " ", "object", "s", "._", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "assert", "Query", "set", "Equal_", "(_", "self_", "._", "r_", "._", "article", "\\u", "set_", "._", "all_", "(_", ")_", ",_", "[_", "\\u\\u\\uNL\\u\\u\\u_", "\"<", "Artic", "le", ":", " ", "Joh", "n", "'", "s", " ", "second", " ", "stor", "y", ">\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"<", "Artic", "le", ":", " ", "Thi", "s", " ", "is", " ", "a", " ", "test", ">\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Query", "set", "Equal_", "(_", "self_", "._", "r_", "._", "article", "\\u", "set_", "._", "filter_", "(_", "headline", "\\u\\u", "startswith_", "=_", "'", "Thi", "s", "'_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "[_", "\"<", "Artic", "le", ":", " ", "Thi", "s", " ", "is", " ", "a", " ", "test", ">\"_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "self_", "._", "r_", "._", "article", "\\u", "set_", "._", "count_", "(_", ")_", ",_", "2_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "self_", "._", "r2_", "._", "article", "\\u", "set_", "._", "count_", "(_", ")_", ",_", "1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Get", " ", "article", "s", " ", "by", " ", "id_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "assert", "Query", "set", "Equal_", "(_", "Article_", "._", "objects_", "._", "filter_", "(_", "id", "\\u\\u", "exact_", "=_", "self_", "._", "a_", "._", "id_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "[_", "\"<", "Artic", "le", ":", " ", "Thi", "s", " ", "is", " ", "a", " ", "test", ">\"_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Query", "set", "Equal_", "(_", "Article_", "._", "objects_", "._", "filter_", "(_", "pk_", "=_", "self_", "._", "a_", "._", "id_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "[_", "\"<", "Artic", "le", ":", " ", "Thi", "s", " ", "is", " ", "a", " ", "test", ">\"_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Query", " ", "on", " ", "an", " ", "article", " ", "property_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "assert", "Query", "set", "Equal_", "(_", "Article_", "._", "objects_", "._", "filter_", "(_", "headline", "\\u\\u", "startswith_", "=_", "'", "Thi", "s", "'_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "[_", "\"<", "Artic", "le", ":", " ", "Thi", "s", " ", "is", " ", "a", " ", "test", ">\"_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "The", " ", "API", " ", "automati", "call", "y", " ", "follow", "s", " ", "relation", "ships", " ", "as", " ", "far", " ", "as", " ", "you", " ", "need", "._", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Us", "e", " ", "double", " ", "underscore", "s", " ", "to", " ", "separate", " ", "relation", "ships", "._", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Thi", "s", " ", "works", " ", "as", " ", "many", " ", "level", "s", " ", "deep", " ", "as", " ", "you", " ", "want", ".", " ", "There", "'", "s", " ", "no", " ", "limit", "._", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Fin", "d", " ", "all", " ", "Artic", "les", " ", "for", " ", "any", " ", "Reporte", "r", " ", "who", "se", " ", "first", " ", "name", " ", "is", " ", "\"", "Joh", "n", "\".", "_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "assert", "Query", "set", "Equal_", "(_", "Article_", "._", "objects_", "._", "filter_", "(_", "reporter", "\\u\\u", "first", "\\u", "name", "\\u\\u", "exact_", "=_", "'", "Joh", "n", "'_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "[_", "\\u\\u\\uNL\\u\\u\\u_", "\"<", "Artic", "le", ":", " ", "Joh", "n", "'", "s", " ", "second", " ", "stor", "y", ">\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"<", "Artic", "le", ":", " ", "Thi", "s", " ", "is", " ", "a", " ", "test", ">\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Check", " ", "tha", "t", " ", "impli", "ed", " ", "\\u\\u", "exact", " ", "als", "o", " ", "works_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "assert", "Query", "set", "Equal_", "(_", "Article_", "._", "objects_", "._", "filter_", "(_", "reporter", "\\u\\u", "first", "\\u", "name_", "=_", "'", "Joh", "n", "'_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "[_", "\\u\\u\\uNL\\u\\u\\u_", "\"<", "Artic", "le", ":", " ", "Joh", "n", "'", "s", " ", "second", " ", "stor", "y", ">\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"<", "Artic", "le", ":", " ", "Thi", "s", " ", "is", " ", "a", " ", "test", ">\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Query", " ", "twi", "ce", " ", "over", " ", "the", " ", "relate", "d", " ", "field", "._", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "assert", "Query", "set", "Equal_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "Article_", "._", "objects_", "._", "filter_", "(_", "reporter", "\\u\\u", "first", "\\u", "name", "\\u\\u", "exact_", "=_", "'", "Joh", "n", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "reporter", "\\u\\u", "last", "\\u", "name", "\\u\\u", "exact_", "=_", "'", "Smi", "th", "'_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "[_", "\\u\\u\\uNL\\u\\u\\u_", "\"<", "Artic", "le", ":", " ", "Joh", "n", "'", "s", " ", "second", " ", "stor", "y", ">\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"<", "Artic", "le", ":", " ", "Thi", "s", " ", "is", " ", "a", " ", "test", ">\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "The", " ", "underl", "ying", " ", "query", " ", "only", " ", "make", "s", " ", "one", " ", "join", " ", "whe", "n", " ", "a", " ", "relate", "d", " ", "table", " ", "is", " ", "referenced", " ", "twi", "ce", "._", "\\u\\u\\uNL\\u\\u\\u_", "queryset_", "=_", "Article_", "._", "objects_", "._", "filter_", "(_", "reporter", "\\u\\u", "first", "\\u", "name", "\\u\\u", "exact_", "=_", "'", "Joh", "n", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "reporter", "\\u\\u", "last", "\\u", "name", "\\u\\u", "exact_", "=_", "'", "Smi", "th", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Num", "Querie", "s_", "(_", "1_", ",_", "list_", ",_", "queryset_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "queryset_", "._", "query_", "._", "get", "\\u", "compiler_", "(_", "queryset_", "._", "db_", ")_", "._", "as", "\\u", "sql_", "(_", ")_", "[_", "0_", "]_", "._", "count_", "(_", "'", "INN", "ER", " ", "JOIN", "'_", ")_", ",_", "1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "The", " ", "automati", "call", "y", " ", "joine", "d", " ", "table", " ", "has", " ", "a", " ", "predi", "ctab", "le", " ", "name", "._", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "assert", "Query", "set", "Equal_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "Article_", "._", "objects_", "._", "filter_", "(_", "reporter", "\\u\\u", "first", "\\u", "name", "\\u\\u", "exact_", "=_", "'", "Joh", "n", "'_", ")_", "._", "extra_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "where_", "=_", "[_", "\"", "many", "\\u", "to", "\\u", "one", "\\u", "reporter", ".", "last", "\\u", "name", "='", "Smi", "th", "'\"_", "]_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "[_", "\\u\\u\\uNL\\u\\u\\u_", "\"<", "Artic", "le", ":", " ", "Joh", "n", "'", "s", " ", "second", " ", "stor", "y", ">\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"<", "Artic", "le", ":", " ", "Thi", "s", " ", "is", " ", "a", " ", "test", ">\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "...", " ", "and", " ", "shou", "ld", " ", "work", " ", "fine", " ", "with", " ", "the", " ", "unicode", " ", "tha", "t", " ", "come", "s", " ", "out", " ", "of", " ", "forms", ".", "Form", ".", "clean", "ed", "\\u", "data_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "assert", "Query", "set", "Equal_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "Article_", "._", "objects_", "._", "filter_", "(_", "reporter", "\\u\\u", "first", "\\u", "name", "\\u\\u", "exact_", "=_", "'", "Joh", "n", "'_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "._", "extra_", "(_", "where_", "=_", "[_", "\"", "many", "\\u", "to", "\\u", "one", "\\u", "reporter", ".", "last", "\\u", "name", "='", "%", "s", "'\"_", "%_", "'", "Smi", "th", "'_", "]_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "[_", "\\u\\u\\uNL\\u\\u\\u_", "\"<", "Artic", "le", ":", " ", "Joh", "n", "'", "s", " ", "second", " ", "stor", "y", ">\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"<", "Artic", "le", ":", " ", "Thi", "s", " ", "is", " ", "a", " ", "test", ">\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Fin", "d", " ", "all", " ", "Artic", "les", " ", "for", " ", "a", " ", "Reporte", "r", "._", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Us", "e", " ", "direct", " ", "ID", " ", "check", ",", " ", "pk", " ", "check", ",", " ", "and", " ", "object", " ", "comparison_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "assert", "Query", "set", "Equal_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "Article_", "._", "objects_", "._", "filter_", "(_", "reporter", "\\u\\u", "id", "\\u\\u", "exact_", "=_", "self_", "._", "r_", "._", "id_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "[_", "\\u\\u\\uNL\\u\\u\\u_", "\"<", "Artic", "le", ":", " ", "Joh", "n", "'", "s", " ", "second", " ", "stor", "y", ">\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"<", "Artic", "le", ":", " ", "Thi", "s", " ", "is", " ", "a", " ", "test", ">\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Query", "set", "Equal_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "Article_", "._", "objects_", "._", "filter_", "(_", "reporter", "\\u\\u", "pk_", "=_", "self_", "._", "r_", "._", "id_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "[_", "\\u\\u\\uNL\\u\\u\\u_", "\"<", "Artic", "le", ":", " ", "Joh", "n", "'", "s", " ", "second", " ", "stor", "y", ">\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"<", "Artic", "le", ":", " ", "Thi", "s", " ", "is", " ", "a", " ", "test", ">\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Query", "set", "Equal_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "Article_", "._", "objects_", "._", "filter_", "(_", "reporter_", "=_", "self_", "._", "r_", "._", "id_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "[_", "\\u\\u\\uNL\\u\\u\\u_", "\"<", "Artic", "le", ":", " ", "Joh", "n", "'", "s", " ", "second", " ", "stor", "y", ">\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"<", "Artic", "le", ":", " ", "Thi", "s", " ", "is", " ", "a", " ", "test", ">\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Query", "set", "Equal_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "Article_", "._", "objects_", "._", "filter_", "(_", "reporter_", "=_", "self_", "._", "r_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "[_", "\\u\\u\\uNL\\u\\u\\u_", "\"<", "Artic", "le", ":", " ", "Joh", "n", "'", "s", " ", "second", " ", "stor", "y", ">\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"<", "Artic", "le", ":", " ", "Thi", "s", " ", "is", " ", "a", " ", "test", ">\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Query", "set", "Equal_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "Article_", "._", "objects_", "._", "filter_", "(_", "reporter", "\\u\\u", "in_", "=_", "[_", "self_", "._", "r_", "._", "id_", ",_", "self_", "._", "r2_", "._", "id_", "]_", ")_", "._", "distinct_", "(_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "[_", "\\u\\u\\uNL\\u\\u\\u_", "\"<", "Artic", "le", ":", " ", "Joh", "n", "'", "s", " ", "second", " ", "stor", "y", ">\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"<", "Artic", "le", ":", " ", "Paul", "'", "s", " ", "stor", "y", ">\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"<", "Artic", "le", ":", " ", "Thi", "s", " ", "is", " ", "a", " ", "test", ">\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Query", "set", "Equal_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "Article_", "._", "objects_", "._", "filter_", "(_", "reporter", "\\u\\u", "in_", "=_", "[_", "self_", "._", "r_", ",_", "self_", "._", "r2_", "]_", ")_", "._", "distinct_", "(_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "[_", "\\u\\u\\uNL\\u\\u\\u_", "\"<", "Artic", "le", ":", " ", "Joh", "n", "'", "s", " ", "second", " ", "stor", "y", ">\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"<", "Artic", "le", ":", " ", "Paul", "'", "s", " ", "stor", "y", ">\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"<", "Artic", "le", ":", " ", "Thi", "s", " ", "is", " ", "a", " ", "test", ">\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "You", " ", "can", " ", "als", "o", " ", "use", " ", "a", " ", "querys", "et", " ", "inst", "ead", " ", "of", " ", "a", " ", "literal", " ", "list", " ", "of", " ", "instance", "s", "._", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "The", " ", "querys", "et", " ", "must", " ", "be", " ", "reduce", "d", " ", "to", " ", "a", " ", "list", " ", "of", " ", "values", " ", "usi", "ng", " ", "values", "()", ",_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "then", " ", "convert", "ed", " ", "int", "o", " ", "a", " ", "query_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "assert", "Query", "set", "Equal_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "Article_", "._", "objects_", "._", "filter_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "reporter", "\\u\\u", "in_", "=_", "Reporter_", "._", "objects_", "._", "filter_", "(_", "first", "\\u", "name_", "=_", "'", "Joh", "n", "'_", ")_", "._", "values_", "(_", "'", "pk", "'_", ")_", "._", "query_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "._", "distinct_", "(_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "[_", "\\u\\u\\uNL\\u\\u\\u_", "\"<", "Artic", "le", ":", " ", "Joh", "n", "'", "s", " ", "second", " ", "stor", "y", ">\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"<", "Artic", "le", ":", " ", "Thi", "s", " ", "is", " ", "a", " ", "test", ">\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Many", "To", "One", "Tests_", "(_", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "reverse", "\\u", "select", "s_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "a3_", "=_", "Article_", "._", "objects_", "._", "create_", "(_", "id_", "=_", "None_", ",_", "headline", "_", "=_", "\"", "Thi", "rd", " ", "article", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "pub", "\\u", "date_", "=_", "datetime_", "(_", "2005", "_", ",_", "7_", ",_", "27_", ")_", ",_", "reporter", "\\u", "id_", "=_", "self_", "._", "r_", "._", "id_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "a4_", "=_", "Article_", "._", "objects_", "._", "create_", "(_", "id_", "=_", "None_", ",_", "headline", "_", "=_", "\"", "Four", "th", " ", "article", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "pub", "\\u", "date_", "=_", "datetime_", "(_", "2005", "_", ",_", "7_", ",_", "27_", ")_", ",_", "reporter", "\\u", "id_", "=_", "str_", "(_", "self_", "._", "r_", "._", "id_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Reporte", "rs", " ", "can", " ", "be", " ", "queried", "_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "assert", "Query", "set", "Equal_", "(_", "Reporter_", "._", "objects_", "._", "filter_", "(_", "id", "\\u\\u", "exact_", "=_", "self_", "._", "r_", "._", "id_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "[_", "\"<", "Reporte", "r", ":", " ", "Joh", "n", " ", "Smi", "th", ">\"_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Query", "set", "Equal_", "(_", "Reporter_", "._", "objects_", "._", "filter_", "(_", "pk_", "=_", "self_", "._", "r_", "._", "id_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "[_", "\"<", "Reporte", "r", ":", " ", "Joh", "n", " ", "Smi", "th", ">\"_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Query", "set", "Equal_", "(_", "Reporter_", "._", "objects_", "._", "filter_", "(_", "first", "\\u", "name", "\\u\\u", "startswith_", "=_", "'", "Joh", "n", "'_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "[_", "\"<", "Reporte", "r", ":", " ", "Joh", "n", " ", "Smi", "th", ">\"_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Reporte", "rs", " ", "can", " ", "query", " ", "in", " ", "opposite", " ", "direction", " ", "of", " ", "Fore", "ign", "Key", " ", "definition_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "assert", "Query", "set", "Equal_", "(_", "Reporter_", "._", "objects_", "._", "filter_", "(_", "article", "\\u\\u", "id", "\\u\\u", "exact_", "=_", "self_", "._", "a_", "._", "id_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "[_", "\"<", "Reporte", "r", ":", " ", "Joh", "n", " ", "Smi", "th", ">\"_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Query", "set", "Equal_", "(_", "Reporter_", "._", "objects_", "._", "filter_", "(_", "article", "\\u\\u", "pk_", "=_", "self_", "._", "a_", "._", "id_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "[_", "\"<", "Reporte", "r", ":", " ", "Joh", "n", " ", "Smi", "th", ">\"_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Query", "set", "Equal_", "(_", "Reporter_", "._", "objects_", "._", "filter_", "(_", "article_", "=_", "self_", "._", "a_", "._", "id_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "[_", "\"<", "Reporte", "r", ":", " ", "Joh", "n", " ", "Smi", "th", ">\"_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Query", "set", "Equal_", "(_", "Reporter_", "._", "objects_", "._", "filter_", "(_", "article_", "=_", "self_", "._", "a_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "[_", "\"<", "Reporte", "r", ":", " ", "Joh", "n", " ", "Smi", "th", ">\"_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Query", "set", "Equal_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "Reporter_", "._", "objects_", "._", "filter_", "(_", "article", "\\u\\u", "in_", "=_", "[_", "self_", "._", "a_", "._", "id_", ",_", "a3_", "._", "id_", "]_", ")_", "._", "distinct_", "(_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "[_", "\"<", "Reporte", "r", ":", " ", "Joh", "n", " ", "Smi", "th", ">\"_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Query", "set", "Equal_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "Reporter_", "._", "objects_", "._", "filter_", "(_", "article", "\\u\\u", "in_", "=_", "[_", "self_", "._", "a_", "._", "id_", ",_", "a3_", "]_", ")_", "._", "distinct_", "(_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "[_", "\"<", "Reporte", "r", ":", " ", "Joh", "n", " ", "Smi", "th", ">\"_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Query", "set", "Equal_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "Reporter_", "._", "objects_", "._", "filter_", "(_", "article", "\\u\\u", "in_", "=_", "[_", "self_", "._", "a_", ",_", "a3_", "]_", ")_", "._", "distinct_", "(_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "[_", "\"<", "Reporte", "r", ":", " ", "Joh", "n", " ", "Smi", "th", ">\"_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Query", "set", "Equal_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "Reporter_", "._", "objects_", "._", "filter_", "(_", "article", "\\u\\u", "headline", "\\u\\u", "startswith_", "=_", "'", "T", "'_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "[_", "\"<", "Reporte", "r", ":", " ", "Joh", "n", " ", "Smi", "th", ">\"_", ",_", "\"<", "Reporte", "r", ":", " ", "Joh", "n", " ", "Smi", "th", ">\"_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Query", "set", "Equal_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "Reporter_", "._", "objects_", "._", "filter_", "(_", "article", "\\u\\u", "headline", "\\u\\u", "startswith_", "=_", "'", "T", "'_", ")_", "._", "distinct_", "(_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "[_", "\"<", "Reporte", "r", ":", " ", "Joh", "n", " ", "Smi", "th", ">\"_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Count", "ing", " ", "in", " ", "the", " ", "opposite", " ", "direction", " ", "works", " ", "in", " ", "conjunction", " ", "with", " ", "distinct", "()", "_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "Reporter_", "._", "objects_", "._", "filter_", "(_", "article", "\\u\\u", "headline", "\\u\\u", "startswith_", "=_", "'", "T", "'_", ")_", "._", "count_", "(_", ")_", ",_", "2_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "Reporter_", "._", "objects_", "._", "filter_", "(_", "article", "\\u\\u", "headline", "\\u\\u", "startswith_", "=_", "'", "T", "'_", ")_", "._", "distinct_", "(_", ")_", "._", "count_", "(_", ")_", ",_", "1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Querie", "s", " ", "can", " ", "go", " ", "round", " ", "in", " ", "circles", "._", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "assert", "Query", "set", "Equal_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "Reporter_", "._", "objects_", "._", "filter_", "(_", "article", "\\u\\u", "reporter", "\\u\\u", "first", "\\u", "name", "\\u\\u", "startswith_", "=_", "'", "Joh", "n", "'_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "[_", "\\u\\u\\uNL\\u\\u\\u_", "\"<", "Reporte", "r", ":", " ", "Joh", "n", " ", "Smi", "th", ">\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"<", "Reporte", "r", ":", " ", "Joh", "n", " ", "Smi", "th", ">\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"<", "Reporte", "r", ":", " ", "Joh", "n", " ", "Smi", "th", ">\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Query", "set", "Equal_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "Reporter_", "._", "objects_", "._", "filter_", "(_", "article", "\\u\\u", "reporter", "\\u\\u", "first", "\\u", "name", "\\u\\u", "startswith_", "=_", "'", "Joh", "n", "'_", ")_", "._", "distinct_", "(_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "[_", "\"<", "Reporte", "r", ":", " ", "Joh", "n", " ", "Smi", "th", ">\"_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Query", "set", "Equal_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "Reporter_", "._", "objects_", "._", "filter_", "(_", "article", "\\u\\u", "reporter", "\\u\\u", "exact_", "=_", "self_", "._", "r_", ")_", "._", "distinct_", "(_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "[_", "\"<", "Reporte", "r", ":", " ", "Joh", "n", " ", "Smi", "th", ">\"_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Check", " ", "tha", "t", " ", "impli", "ed", " ", "\\u\\u", "exact", " ", "als", "o", " ", "works", "._", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "assert", "Query", "set", "Equal_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "Reporter_", "._", "objects_", "._", "filter_", "(_", "article", "\\u\\u", "reporter_", "=_", "self_", "._", "r_", ")_", "._", "distinct_", "(_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "[_", "\"<", "Reporte", "r", ":", " ", "Joh", "n", " ", "Smi", "th", ">\"_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "It", "'", "s", " ", "possib", "le", " ", "to", " ", "use", " ", "values", "()", " ", "calls", " ", "acro", "ss", " ", "many", "-", "to", "-", "one", " ", "relation", "s", "._", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "(", "Not", "e", ",", " ", "too", ",", " ", "tha", "t", " ", "we", " ", "clear", " ", "the", " ", "orderi", "ng", " ", "here", " ", "so", " ", "as", " ", "not", " ", "to", " ", "drag", " ", "the_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "'", "headline", "'", " ", "field", " ", "int", "o", " ", "the", " ", "column", "s", " ", "bei", "ng", " ", "used", " ", "to", " ", "dete", "rmin", "e", " ", "unique", "ness", ")_", "\\u\\u\\uNL\\u\\u\\u_", "d_", "=_", "{_", "'", "reporter", "\\u\\u", "first", "\\u", "name", "'_", ":_", "'", "Joh", "n", "'_", ",_", "'", "reporter", "\\u\\u", "last", "\\u", "name", "'_", ":_", "'", "Smi", "th", "'_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "[_", "d_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "list_", "(_", "Article_", "._", "objects_", "._", "filter_", "(_", "reporter_", "=_", "self_", "._", "r_", ")_", "._", "distinct_", "(_", ")_", "._", "order", "\\u", "by_", "(_", ")_", "\\u\\u\\uNL\\u\\u\\u_", "._", "values_", "(_", "'", "reporter", "\\u\\u", "first", "\\u", "name", "'_", ",_", "'", "reporter", "\\u\\u", "last", "\\u", "name", "'_", ")_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Many", "To", "One", "Tests_", "(_", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "select", "\\u", "related_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Check", " ", "tha", "t", " ", "Artic", "le", ".", "object", "s", ".", "select", "\\u", "relate", "d", "()", ".", "dates", "()", " ", "works", " ", "proper", "ly", " ", "when_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "there", " ", "are", " ", "multiple", " ", "Artic", "les", " ", "with", " ", "the", " ", "same", " ", "date", " ", "but", " ", "different", " ", "foreign", "-", "key_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "object", "s", " ", "(", "Reporte", "rs", ").", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "r1_", "=_", "Reporter_", "._", "objects_", "._", "create_", "(_", "first", "\\u", "name_", "=_", "'", "Mik", "e", "'_", ",_", "last", "\\u", "name_", "=_", "'", "Ro", "yk", "o", "'_", ",_", "email_", "=_", "'", "roy", "ko", "@", "sun", "times", ".", "com", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "r2_", "=_", "Reporter_", "._", "objects_", "._", "create_", "(_", "first", "\\u", "name_", "=_", "'", "Joh", "n", "'_", ",_", "last", "\\u", "name_", "=_", "'", "Kas", "s", "'_", ",_", "email_", "=_", "'", "jk", "ass", "@", "trib", "une", ".", "com", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "a1_", "=_", "Article_", "._", "objects_", "._", "create_", "(_", "headline", "_", "=_", "'", "Fi", "rst", "'_", ",_", "pub", "\\u", "date_", "=_", "datetime_", "(_", "1980", "_", ",_", "4_", ",_", "23_", ")_", ",_", "reporter_", "=_", "r1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "a2_", "=_", "Article_", "._", "objects_", "._", "create_", "(_", "headline", "_", "=_", "'", "Second", "'_", ",_", "pub", "\\u", "date_", "=_", "datetime_", "(_", "1980", "_", ",_", "4_", ",_", "23_", ")_", ",_", "reporter_", "=_", "r2_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "list_", "(_", "Article_", "._", "objects_", "._", "select", "\\u", "related_", "(_", ")_", "._", "dates_", "(_", "'", "pub", "\\u", "date", "'_", ",_", "'", "day", "'_", ")_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "[_", "\\u\\u\\uNL\\u\\u\\u_", "datetime_", "(_", "1980", "_", ",_", "4_", ",_", "23_", ",_", "0_", ",_", "0_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "datetime_", "(_", "2005", "_", ",_", "7_", ",_", "27_", ",_", "0_", ",_", "0_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "list_", "(_", "Article_", "._", "objects_", "._", "select", "\\u", "related_", "(_", ")_", "._", "dates_", "(_", "'", "pub", "\\u", "date", "'_", ",_", "'", "month", "'_", ")_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "[_", "\\u\\u\\uNL\\u\\u\\u_", "datetime_", "(_", "1980", "_", ",_", "4_", ",_", "1_", ",_", "0_", ",_", "0_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "datetime_", "(_", "2005", "_", ",_", "7_", ",_", "1_", ",_", "0_", ",_", "0_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "list_", "(_", "Article_", "._", "objects_", "._", "select", "\\u", "related_", "(_", ")_", "._", "dates_", "(_", "'", "pub", "\\u", "date", "'_", ",_", "'", "year", "'_", ")_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "[_", "\\u\\u\\uNL\\u\\u\\u_", "datetime_", "(_", "1980", "_", ",_", "1_", ",_", "1_", ",_", "0_", ",_", "0_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "datetime_", "(_", "2005", "_", ",_", "1_", ",_", "1_", ",_", "0_", ",_", "0_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Many", "To", "One", "Tests_", "(_", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "delete_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "new", "\\u", "article_", "=_", "self_", "._", "r_", "._", "article", "\\u", "set_", "._", "create_", "(_", "headline", "_", "=_", "\"", "Joh", "n", "'", "s", " ", "second", " ", "stor", "y", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "pub", "\\u", "date_", "=_", "datetime_", "(_", "2005", "_", ",_", "7_", ",_", "29_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "new", "\\u", "article", "2_", "=_", "self_", "._", "r2_", "._", "article", "\\u", "set_", "._", "create_", "(_", "headline", "_", "=_", "\"", "Paul", "'", "s", " ", "stor", "y", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "pub", "\\u", "date_", "=_", "datetime_", "(_", "2006", "_", ",_", "1_", ",_", "17_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "a3_", "=_", "Article_", "._", "objects_", "._", "create_", "(_", "id_", "=_", "None_", ",_", "headline", "_", "=_", "\"", "Thi", "rd", " ", "article", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "pub", "\\u", "date_", "=_", "datetime_", "(_", "2005", "_", ",_", "7_", ",_", "27_", ")_", ",_", "reporter", "\\u", "id_", "=_", "self_", "._", "r_", "._", "id_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "a4_", "=_", "Article_", "._", "objects_", "._", "create_", "(_", "id_", "=_", "None_", ",_", "headline", "_", "=_", "\"", "Four", "th", " ", "article", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "pub", "\\u", "date_", "=_", "datetime_", "(_", "2005", "_", ",_", "7_", ",_", "27_", ")_", ",_", "reporter", "\\u", "id_", "=_", "str_", "(_", "self_", "._", "r_", "._", "id_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "If", " ", "you", " ", "delete", " ", "a", " ", "reporter", ",", " ", "his", " ", "article", "s", " ", "will", " ", "be", " ", "delete", "d", "._", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "assert", "Query", "set", "Equal_", "(_", "Article_", "._", "objects_", "._", "all_", "(_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "[_", "\\u\\u\\uNL\\u\\u\\u_", "\"<", "Artic", "le", ":", " ", "Four", "th", " ", "article", ">\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"<", "Artic", "le", ":", " ", "Joh", "n", "'", "s", " ", "second", " ", "stor", "y", ">\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"<", "Artic", "le", ":", " ", "Paul", "'", "s", " ", "stor", "y", ">\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"<", "Artic", "le", ":", " ", "Thi", "rd", " ", "article", ">\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"<", "Artic", "le", ":", " ", "Thi", "s", " ", "is", " ", "a", " ", "test", ">\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Query", "set", "Equal_", "(_", "Reporter_", "._", "objects_", "._", "order", "\\u", "by_", "(_", "'", "first", "\\u", "name", "'_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "[_", "\\u\\u\\uNL\\u\\u\\u_", "\"<", "Reporte", "r", ":", " ", "Joh", "n", " ", "Smi", "th", ">\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"<", "Reporte", "r", ":", " ", "Paul", " ", "Jones", ">\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "r2_", "._", "delete_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Query", "set", "Equal_", "(_", "Article_", "._", "objects_", "._", "all_", "(_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "[_", "\\u\\u\\uNL\\u\\u\\u_", "\"<", "Artic", "le", ":", " ", "Four", "th", " ", "article", ">\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"<", "Artic", "le", ":", " ", "Joh", "n", "'", "s", " ", "second", " ", "stor", "y", ">\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"<", "Artic", "le", ":", " ", "Thi", "rd", " ", "article", ">\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"<", "Artic", "le", ":", " ", "Thi", "s", " ", "is", " ", "a", " ", "test", ">\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Query", "set", "Equal_", "(_", "Reporter_", "._", "objects_", "._", "order", "\\u", "by_", "(_", "'", "first", "\\u", "name", "'_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "[_", "\"<", "Reporte", "r", ":", " ", "Joh", "n", " ", "Smi", "th", ">\"_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "You", " ", "can", " ", "delete", " ", "usi", "ng", " ", "a", " ", "JOIN", " ", "in", " ", "the", " ", "query", "._", "\\u\\u\\uNL\\u\\u\\u_", "Reporter_", "._", "objects_", "._", "filter_", "(_", "article", "\\u\\u", "headline", "\\u\\u", "startswith_", "=_", "'", "Thi", "s", "'_", ")_", "._", "delete_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Query", "set", "Equal_", "(_", "Reporter_", "._", "objects_", "._", "all_", "(_", ")_", ",_", "[_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Query", "set", "Equal_", "(_", "Article_", "._", "objects_", "._", "all_", "(_", ")_", ",_", "[_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_" ]
[ 4, 4, 4, 4, 4, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 ]
Unused import
AppScale/appscale/AppServer/lib/concurrent/concurrent/futures/__init__.py
[ { "content": "# Copyright 2009 Brian Quinlan. All Rights Reserved.\n# Licensed to PSF under a Contributor Agreement.\n\n\"\"\"Execute computations asynchronously using threads or processes.\"\"\"\n\n__author__ = 'Brian Quinlan ([email protected])'\n\nfrom concurrent.futures._base import (FIRST_COMPLETED,\n FIRST_EXCEPTION,\n ALL_COMPLETED,\n CancelledError,\n TimeoutError,\n Future,\n Executor,\n wait,\n as_completed)\nfrom concurrent.futures.process import ProcessPoolExecutor\nfrom concurrent.futures.thread import ThreadPoolExecutor\n", "metadata": "root", "header": "['module', '___EOS___']", "index": 0 } ]
[ { "span": "from concurrent.futures._base import (FIRST_COMPLETED,\n FIRST_EXCEPTION,\n ALL_COMPLETED,\n CancelledError,\n TimeoutError,\n Future,\n Executor,\n wait,\n as_completed)", "start_line": 7, "start_column": 0, "end_line": 15, "end_column": 51 }, { "span": "from concurrent.futures.process import ProcessPoolExecutor", "start_line": 16, "start_column": 0, "end_line": 16, "end_column": 58 }, { "span": "from concurrent.futures.thread import ThreadPoolExecutor", "start_line": 17, "start_column": 0, "end_line": 17, "end_column": 56 } ]
[]
1
false
[ "[CLS]_", "Un", "used_", "import_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "#", " ", "Copy", "right", " ", "200", "9", " ", "Brian", " ", "Qui", "nla", "n", ".", " ", "All", " ", "Rig", "hts", " ", "Reserve", "d", "._", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "License", "d", " ", "to", " ", "PSF", " ", "under", " ", "a", " ", "Contributor", " ", "Agreement", "._", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\"\"\"", "Execut", "e", " ", "computation", "s", " ", "async", "hronous", "ly", " ", "usi", "ng", " ", "thread", "s", " ", "or", " ", "process", "es", ".\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u", "author\\u\\u_", "=_", "'", "Brian", " ", "Qui", "nla", "n", " ", "(", "bri", "an", "@", "swe", "eta", "pp", ".", "com", ")'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "from_", "concurrent_", "._", "futures_", "._", "\\u", "base_", "import_", "(_", "FIR", "ST", "\\u", "COMPLETED", "_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "FIR", "ST", "\\u", "EXCEPTION_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "ALL", "\\u", "COMPLETED", "_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "Cancel", "led", "Error_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "Time", "out", "Error_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "Future_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "Executor_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "wait_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "as", "\\u", "completed_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "concurrent_", "._", "futures_", "._", "process_", "import_", "Process", "Poo", "l", "Executor_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "concurrent_", "._", "futures_", "._", "thread_", "import_", "Thread", "Poo", "l", "Executor_" ]
[ 4, 4, 4, 4, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
Unused local variable
evfredericksen/pynacea/pynhost/pynhost/commands.py
[ { "content": "def new_action_list(raw_actions, rule_match=None):\n words = rule_match.matched_words if rule_match else ()\n new_actions = []\n for action in raw_actions:\n if isinstance(action, dynamic.Num):\n action = action.evaluate(rule_match)\n elif isinstance (action, (list, tuple)):\n func = action[0]\n for action in self.actions:\n if not isinstance(action, (int, dynamic.RepeatCommand)):\n return True\n return False\n\n def __str__(self):\n return '<ActionList matching words {}>'.format(' '.join(self.matched_words))\n\n def __repr__(self):\n return str(self)", "metadata": "root.new_action_list", "header": "['module', '___EOS___']", "index": 81 } ]
[ { "span": "words ", "start_line": 82, "start_column": 4, "end_line": 82, "end_column": 9 }, { "span": "new_actions ", "start_line": 83, "start_column": 4, "end_line": 83, "end_column": 15 }, { "span": "func ", "start_line": 88, "start_column": 12, "end_line": 88, "end_column": 16 } ]
[]
1
true
[ "[CLS]_", "Un", "used_", "local_", "variable_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "new", "\\u", "action", "\\u", "list_", "(_", "raw", "\\u", "actions_", ",_", "rule", "\\u", "match_", "=_", "None_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "words_", "=_", "rule", "\\u", "match_", "._", "matche", "d\\u", "words_", "if_", "rule", "\\u", "match_", "else_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "new", "\\u", "actions_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "action_", "in_", "raw", "\\u", "actions_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "isinstance_", "(_", "action_", ",_", "dynamic_", "._", "Num_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "action_", "=_", "action_", "._", "evaluate_", "(_", "rule", "\\u", "match_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "isinstance_", "(_", "action_", ",_", "(_", "list_", ",_", "tuple_", ")_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "func_", "=_", "action_", "[_", "0_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "for_", "action_", "in_", "self_", "._", "actions_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "not_", "isinstance_", "(_", "action_", ",_", "(_", "int_", ",_", "dynamic_", "._", "Repeat", "Command_", ")_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "\\u\\u", "str\\u\\u_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "'<", "Action", "List", " ", "matchi", "ng", " ", "words", " ", "{}>", "'_", "._", "format_", "(_", "'", " ", "'_", "._", "join_", "(_", "self_", "._", "matche", "d\\u", "words_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "\\u\\u", "repr\\u\\u_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "str_", "(_", "self_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_" ]
[ 4, 4, 4, 4, 4, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 ]
Except block handles 'BaseException'
ufora/ufora/ufora/distributed/SharedState/SharedState_test.py
[ { "content": " def clientThread(self, harness, passIndex, threadIndex, totalThreadCount,\n successList, failureList, connectedThreads, connectedThreadEvent,\n viewList,\n blockUntilConnected\n ):\n try:\n logging.info(\"Connecting to SharedState in thread %s\", threadIndex)\n try:\n view = harness.newView()\n viewList.append(view)\n finally:\n connectedThreads.append(threadIndex)\n\n if len(connectedThreads) == totalThreadCount:\n connectedThreadEvent.set()\n logging.debug(\"All reconnection test threads have connected.\")\n\n\n if blockUntilConnected:\n connectedThreadEvent.wait()\n\n logging.info(\"Have view in thread %s\", threadIndex)\n\n logging.info(\"Connected to shared state in thread %s\", threadIndex)\n\n harness.subscribeToKeyspace(view, NativeJson.Json(\"data\"))\n\n harness.writeToKeyspace(\n view,\n NativeJson.Json(\"data\"),\n NativeJson.Json(str(threadIndex)),\n NativeJson.Json(str(passIndex))\n )\n\n t0 = time.time()\n\n while True:\n itemDict = dict(harness.getAllItemsFromView(view, NativeJson.Json(\"data\")))\n\n allAreCurPass = True\n if len(itemDict) == totalThreadCount:\n for i in itemDict:\n if itemDict[i] != NativeJson.Json(str(passIndex)):\n allAreCurPass = False\n\n if allAreCurPass:\n successList.append(threadIndex)\n return\n\n time.sleep(.01)\n if time.time() - t0 > 5.0:\n failureList.append(\"Bad dict: %s\" % itemDict)\n return\n\n view.flush()\n except:\n failureList.append(\"Exception: \" + traceback.format_exc())", "metadata": "root.TestSharedState.clientThread", "header": "['class', 'TestSharedState', '(', 'unittest', '.', 'TestCase', ')', ':', '___EOS___']", "index": 35 }, { "content": " def test_file_management(self):\n tempDir = tempfile.mkdtemp()\n\n curOpenFiles = len(os.listdir('/proc/%s/fd' % os.getpid()))\n\n OPEN_FILE_LIMIT = 200\n\n if curOpenFiles >= OPEN_FILE_LIMIT:\n os.system(\"ls -alh /proc/%s/fd\" % os.getpid())\n\n self.assertTrue(curOpenFiles < OPEN_FILE_LIMIT, \"Too many open files: %s\" % curOpenFiles)\n\n soft, hard = resource.getrlimit(resource.RLIMIT_OFILE)\n\n harness = self.getHarness(inMemory=True,\n cachePathOverride=tempDir,\n maxOpenFiles=15)\n try:\n v1 = harness.newView()\n resource.setrlimit(resource.RLIMIT_OFILE, (curOpenFiles + 30, hard))\n\n for ix in range(128):\n space = SharedState.Keyspace(\"TakeHighestIdKeyType\",\n NativeJson.Json(\"TestSpace%s\" % ix),\n 1)\n rng = SharedState.KeyRange(space, 0, None, None, True, False)\n v1.subscribe(rng)\n key = SharedState.Key(space, (NativeJson.Json('key%s' % ix),))\n with SharedState.Transaction(v1):\n v1[key] = NativeJson.Json('value %s' % ix)\n finally:\n time.sleep(0.01)\n harness.teardown()\n resource.setrlimit(resource.RLIMIT_OFILE, (soft, hard))\n try:\n shutil.rmtree(tempDir)\n except:\n pass", "metadata": "root.TestSharedState.test_file_management", "header": "['class', 'TestSharedState', '(', 'unittest', '.', 'TestCase', ')', ':', '___EOS___']", "index": 272 } ]
[ { "span": "except:", "start_line": 90, "start_column": 8, "end_line": 90, "end_column": 15 }, { "span": "except:", "start_line": 308, "start_column": 12, "end_line": 308, "end_column": 19 } ]
[]
1
true
[ "[CLS]_", "Except", "_", "block_", "handles_", "'", "Base", "Except", "ion", "'_", "[SEP]_", "class_", "Test", "Share", "d", "State_", "(_", "unittest_", "._", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "def_", "client", "Thread_", "(_", "self_", ",_", "harness_", ",_", "pass", "Index_", ",_", "thread", "Index_", ",_", "total", "Thread", "Count_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "success", "List_", ",_", "fail", "ure", "List_", ",_", "connect", "ed", "Threads_", ",_", "connect", "ed", "Thread", "Event_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "view", "List_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "block", "Unti", "l", "Connected_", "\\u\\u\\uNL\\u\\u\\u_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "logging_", "._", "info_", "(_", "\"", "Connect", "ing", " ", "to", " ", "Share", "d", "State", " ", "in", " ", "thread", " ", "%", "s", "\"_", ",_", "thread", "Index_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "view_", "=_", "harness_", "._", "new", "View_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "view", "List_", "._", "append_", "(_", "view_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "finally_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "connect", "ed", "Threads_", "._", "append_", "(_", "thread", "Index_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "len_", "(_", "connect", "ed", "Threads_", ")_", "==_", "total", "Thread", "Count_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "connect", "ed", "Thread", "Event_", "._", "set_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "logging_", "._", "debug_", "(_", "\"", "All", " ", "reconnect", "ion", " ", "test", " ", "thread", "s", " ", "have", " ", "connect", "ed", ".\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "block", "Unti", "l", "Connected_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "connect", "ed", "Thread", "Event_", "._", "wait_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "logging_", "._", "info_", "(_", "\"", "Ha", "ve", " ", "view", " ", "in", " ", "thread", " ", "%", "s", "\"_", ",_", "thread", "Index_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "logging_", "._", "info_", "(_", "\"", "Connect", "ed", " ", "to", " ", "shared", " ", "state", " ", "in", " ", "thread", " ", "%", "s", "\"_", ",_", "thread", "Index_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "harness_", "._", "subscribe", "To", "Keys", "pace_", "(_", "view_", ",_", "Nat", "ive", "Json_", "._", "Json_", "(_", "\"", "data", "\"_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "harness_", "._", "write", "To", "Keys", "pace_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "view_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "Nat", "ive", "Json_", "._", "Json_", "(_", "\"", "data", "\"_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "Nat", "ive", "Json_", "._", "Json_", "(_", "str_", "(_", "thread", "Index_", ")_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "Nat", "ive", "Json_", "._", "Json_", "(_", "str_", "(_", "pass", "Index_", ")_", ")_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "t0_", "=_", "time_", "._", "time_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "while_", "True_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "item", "Dict_", "=_", "dict_", "(_", "harness_", "._", "get", "All", "Item", "s", "Fro", "m", "View_", "(_", "view_", ",_", "Nat", "ive", "Json_", "._", "Json_", "(_", "\"", "data", "\"_", ")_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "all", "Are", "Cur", "Pass_", "=_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "len_", "(_", "item", "Dict_", ")_", "==_", "total", "Thread", "Count_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "for_", "i_", "in_", "item", "Dict_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "if_", "item", "Dict_", "[_", "i_", "]_", "!=_", "Nat", "ive", "Json_", "._", "Json_", "(_", "str_", "(_", "pass", "Index_", ")_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "all", "Are", "Cur", "Pass_", "=_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "all", "Are", "Cur", "Pass_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "success", "List_", "._", "append_", "(_", "thread", "Index_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "time_", "._", "sleep_", "(_", ".01_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "time_", "._", "time_", "(_", ")_", "-_", "t0_", ">_", "5.0_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "fail", "ure", "List_", "._", "append_", "(_", "\"", "Ba", "d", " ", "dict", ":", " ", "%", "s", "\"_", "%_", "item", "Dict_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "view_", "._", "flush_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "fail", "ure", "List_", "._", "append_", "(_", "\"", "Except", "ion", ":", " ", "\"_", "+_", "traceback_", "._", "format\\u", "exc_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Test", "Share", "d", "State_", "(_", "unittest_", "._", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "file", "\\u", "management_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "temp", "Dir_", "=_", "tempfile_", "._", "mkdtemp_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "cur", "Open", "Files_", "=_", "len_", "(_", "os_", "._", "listdir_", "(_", "'/", "proc", "/", "%", "s", "/", "fd", "'_", "%_", "os_", "._", "getpid_", "(_", ")_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "OPEN", "\\u", "FILE", "\\u", "LIMIT_", "=_", "200_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "cur", "Open", "Files_", ">=_", "OPEN", "\\u", "FILE", "\\u", "LIMIT_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "os_", "._", "system_", "(_", "\"", "ls", " ", "-", "al", "h", " ", "/", "proc", "/", "%", "s", "/", "fd", "\"_", "%_", "os_", "._", "getpid_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "cur", "Open", "Files_", "<_", "OPEN", "\\u", "FILE", "\\u", "LIMIT_", ",_", "\"", "Too", " ", "many", " ", "open", " ", "files", ":", " ", "%", "s", "\"_", "%_", "cur", "Open", "Files_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "soft", "_", ",_", "hard", "_", "=_", "resource_", "._", "getr", "limit_", "(_", "resource_", "._", "RL", "IM", "IT", "\\u", "OF", "ILE_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "harness_", "=_", "self_", "._", "get", "Har", "ness_", "(_", "in", "Memory_", "=_", "True_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "cache", "Path", "Override", "_", "=_", "temp", "Dir_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "max", "Open", "Files_", "=_", "15_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "v1_", "=_", "harness_", "._", "new", "View_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "resource_", "._", "set", "rli", "mit_", "(_", "resource_", "._", "RL", "IM", "IT", "\\u", "OF", "ILE_", ",_", "(_", "cur", "Open", "Files_", "+_", "30_", ",_", "hard", "_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "for_", "ix_", "in_", "range_", "(_", "128_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "space_", "=_", "Share", "d", "State_", "._", "Keys", "pace_", "(_", "\"", "Tak", "e", "Highe", "st", "Id", "Key", "Type", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "Nat", "ive", "Json_", "._", "Json_", "(_", "\"", "Test", "Spac", "e", "%", "s", "\"_", "%_", "ix_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "rng_", "=_", "Share", "d", "State_", "._", "Key", "Range_", "(_", "space_", ",_", "0_", ",_", "None_", ",_", "None_", ",_", "True_", ",_", "False_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "v1_", "._", "subscribe_", "(_", "rng_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "key_", "=_", "Share", "d", "State_", "._", "Key_", "(_", "space_", ",_", "(_", "Nat", "ive", "Json_", "._", "Json_", "(_", "'", "key", "%", "s", "'_", "%_", "ix_", ")_", ",_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "with_", "Share", "d", "State_", "._", "Transaction_", "(_", "v1_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "v1_", "[_", "key_", "]_", "=_", "Nat", "ive", "Json_", "._", "Json_", "(_", "'", "value", " ", "%", "s", "'_", "%_", "ix_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "finally_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "time_", "._", "sleep_", "(_", "0.01_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "harness_", "._", "teardown_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "resource_", "._", "set", "rli", "mit_", "(_", "resource_", "._", "RL", "IM", "IT", "\\u", "OF", "ILE_", ",_", "(_", "soft", "_", ",_", "hard", "_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "shutil_", "._", "rmtree_", "(_", "temp", "Dir_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "pass_", "\\u\\u\\uNEWLINE\\u\\u\\u_" ]
[ 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,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, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 1, 1, 2, 2, 2, 2, 2 ]
Unused import
open-cloud/xos/xos/core/models/serviceclass.py
[ { "content": "import os\nfrom django.db import models\nfrom core.models import PlCoreBase\nfrom core.models.plcorebase import StrippedCharField\n\n\n", "metadata": "root", "header": "['module', '___EOS___']", "index": 0 }, { "content": "def get_default_serviceclass():\n try:\n return ServiceClass.objects.get(name=\"Best Effort\")\n except ServiceClass.DoesNotExist:\n return None", "metadata": "root.get_default_serviceclass", "header": "['module', '___EOS___']", "index": 5 }, { "content": "class ServiceClass(PlCoreBase):\n name = StrippedCharField(max_length=32)\n description = StrippedCharField(max_length=255)\n commitment = models.IntegerField(default=365)\n membershipFee = models.IntegerField(default=0)\n membershipFeeMonths = models.IntegerField(default=12)\n upgradeRequiresApproval = models.BooleanField(default=False)\n upgradeFrom = models.ManyToManyField('self', blank=True, null=True)\n\n class Meta(PlCoreBase.Meta):\n verbose_name_plural = \"Service classes\"\n\n", "metadata": "root.ServiceClass", "header": "['module', '___EOS___']", "index": 11 }, { "content": " def __unicode__(self): return u'%s' % (self.name)", "metadata": "root.ServiceClass.__unicode__", "header": "['class', 'ServiceClass', '(', 'PlCoreBase', ')', ':', '___EOS___']", "index": 23 }, { "content": " def save_by_user(self, user, *args, **kwds):\n if self.can_update(user):\n super(ServiceClass, self).save(*args, **kwds)", "metadata": "root.ServiceClass.save_by_user", "header": "['class', 'ServiceClass', '(', 'PlCoreBase', ')', ':', '___EOS___']", "index": 25 } ]
[ { "span": "import os", "start_line": 0, "start_column": 0, "end_line": 0, "end_column": 9 } ]
[]
1
false
[ "[CLS]_", "Un", "used_", "import_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "import_", "os_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "django_", "._", "db_", "import_", "models_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "core_", "._", "models_", "import_", "Pl", "Core", "Base_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "core_", "._", "models_", "._", "plc", "ore", "base_", "import_", "Strip", "ped", "Char", "Field_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "get", "\\u", "default", "\\u", "service", "class_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "Service", "Class_", "._", "objects_", "._", "get_", "(_", "name_", "=_", "\"", "Bes", "t", " ", "Eff", "ort", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "Service", "Class_", "._", "Do", "es", "Not", "Exist_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "class_", "Service", "Class_", "(_", "Pl", "Core", "Base_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "name_", "=_", "Strip", "ped", "Char", "Field_", "(_", "max", "\\u", "length_", "=_", "32_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "description_", "=_", "Strip", "ped", "Char", "Field_", "(_", "max", "\\u", "length_", "=_", "255_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "commitment", "_", "=_", "models_", "._", "Integer", "Field_", "(_", "default_", "=_", "365_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "member", "ship", "Fee", "_", "=_", "models_", "._", "Integer", "Field_", "(_", "default_", "=_", "0_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "member", "ship", "Fee", "Mont", "hs_", "=_", "models_", "._", "Integer", "Field_", "(_", "default_", "=_", "12_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "upgrade", "Requ", "ires", "Approval", "_", "=_", "models_", "._", "Boo", "lean", "Field_", "(_", "default_", "=_", "False_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "upgrade", "From_", "=_", "models_", "._", "Many", "To", "Many", "Field_", "(_", "'", "self", "'_", ",_", "blank_", "=_", "True_", ",_", "null_", "=_", "True_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "class_", "Meta_", "(_", "Pl", "Core", "Base_", "._", "Meta_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "verbo", "se", "\\u", "name", "\\u", "plural_", "=_", "\"", "Service", " ", "classe", "s", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "[SEP]_", "class_", "Service", "Class_", "(_", "Pl", "Core", "Base_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "\\u\\u", "unicode\\u\\u_", "(_", "self_", ")_", ":_", "return_", "u", "'%", "s", "'_", "%_", "(_", "self_", "._", "name_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Service", "Class_", "(_", "Pl", "Core", "Base_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "save", "\\u", "by", "\\u", "user_", "(_", "self_", ",_", "user_", ",_", "*_", "args_", ",_", "**_", "kwds_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "self_", "._", "can", "\\u", "update_", "(_", "user_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "super_", "(_", "Service", "Class_", ",_", "self_", ")_", "._", "save_", "(_", "*_", "args_", ",_", "**_", "kwds_", ")_" ]
[ 4, 4, 4, 4, 4, 2, 2, 0, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 ]
First parameter of a method is not named 'self'
manasgarg/flask-sauth/flask_sauth/forms.py
[ { "content": " def validate_email( form, field):\n email = field.data.lower().strip()\n if( User.objects(email=email).count()):\n raise ValidationError( \"Hey! This email is already registered with us. Did you forget your password?\")", "metadata": "root.RegistrationForm.validate_email", "header": "['class', 'RegistrationForm', '(', 'Form', ')', ':', '___EOS___']", "index": 14 } ]
[ { "span": "def validate_email( form, field):", "start_line": 14, "start_column": 4, "end_line": 14, "end_column": 37 } ]
[]
1
true
[ "[CLS]_", "First_", "parameter_", "of_", "a_", "method_", "is_", "not_", "named_", "'", "self", "'_", "[SEP]_", "class_", "Registration", "Form_", "(_", "Form_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "validat", "e\\u", "email_", "(_", "form_", ",_", "field_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "email_", "=_", "field_", "._", "data_", "._", "lower_", "(_", ")_", "._", "strip_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "(_", "User_", "._", "objects_", "(_", "email_", "=_", "email_", ")_", "._", "count_", "(_", ")_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "raise_", "Validat", "ion", "Error_", "(_", "\"", "He", "y", "!", " ", "Thi", "s", " ", "email", " ", "is", " ", "alr", "ead", "y", " ", "register", "ed", " ", "with", " ", "us", ".", " ", "Di", "d", " ", "you", " ", "forget", " ", "your", " ", "password", "?\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_" ]
[ 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 ]
Unused local variable
slinderman/pyhawkes/test/test_sbm_mf.py
[ { "content": "def test_sbm_mf(seed=None):\n \"\"\"\n Create a discrete time Hawkes model and generate from it.\n\n :return:\n \"\"\"\n if seed is None:\n seed = np.random.randint(2**32)\n\n print \"Setting seed to \", seed\n np.random.seed(seed)\n\n C = 5\n K = 100\n T = 1000\n dt = 1.0\n B = 3\n p = 0.4 * np.eye(C) + (0.05) * (1-np.eye(C))\n\n # Generate from a true model\n network_hypers = {'C': C, 'beta': 1.0/K, 'p': p}\n true_model = DiscreteTimeNetworkHawkesModelSpikeAndSlab(K, dt=dt, B=B,\n network_hypers=network_hypers)\n c = true_model.network.c\n perm = np.argsort(c)\n #\n # Plot the true network\n plt.ion()\n plot_network(true_model.weight_model.A[np.ix_(perm, perm)],\n true_model.weight_model.W[np.ix_(perm, perm)])\n plt.pause(0.001)\n\n # Make a new model for inference\n test_network_hypers = {'C': C, 'beta': 1.0/K, 'tau0': 0.5, 'tau1': 0.5}\n test_model = DiscreteTimeNetworkHawkesModelGammaMixture(K=K, dt=dt, B=B,\n network_hypers=test_network_hypers)\n test_model.weight_model.initialize_from_gibbs(true_model.weight_model.A,\n true_model.weight_model.W)\n\n # Plot the block probabilities\n plt.figure()\n im = plt.imshow(test_model.network.mf_m[perm,:],\n interpolation=\"none\", cmap=\"Greys\",\n aspect=float(C)/K)\n plt.xlabel('C')\n plt.ylabel('K')\n plt.show()\n plt.pause(0.001)\n\n # Run mean field updates for the SBM given a fixed network\n N_iters = 20\n c_samples = []\n vlbs = []\n for itr in xrange(N_iters):\n if itr % 5 == 0:\n print \"Iteration: \", itr\n\n # Update the plot\n im.set_data(test_model.network.mf_m[perm,:])\n plt.pause(0.001)\n\n\n # Resample from meanfield distribution\n test_model.network.resample_from_mf()\n c_samples.append(copy.deepcopy(test_model.network.c))\n vlbs.append(test_model.network.get_vlb() + test_model.weight_model.get_vlb())\n\n if itr > 0:\n\n if vlbs[-1] - vlbs[-2] < -1e-3:\n print \"VLBS are not increasing\"\n print np.array(vlbs)\n # import pdb; pdb.set_trace()\n raise Exception(\"VLBS are not increasing!\")\n\n\n # Take a mean field step\n test_model.network.meanfieldupdate(test_model.weight_model)\n\n plt.ioff()\n\n # Compute sample statistics for second half of samples\n c_samples = np.array(c_samples)\n vlbs = np.array(vlbs)\n\n print \"True c: \", true_model.network.c\n print \"Test c: \", c_samples[-10:, :]\n\n # Compute the adjusted mutual info score of the clusterings\n amis = []\n arss = []\n for c in c_samples:\n amis.append(adjusted_mutual_info_score(true_model.network.c, c))\n arss.append(adjusted_rand_score(true_model.network.c, c))\n\n plt.figure()\n plt.plot(np.arange(N_iters), amis, '-r')\n plt.plot(np.arange(N_iters), arss, '-b')\n plt.xlabel(\"Iteration\")\n plt.ylabel(\"Clustering score\")\n\n plt.figure()\n plt.plot(np.arange(N_iters), vlbs)\n plt.xlabel(\"Iteration\")\n plt.ylabel(\"VLB\")\n\n plt.show()\n #\n # plt.close('all')", "metadata": "root.test_sbm_mf", "header": "['module', '___EOS___']", "index": 11 } ]
[ { "span": "T ", "start_line": 25, "start_column": 4, "end_line": 25, "end_column": 5 } ]
[]
1
true
[ "[CLS]_", "Un", "used_", "local_", "variable_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "test\\u", "sb", "m", "\\u", "mf_", "(_", "seed_", "=_", "None_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Creat", "e", " ", "a", " ", "discrete", " ", "time", " ", "Ha", "wk", "es", " ", "model", " ", "and", " ", "generat", "e", " ", "from", " ", "it", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", ":", "return", ":", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "seed_", "is_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "seed_", "=_", "np_", "._", "random_", "._", "randint_", "(_", "2_", "**_", "32_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "print_", "\"", "Sett", "ing", " ", "seed", " ", "to", " ", "\"_", ",_", "seed_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "np_", "._", "random_", "._", "seed_", "(_", "seed_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "C_", "=_", "5_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "K_", "=_", "100_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "T_", "=_", "1000_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "dt_", "=_", "1.0_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "B_", "=_", "3_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "p_", "=_", "0.4_", "*_", "np_", "._", "eye_", "(_", "C_", ")_", "+_", "(_", "0.05_", ")_", "*_", "(_", "1_", "-_", "np_", "._", "eye_", "(_", "C_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Generate", " ", "from", " ", "a", " ", "true", " ", "model_", "\\u\\u\\uNL\\u\\u\\u_", "network", "\\u", "hypers", "_", "=_", "{_", "'", "C", "'_", ":_", "C_", ",_", "'", "beta", "'_", ":_", "1.0_", "/_", "K_", ",_", "'", "p", "'_", ":_", "p_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "true", "\\u", "model_", "=_", "Discr", "ete", "Time", "Network", "Ha", "wk", "es", "Model", "Spike", "And", "Sla", "b_", "(_", "K_", ",_", "dt_", "=_", "dt_", ",_", "B_", "=_", "B_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "network", "\\u", "hypers", "_", "=_", "network", "\\u", "hypers", "_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "c_", "=_", "true", "\\u", "model_", "._", "network_", "._", "c_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "perm_", "=_", "np_", "._", "argsort_", "(_", "c_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Plot", " ", "the", " ", "true", " ", "network_", "\\u\\u\\uNL\\u\\u\\u_", "plt_", "._", "ion_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "plot", "\\u", "network_", "(_", "true", "\\u", "model_", "._", "weight", "\\u", "model_", "._", "A_", "[_", "np_", "._", "ix", "\\u_", "(_", "perm_", ",_", "perm_", ")_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "true", "\\u", "model_", "._", "weight", "\\u", "model_", "._", "W_", "[_", "np_", "._", "ix", "\\u_", "(_", "perm_", ",_", "perm_", ")_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "plt_", "._", "pause_", "(_", "0.001_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Make", " ", "a", " ", "new", " ", "model", " ", "for", " ", "inference_", "\\u\\u\\uNL\\u\\u\\u_", "test\\u", "network", "\\u", "hypers", "_", "=_", "{_", "'", "C", "'_", ":_", "C_", ",_", "'", "beta", "'_", ":_", "1.0_", "/_", "K_", ",_", "'", "tau", "0", "'_", ":_", "0.5_", ",_", "'", "tau", "1", "'_", ":_", "0.5_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "test\\u", "model_", "=_", "Discr", "ete", "Time", "Network", "Ha", "wk", "es", "Model", "Gamma", "Mix", "ture_", "(_", "K_", "=_", "K_", ",_", "dt_", "=_", "dt_", ",_", "B_", "=_", "B_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "network", "\\u", "hypers", "_", "=_", "test\\u", "network", "\\u", "hypers", "_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "test\\u", "model_", "._", "weight", "\\u", "model_", "._", "initialize", "\\u", "from", "\\u", "gib", "bs_", "(_", "true", "\\u", "model_", "._", "weight", "\\u", "model_", "._", "A_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "true", "\\u", "model_", "._", "weight", "\\u", "model_", "._", "W_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Plot", " ", "the", " ", "block", " ", "probabilities_", "\\u\\u\\uNL\\u\\u\\u_", "plt_", "._", "figure_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "im_", "=_", "plt_", "._", "imshow_", "(_", "test\\u", "model_", "._", "network_", "._", "mf", "\\u", "m_", "[_", "perm_", ",_", ":_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "interpolation_", "=_", "\"", "none", "\"_", ",_", "cmap_", "=_", "\"", "Grey", "s", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "aspect_", "=_", "float_", "(_", "C_", ")_", "/_", "K_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "plt_", "._", "xlabel_", "(_", "'", "C", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "plt_", "._", "ylabel_", "(_", "'", "K", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "plt_", "._", "show_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "plt_", "._", "pause_", "(_", "0.001_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Run", " ", "mean", " ", "field", " ", "update", "s", " ", "for", " ", "the", " ", "SB", "M", " ", "give", "n", " ", "a", " ", "fixed", " ", "network_", "\\u\\u\\uNL\\u\\u\\u_", "N", "\\u", "iters_", "=_", "20_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "c\\u", "samples_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "vl", "bs_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "itr_", "in_", "xrange_", "(_", "N", "\\u", "iters_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "itr_", "%_", "5_", "==_", "0_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "print_", "\"", "Iterat", "ion", ":", " ", "\"_", ",_", "itr_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Update", " ", "the", " ", "plot_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "im_", "._", "set\\u", "data_", "(_", "test\\u", "model_", "._", "network_", "._", "mf", "\\u", "m_", "[_", "perm_", ",_", ":_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "plt_", "._", "pause_", "(_", "0.001_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Res", "ample", " ", "from", " ", "mean", "field", " ", "distribution_", "\\u\\u\\uNL\\u\\u\\u_", "test\\u", "model_", "._", "network_", "._", "resample", "\\u", "from", "\\u", "mf_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "c\\u", "samples_", "._", "append_", "(_", "copy_", "._", "deepcopy_", "(_", "test\\u", "model_", "._", "network_", "._", "c_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "vl", "bs_", "._", "append_", "(_", "test\\u", "model_", "._", "network_", "._", "get", "\\u", "vl", "b_", "(_", ")_", "+_", "test\\u", "model_", "._", "weight", "\\u", "model_", "._", "get", "\\u", "vl", "b_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "itr_", ">_", "0_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "vl", "bs_", "[_", "-_", "1_", "]_", "-_", "vl", "bs_", "[_", "-_", "2_", "]_", "<_", "-_", "1e-3_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "print_", "\"", "VL", "BS", " ", "are", " ", "not", " ", "incr", "easi", "ng", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "print_", "np_", "._", "array_", "(_", "vl", "bs_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "import", " ", "pdb", ";", " ", "pdb", ".", "set\\u", "trace", "()", "_", "\\u\\u\\uNL\\u\\u\\u_", "raise_", "Exception_", "(_", "\"", "VL", "BS", " ", "are", " ", "not", " ", "incr", "easi", "ng", "!\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Tak", "e", " ", "a", " ", "mean", " ", "field", " ", "step_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "test\\u", "model_", "._", "network_", "._", "mean", "field", "update_", "(_", "test\\u", "model_", "._", "weight", "\\u", "model_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "plt_", "._", "io", "ff_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Compute", " ", "sample", " ", "statistic", "s", " ", "for", " ", "second", " ", "half", " ", "of", " ", "samples_", "\\u\\u\\uNL\\u\\u\\u_", "c\\u", "samples_", "=_", "np_", "._", "array_", "(_", "c\\u", "samples_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "vl", "bs_", "=_", "np_", "._", "array_", "(_", "vl", "bs_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "print_", "\"", "Tru", "e", " ", "c", ":", " ", "\"_", ",_", "true", "\\u", "model_", "._", "network_", "._", "c_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "print_", "\"", "Test", " ", "c", ":", " ", "\"_", ",_", "c\\u", "samples_", "[_", "-_", "10_", ":_", ",_", ":_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Compute", " ", "the", " ", "adjusted", " ", "mutual", " ", "info", " ", "score", " ", "of", " ", "the", " ", "clusteri", "ngs_", "\\u\\u\\uNL\\u\\u\\u_", "ami", "s_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "ars", "s_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "c_", "in_", "c\\u", "samples_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "ami", "s_", "._", "append_", "(_", "adjusted", "\\u", "mutual", "\\u", "info", "\\u", "score_", "(_", "true", "\\u", "model_", "._", "network_", "._", "c_", ",_", "c_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "ars", "s_", "._", "append_", "(_", "adjusted", "\\u", "rand", "\\u", "score_", "(_", "true", "\\u", "model_", "._", "network_", "._", "c_", ",_", "c_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "plt_", "._", "figure_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "plt_", "._", "plot_", "(_", "np_", "._", "arange_", "(_", "N", "\\u", "iters_", ")_", ",_", "ami", "s_", ",_", "'-", "r", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "plt_", "._", "plot_", "(_", "np_", "._", "arange_", "(_", "N", "\\u", "iters_", ")_", ",_", "ars", "s_", ",_", "'-", "b", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "plt_", "._", "xlabel_", "(_", "\"", "Iterat", "ion", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "plt_", "._", "ylabel_", "(_", "\"", "Clustering", " ", "score", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "plt_", "._", "figure_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "plt_", "._", "plot_", "(_", "np_", "._", "arange_", "(_", "N", "\\u", "iters_", ")_", ",_", "vl", "bs_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "plt_", "._", "xlabel_", "(_", "\"", "Iterat", "ion", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "plt_", "._", "ylabel_", "(_", "\"", "VL", "B", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "plt_", "._", "show_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "plt", ".", "close", "('", "all", "')", "_", "\\u\\u\\uNL\\u\\u\\u_" ]
[ 4, 4, 4, 4, 4, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2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, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 ]
Except block handles 'BaseException'
paypal/support/support/meta_service/meta_service.py
[ { "content": "def get_pytypes():\n answer = defaultdict(lambda: 0)\n try:\n for ob in gc.get_objects():\n answer[repr(type(ob))] += 1\n except:\n pass\n return answer", "metadata": "root.get_pytypes", "header": "['module', '___EOS___']", "index": 130 }, { "content": "def get_pytypes_len_gen():\n try:\n yield \"{\\n\"\n\n def get_total_size(obj, n=0):\n if n > 10:\n return 0\n obj_len = 0\n try:\n if callable(getattr(obj, '__len__', False)):\n obj_len += int(obj.__len__())\n except:\n pass\n for a in gc.get_referents(obj):\n obj_len += get_total_size(a, n + 1)\n return obj_len\n\n for ob in gc.get_objects():\n if getattr(ob, '__len__', False):\n yield \"\\\"\" + repr(type(ob)) + \":\" + str(id(ob)) + \"\\\": [\" + str(len(ob)) \\\n + \", \" + str(get_total_size(ob)) + \"]\\n\"\n\n except Exception as e:\n yield \"\\\"error\\\":\\\"\" + repr(e).replace(\"\\\"\", \"\\\\\\\"\") + \"\\\"\\n\"\n yield \"}\\n\"", "metadata": "root.get_pytypes_len_gen", "header": "['module', '___EOS___']", "index": 144 }, { "content": "def get_fd_info():\n '''\n Gathers and correlates fd info from 3 sources:\n\n 1. gc over all objects that have a fileno(); this is most 'socket-like' things\n 2. infra Context object data structures\n 3. psutil information\n 4. /proc filesystem (if available)\n\n This function is a little bit open-ended, we can probably continue\n to find additional sources of information\n '''\n import psutil\n\n fd_info = collections.defaultdict(\n lambda: {'gc_objs': [], '/proc': {}, 'context': [], 'psutil': {}})\n\n # 1 - all objects with filenos\n for obj in gc.get_objects():\n try:\n fd = None\n if hasattr(obj, 'fileno') and callable(obj.fileno):\n fd = obj.fileno()\n except: # there are a zillion boring reasons this may fail\n pass\n if isinstance(fd, (int, long)):\n fd_info[fd]['gc_objs'].append(obj)\n\n # 2 - inspection of data-structures in context\n ctx = context.get_context()\n socks = []\n if ctx.connection_mgr:\n for model in ctx.connection_mgr.server_models.values():\n socks.extend(model.active_connections)\n if ctx.client_sockets:\n socks.extend(ctx.client_sockets)\n if ctx.server_group:\n socks.extend(ctx.server_group.socks.values())\n for sock in socks:\n fd_info[sock.fileno()]['context'].append(sock)\n\n # 3 - psutil information\n process = psutil.Process()\n for f in process.get_open_files():\n if f.fd == -1:\n continue\n fd_info[f.fd]['psutil']['path'] = f.path\n for conn in process.get_connections(kind='all'):\n if conn.fd == -1:\n continue\n fd_info[conn.fd]['psutil'].update(vars(conn))\n del fd_info[conn.fd]['psutil']['fd']\n\n # 4 - /proc filesystem\n proc_path = \"/proc/\" + str(os.getpid())\n if not os.path.exists(proc_path):\n return dict(fd_info)\n\n for fd in os.listdir(proc_path + \"/fd\"):\n try:\n inode = os.readlink(proc_path + \"/fd/\" + fd)\n except OSError:\n continue\n else:\n fd = int(fd)\n fd_info[fd]['/proc']['inode'] = inode\n\n return dict(fd_info)", "metadata": "root.get_fd_info", "header": "['module', '___EOS___']", "index": 236 }, { "content": "def _transform(v):\n try:\n return dict(v)\n except:\n pass\n try:\n return list(v)\n except:\n pass\n return repr(v)", "metadata": "root._transform", "header": "['module', '___EOS___']", "index": 410 } ]
[ { "span": "except:", "start_line": 135, "start_column": 4, "end_line": 135, "end_column": 11 }, { "span": "except:", "start_line": 155, "start_column": 12, "end_line": 155, "end_column": 19 }, { "span": "except: ", "start_line": 259, "start_column": 8, "end_line": 259, "end_column": 15 }, { "span": "except:", "start_line": 413, "start_column": 4, "end_line": 413, "end_column": 11 }, { "span": "except:", "start_line": 417, "start_column": 4, "end_line": 417, "end_column": 11 } ]
[]
1
true
[ "[CLS]_", "Except", "_", "block_", "handles_", "'", "Base", "Except", "ion", "'_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "get", "\\u", "pyt", "ypes_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "answer_", "=_", "defaultdict_", "(_", "lambda_", ":_", "0_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "for_", "ob_", "in_", "gc_", "._", "get", "\\u", "objects_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "answer_", "[_", "repr_", "(_", "type_", "(_", "ob_", ")_", ")_", "]_", "+=_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "pass_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "answer_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "get", "\\u", "pyt", "ype", "s", "\\u", "len", "\\u", "gen_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "yield_", "\"{\\\\", "n", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "get", "\\u", "total", "\\u", "size_", "(_", "obj_", ",_", "n_", "=_", "0_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "n_", ">_", "10_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "0_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "obj", "\\u", "len_", "=_", "0_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "callable_", "(_", "getattr_", "(_", "obj_", ",_", "'\\u", "\\u", "len", "\\u\\u'_", ",_", "False_", ")_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "obj", "\\u", "len_", "+=_", "int_", "(_", "obj_", "._", "\\u\\u", "len\\u\\u_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "pass_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "for_", "a_", "in_", "gc_", "._", "get", "\\u", "referen", "ts_", "(_", "obj_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "obj", "\\u", "len_", "+=_", "get", "\\u", "total", "\\u", "size_", "(_", "a_", ",_", "n_", "+_", "1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "obj", "\\u", "len_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "for_", "ob_", "in_", "gc_", "._", "get", "\\u", "objects_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "getattr_", "(_", "ob_", ",_", "'\\u", "\\u", "len", "\\u\\u'_", ",_", "False_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "yield_", "\"\\\\\"\"_", "+_", "repr_", "(_", "type_", "(_", "ob_", ")_", ")_", "+_", "\":\"_", "+_", "str_", "(_", "id_", "(_", "ob_", ")_", ")_", "+_", "\"\\\\\"", ":", " ", "[\"_", "+_", "str_", "(_", "len_", "(_", "ob_", ")_", ")_", "+_", "\",", " ", "\"_", "+_", "str_", "(_", "get", "\\u", "total", "\\u", "size_", "(_", "ob_", ")_", ")_", "+_", "\"]", "\\\\", "n", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "Exception_", "as_", "e_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "yield_", "\"\\\\\"", "error", "\\\\\":", "\\\\\"\"_", "+_", "repr_", "(_", "e_", ")_", "._", "replace_", "(_", "\"\\\\\"\"_", ",_", "\"\\\\\\\\\\\\", "\"\"_", ")_", "+_", "\"\\\\\"", "\\\\", "n", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "yield_", "\"}", "\\\\", "n", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "get", "\\u", "fd", "\\u", "info_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "'''", "\\", "10", ";", " ", " ", " ", " ", "Gather", "s", " ", "and", " ", "correlate", "s", " ", "fd", " ", "info", " ", "from", " ", "3", " ", "source", "s", ":", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "1", ".", " ", "gc", " ", "over", " ", "all", " ", "object", "s", " ", "tha", "t", " ", "have", " ", "a", " ", "filen", "o", "();", " ", "this", " ", "is", " ", "most", " ", "'", "socket", "-", "like", "'", " ", "thing", "s", "\\", "10", ";", " ", " ", " ", " ", "2", ".", " ", "infra", " ", "Context", " ", "object", " ", "data", " ", "structure", "s", "\\", "10", ";", " ", " ", " ", " ", "3", ".", " ", "psu", "til", " ", "informati", "on", "\\", "10", ";", " ", " ", " ", " ", "4", ".", " ", "/", "proc", " ", "filesystem", " ", "(", "if", " ", "avail", "able", ")", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "Thi", "s", " ", "function", " ", "is", " ", "a", " ", "litt", "le", " ", "bit", " ", "open", "-", "ende", "d", ",", " ", "we", " ", "can", " ", "probab", "ly", " ", "continue", "\\", "10", ";", " ", " ", " ", " ", "to", " ", "find", " ", "addition", "al", " ", "source", "s", " ", "of", " ", "informati", "on", "\\", "10", ";", " ", " ", " ", " ", "'''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "psutil_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "fd", "\\u", "info_", "=_", "collections_", "._", "defaultdict_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "lambda_", ":_", "{_", "'", "gc", "\\u", "objs", "'_", ":_", "[_", "]_", ",_", "'/", "proc", "'_", ":_", "{_", "}_", ",_", "'", "context", "'_", ":_", "[_", "]_", ",_", "'", "psu", "til", "'_", ":_", "{_", "}_", "}_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "1", " ", "-", " ", "all", " ", "object", "s", " ", "with", " ", "filen", "os_", "\\u\\u\\uNL\\u\\u\\u_", "for_", "obj_", "in_", "gc_", "._", "get", "\\u", "objects_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "fd_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "hasattr_", "(_", "obj_", ",_", "'", "filen", "o", "'_", ")_", "and_", "callable_", "(_", "obj_", "._", "fileno_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "fd_", "=_", "obj_", "._", "fileno_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", ":_", "#", " ", "there", " ", "are", " ", "a", " ", "zil", "lio", "n", " ", "bor", "ing", " ", "reasons", " ", "this", " ", "may", " ", "fail_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "pass_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "isinstance_", "(_", "fd_", ",_", "(_", "int_", ",_", "long_", ")_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "fd", "\\u", "info_", "[_", "fd_", "]_", "[_", "'", "gc", "\\u", "objs", "'_", "]_", "._", "append_", "(_", "obj_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "2", " ", "-", " ", "inspection", " ", "of", " ", "data", "-", "structure", "s", " ", "in", " ", "context_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "ctx_", "=_", "context_", "._", "get", "\\u", "context_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "socks", "_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "ctx_", "._", "connecti", "on", "\\u", "mgr_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "for_", "model_", "in_", "ctx_", "._", "connecti", "on", "\\u", "mgr_", "._", "server", "\\u", "models_", "._", "values_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "socks", "_", "._", "extend_", "(_", "model_", "._", "active", "\\u", "connections_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "ctx_", "._", "client", "\\u", "sockets_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "socks", "_", "._", "extend_", "(_", "ctx_", "._", "client", "\\u", "sockets_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "ctx_", "._", "server", "\\u", "group_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "socks", "_", "._", "extend_", "(_", "ctx_", "._", "server", "\\u", "group_", "._", "socks", "_", "._", "values_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "for_", "sock_", "in_", "socks", "_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "fd", "\\u", "info_", "[_", "sock_", "._", "fileno_", "(_", ")_", "]_", "[_", "'", "context", "'_", "]_", "._", "append_", "(_", "sock_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "3", " ", "-", " ", "psu", "til", " ", "information_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "process_", "=_", "psutil_", "._", "Process_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "f_", "in_", "process_", "._", "get", "\\u", "open", "\\u", "files_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "f_", "._", "fd_", "==_", "-_", "1_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "continue_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "fd", "\\u", "info_", "[_", "f_", "._", "fd_", "]_", "[_", "'", "psu", "til", "'_", "]_", "[_", "'", "path", "'_", "]_", "=_", "f_", "._", "path_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "for_", "conn_", "in_", "process_", "._", "get", "\\u", "connections_", "(_", "kind_", "=_", "'", "all", "'_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "conn_", "._", "fd_", "==_", "-_", "1_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "continue_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "fd", "\\u", "info_", "[_", "conn_", "._", "fd_", "]_", "[_", "'", "psu", "til", "'_", "]_", "._", "update_", "(_", "vars_", "(_", "conn_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "del_", "fd", "\\u", "info_", "[_", "conn_", "._", "fd_", "]_", "[_", "'", "psu", "til", "'_", "]_", "[_", "'", "fd", "'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "4", " ", "-", " ", "/", "proc", " ", "filesystem_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "proc", "\\u", "path_", "=_", "\"/", "proc", "/\"_", "+_", "str_", "(_", "os_", "._", "getpid_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "not_", "os_", "._", "path_", "._", "exists_", "(_", "proc", "\\u", "path_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "dict_", "(_", "fd", "\\u", "info_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "for_", "fd_", "in_", "os_", "._", "listdir_", "(_", "proc", "\\u", "path_", "+_", "\"/", "fd", "\"_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "inode_", "=_", "os_", "._", "readli", "nk_", "(_", "proc", "\\u", "path_", "+_", "\"/", "fd", "/\"_", "+_", "fd_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "OSE", "rror_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "continue_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "fd_", "=_", "int_", "(_", "fd_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "fd", "\\u", "info_", "[_", "fd_", "]_", "[_", "'/", "proc", "'_", "]_", "[_", "'", "inode", "'_", "]_", "=_", "inode_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "dict_", "(_", "fd", "\\u", "info_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "\\u", "transform_", "(_", "v_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "dict_", "(_", "v_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "pass_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "list_", "(_", "v_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "pass_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "repr_", "(_", "v_",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 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 ]
Unused local variable
rcbops/glance-buildpackage/glance/tests/functional/test_api.py
[ { "content": " @skip_if_disabled\n def test_delete_not_existing(self):\n \"\"\"\n We test the following:\n\n 0. GET /images/1\n - Verify 404\n 1. DELETE /images/1\n - Verify 404\n \"\"\"\n self.cleanup()\n self.start_servers(**self.__dict__.copy())\n\n api_port = self.api_port\n registry_port = self.registry_port\n\n # 0. GET /images\n # Verify no public images\n path = \"http://%s:%d/v1/images\" % (\"0.0.0.0\", self.api_port)\n http = httplib2.Http()\n response, content = http.request(path, 'GET')\n self.assertEqual(response.status, 200)\n self.assertEqual(content, '{\"images\": []}')\n\n # 1. DELETE /images/1\n # Verify 404 returned\n path = \"http://%s:%d/v1/images/1\" % (\"0.0.0.0\", self.api_port)\n http = httplib2.Http()\n response, content = http.request(path, 'DELETE')\n self.assertEqual(response.status, 404)\n\n self.stop_servers()", "metadata": "root.TestApi.test_delete_not_existing", "header": "['class', 'TestApi', '(', 'functional', '.', 'FunctionalTest', ')', ':', '___EOS___']", "index": 1209 } ]
[ { "span": "api_port ", "start_line": 1222, "start_column": 8, "end_line": 1222, "end_column": 16 }, { "span": "registry_port ", "start_line": 1223, "start_column": 8, "end_line": 1223, "end_column": 21 } ]
[]
1
true
[ "[CLS]_", "Un", "used_", "local_", "variable_", "[SEP]_", "class_", "Test", "Api_", "(_", "functional_", "._", "Function", "al", "Test_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "@_", "skip", "\\u", "if", "\\u", "disabled_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "test\\u", "delete", "\\u", "not", "\\u", "existing_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "We", " ", "test", " ", "the", " ", "follow", "ing", ":", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "0.", " ", "GET", " ", "/", "images", "/", "1", "\\", "10", ";", " ", " ", " ", " ", "-", " ", "Verify", " ", "404", "\\", "10", ";", " ", " ", " ", " ", "1", ".", " ", "DELET", "E", " ", "/", "images", "/", "1", "\\", "10", ";", " ", " ", " ", " ", "-", " ", "Verify", " ", "404", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "cleanup_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "start", "\\u", "servers_", "(_", "**_", "self_", "._", "\\u\\u", "dict\\u\\u_", "._", "copy_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "api", "\\u", "port_", "=_", "self_", "._", "api", "\\u", "port_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "registr", "y", "\\u", "port_", "=_", "self_", "._", "registr", "y", "\\u", "port_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "0.", " ", "GET", " ", "/", "images_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Verify", " ", "no", " ", "public", " ", "images_", "\\u\\u\\uNL\\u\\u\\u_", "path_", "=_", "\"", "http", "://", "%", "s", ":", "%", "d", "/", "v1", "/", "images", "\"_", "%_", "(_", "\"", "0.", "0.", "0.", "0", "\"_", ",_", "self_", "._", "api", "\\u", "port_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "http_", "=_", "httplib2_", "._", "Http_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "response_", ",_", "content_", "=_", "http_", "._", "request_", "(_", "path_", ",_", "'", "GET", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "response_", "._", "status_", ",_", "200_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "content_", ",_", "'{", "\"", "images", "\":", " ", "[]", "}'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "1", ".", " ", "DELET", "E", " ", "/", "images", "/", "1_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Verify", " ", "404", " ", "returned_", "\\u\\u\\uNL\\u\\u\\u_", "path_", "=_", "\"", "http", "://", "%", "s", ":", "%", "d", "/", "v1", "/", "images", "/", "1", "\"_", "%_", "(_", "\"", "0.", "0.", "0.", "0", "\"_", ",_", "self_", "._", "api", "\\u", "port_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "http_", "=_", "httplib2_", "._", "Http_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "response_", ",_", "content_", "=_", "http_", "._", "request_", "(_", "path_", ",_", "'", "DELET", "E", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "response_", "._", "status_", ",_", "404_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "stop", "\\u", "servers_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_" ]
[ 4, 4, 4, 4, 4, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 1, 1, 2, 2, 2, 2, 2, 2, 2, 0, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 ]
Unused import
denizalti/concoord/concoord/replica.py
[ { "content": "'''\n@author: Deniz Altinbuken, Emin Gun Sirer\n@note: The Replica keeps an object and responds to Perform messages received from the Leader.\n@copyright: See LICENSE\n'''\nimport inspect\nimport time\nimport os, sys\nimport signal\nimport cPickle as pickle\nfrom threading import Thread, Lock, Timer, Event\nfrom concoord.pack import Proposal, PValue\nfrom concoord.pvalue import PValueSet\nfrom concoord.nameserver import Nameserver\nfrom concoord.responsecollector import ResponseCollector\nfrom concoord.exception import ConCoordException, BlockingReturn, UnblockingReturn\nfrom concoord.node import *\nfrom concoord.enums import *\nfrom concoord.utils import *\nfrom concoord.message import *\n\nbackoff_event = Event()\n\n\nif __name__=='__main__':\n main()\n", "metadata": "root", "header": "['module', '___EOS___']", "index": 0 }, { "content": "class Replica(Node):\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n# LEADER STATE\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n## PAXOS METHODS\n\n\n## PAXOS ACCEPTOR MESSAGE HANDLERS\n\n\n\n## PAXOS REPLICA MESSAGE HANDLERS\n\n\n\n\n\n\n\n\n\n\n## SHELL COMMANDS\n\n\n\n\n\n\n## TERMINATION METHODS\n", "metadata": "root.Replica", "header": "['module', '___EOS___']", "index": 22 }, { "content": " def __init__(self):\n Node.__init__(self)\n # load and initialize the object to be replicated\n import importlib\n objectloc,a,classname = self.objectname.rpartition('.')\n self.object = None\n try:\n module = importlib.import_module(objectloc)\n if hasattr(module, classname):\n self.object = getattr(module, classname)()\n except (ValueError, ImportError, AttributeError):\n self.object = None\n\n if not self.object:\n self.logger.write(\"Object Error\", \"Object cannot be found.\")\n self._graceexit(1)\n try:\n self.token = getattr(self.object, '_%s__concoord_token' % self.objectname)\n except AttributeError as e:\n if self.debug: self.logger.write(\"State\", \"Object initialized without a token.\")\n self.token = None\n\n # leadership state\n self.leader_initializing = False\n self.isleader = False\n self.ballotnumber = (0, 0, self.id)\n self.nexttoexecute = 1\n # decided commands: <commandnumber:command>\n self.decisions = {}\n self.decisionset = set()\n # executed commands: <command:(replycode,commandresult,unblocked{})>\n self.executed = {}\n # commands that are proposed: <commandnumber:command>\n self.proposals = {}\n self.proposalset = set()\n # commands that are received, not yet proposed: <commandnumber:command>\n self.pendingcommands = {}\n self.pendingcommandset = set()\n # commandnumbers known to be in use\n self.usedcommandnumbers = set()\n # nodes being added/deleted\n self.nodesbeingdeleted = set()\n # number for metacommands initiated from this replica\n self.metacommandnumber = 0\n # keep nodes that are recently updated\n self.recentlyupdatedpeerslock = Lock()\n self.recentlyupdatedpeers = []\n\n # Quorum state\n if self.durable:\n self.file = open('concoordlog', 'a')\n\n self.quorumballotnumber = (0, 0, '')\n self.last_accept_msg_id = -1\n self.quorumaccepted = PValueSet()\n self.objectsnapshot = (0,None)\n\n # PERFORMANCE MEASUREMENT VARS\n self.firststarttime = 0\n self.firststoptime = 0\n self.secondstarttime = 0\n self.secondstoptime = 0\n self.count = 0\n\n self.throughput_runs = 0\n self.throughput_stop = 0\n self.throughput_start = 0", "metadata": "root.Replica.__init__", "header": "['class', 'Replica', '(', 'Node', ')', ':', '___EOS___']", "index": 23 }, { "content": " def __str__(self):\n rstr = \"%s %s:%d\\n\" % (\"LEADER\" if self.isleader else node_names[self.type], self.addr, self.port)\n rstr += \"Members:\\n%s\\n\" % \"\\n\".join(str(peer) for peer in self.replicas)\n rstr += \"Waiting to execute command %d.\\n\" % self.nexttoexecute\n rstr += \"Commands:\\n\"\n for commandnumber, command in self.decisions.iteritems():\n state = ''\n if command in self.executed:\n if isinstance(command, ProposalClientBatch):\n state = '\\t' + str(self.executed[command])\n else:\n state = '\\t' + cr_codes[self.executed[command][0]]+ '\\t' + str(self.executed[command][1])\n rstr += str(commandnumber) + \":\\t\" + str(command) + state + '\\n'\n if len(self.pendingcommands):\n rstr += \"Pending Commands:\\n\"\n for commandnumber, command in self.pendingcommands.iteritems():\n rstr += str(commandnumber) + \":\\t\" + str(command) + '\\n'\n if len(self.proposals):\n rstr += \"Proposals:\\n\"\n for commandnumber, command in self.proposals.iteritems():\n rstr += str(commandnumber) + \":\\t\" + str(command) + '\\n'\n # Add QUORUM State\n rstr += \"Quorum Ballot Number: %s\\n\" % str(self.quorumballotnumber)\n rstr += \"Accepted PValues: %s\\n\" % str(self.quorumaccepted)\n\n return rstr", "metadata": "root.Replica.__str__", "header": "['class', 'Replica', '(', 'Node', ')', ':', '___EOS___']", "index": 91 }, { "content": " def _import_object(self, name):\n mod = __import__(name)\n components = name.split('.')\n for comp in components[1:]:\n mod = getattr(mod, comp)\n return mod", "metadata": "root.Replica._import_object", "header": "['class', 'Replica', '(', 'Node', ')', ':', '___EOS___']", "index": 118 }, { "content": " def startservice(self):\n \"\"\"Start the background services associated with a replica.\"\"\"\n Node.startservice(self)\n\n if self.isnameserver and not self.useroute53:\n if self.debug: self.logger.write(\"State\", \"Starting the Nameserver Thread.\")\n # Start a thread for the UDP server\n UDP_server_thread = Thread(target=self.nameserver.udp_server_loop, name='UDPServerThread')\n UDP_server_thread.start()", "metadata": "root.Replica.startservice", "header": "['class', 'Replica', '(', 'Node', ')', ':', '___EOS___']", "index": 125 }, { "content": " @staticmethod\n def _apply_args_to_method(method, args, _concoord_command):\n argspec = inspect.getargspec(method)\n if argspec.args and argspec.args[-1] == '_concoord_command':\n return method(*args, _concoord_command=_concoord_command)\n elif argspec.keywords is not None:\n return method(*args, _concoord_command=_concoord_command)\n else:\n return method(*args)", "metadata": "root.Replica._apply_args_to_method", "header": "['class', 'Replica', '(', 'Node', ')', ':', '___EOS___']", "index": 135 }, { "content": " def performcore_clientbatch(self, commandbatch, designated=False):\n '''performs all clientrequests in a clientbatch and returns a batched result.'''\n if self.debug: self.logger.write(\"State\", \"Performing client batch.\")\n clientreplies = []\n for commandtuple in commandbatch.command:\n commandname = commandtuple[0]\n commandargs = commandtuple[1:]\n # Result triple\n clientreplycode, givenresult, unblocked = (-1, None, {})\n try:\n method = getattr(self.object, commandname)\n # Watch out for the lock release and acquire!\n self.lock.release()\n try:\n givenresult = method(*commandargs)\n clientreplycode = CR_OK\n except BlockingReturn as blockingretexp:\n if self.debug: self.logger.write(\"State\", \"Blocking Client.\")\n givenresult = blockingretexp.returnvalue\n clientreplycode = CR_BLOCK\n except UnblockingReturn as unblockingretexp:\n if self.debug: self.logger.write(\"State\", \"Unblocking Client(s).\")\n # Get the information about the method call\n # These will be used to update executed and\n # to send reply message to the caller client\n givenresult = unblockingretexp.returnvalue\n unblocked = unblockingretexp.unblocked\n clientreplycode = CR_OK\n # If there are clients to be unblocked that have\n # been blocked previously, send them unblock messages\n for unblockedclientcommand in unblocked.iterkeys():\n self.send_reply_to_client(CR_UNBLOCK, None, unblockedclientcommand)\n except Exception as e:\n if self.debug: self.logger.write(\"Execution Error\", \"Error during method invocation: %s\" % str(e))\n givenresult = pickle.dumps(e)\n clientreplycode = CR_EXCEPTION\n unblocked = {}\n self.lock.acquire()\n except (TypeError, AttributeError) as t:\n if self.debug: self.logger.write(\"Execution Error\",\n \"command not supported: %s\" % str(commandname))\n if self.debug: self.logger.write(\"Execution Error\", \"%s\" % str(t))\n\n givenresult = 'Method Does Not Exist: ', commandname\n clientreplycode = CR_EXCEPTION\n unblocked = {}\n clientreplies.append((clientreplycode, givenresult, unblocked))\n self.add_to_executed(commandbatch, clientreplies)\n\n if self.isleader and str(commandbatch.client) in self.connectionpool.poolbypeer.keys():\n self.send_replybatch_to_client(clientreplies, commandbatch)\n\n if self.nexttoexecute % GARBAGEPERIOD == 0 and self.isleader:\n mynumber = self.metacommandnumber\n self.metacommandnumber += 1\n garbagetuple = (\"_garbage_collect\", self.nexttoexecute)\n garbagecommand = Proposal(self.me, mynumber, garbagetuple)\n if self.leader_initializing:\n self.handle_client_command(garbagecommand, prepare=True)\n else:\n self.handle_client_command(garbagecommand)\n if self.debug: self.logger.write(\"State:\", \"returning from performcore!\")", "metadata": "root.Replica.performcore_clientbatch", "header": "['class', 'Replica', '(', 'Node', ')', ':', '___EOS___']", "index": 145 }, { "content": " def performcore(self, command, dometaonly=False, designated=False):\n \"\"\"The core function that performs a given command in a slot number. It\n executes regular commands as well as META-level commands (commands related\n to the managements of the Paxos protocol) with a delay of WINDOW commands.\"\"\"\n commandtuple = command.command\n if type(commandtuple) == str:\n commandname = commandtuple\n commandargs = []\n else:\n commandname = commandtuple[0]\n commandargs = commandtuple[1:]\n ismeta = (commandname in METACOMMANDS)\n noop = (commandname == \"noop\")\n send_result_to_client = True\n if self.debug: self.logger.write(\"State:\", \"---> Command: %s DoMetaOnly: %s IsMeta: %s\"\n % (command, dometaonly, ismeta))\n # Result triple\n clientreplycode, givenresult, unblocked = (-1, None, {})\n try:\n if dometaonly and not ismeta:\n return\n elif noop:\n method = getattr(self, NOOP)\n clientreplycode = CR_OK\n givenresult = \"NOOP\"\n unblocked = {}\n send_result_to_client = False\n elif dometaonly and ismeta:\n # execute a metacommand when the window has expired\n if self.debug: self.logger.write(\"State\",\n \"commandname: %s args: %s\" %\n (commandname, str(commandargs)))\n method = getattr(self, commandname)\n clientreplycode = CR_META\n givenresult = self._apply_args_to_method(method, commandargs, command)\n unblocked = {}\n send_result_to_client = False\n elif not dometaonly and ismeta:\n # meta command, but the window has not passed yet,\n # so just mark it as executed without actually executing it\n # the real execution will take place when the window has expired\n self.add_to_executed(command, (CR_META, META, {}))\n return\n elif not dometaonly and not ismeta:\n # this is the workhorse case that executes most normal commands\n method = getattr(self.object, commandname)\n # Watch out for the lock release and acquire!\n self.lock.release()\n try:\n givenresult = self._apply_args_to_method(method, commandargs, command)\n clientreplycode = CR_OK\n send_result_to_client = True\n except BlockingReturn as blockingretexp:\n if self.debug: self.logger.write(\"State\", \"Blocking Client.\")\n givenresult = blockingretexp.returnvalue\n clientreplycode = CR_BLOCK\n send_result_to_client = True\n except UnblockingReturn as unblockingretexp:\n if self.debug: self.logger.write(\"State\", \"Unblocking Client(s).\")\n # Get the information about the method call\n # These will be used to update executed and\n # to send reply message to the caller client\n givenresult = unblockingretexp.returnvalue\n unblocked = unblockingretexp.unblocked\n clientreplycode = CR_OK\n send_result_to_client = True\n # If there are clients to be unblocked that have\n # been blocked previously, send them unblock messages\n for unblockedclientcommand in unblocked.iterkeys():\n self.send_reply_to_client(CR_UNBLOCK, None, unblockedclientcommand)\n except Exception as e:\n if self.debug: self.logger.write(\"Execution Error\",\n \"Error during method invocation: %s\" % str(e))\n givenresult = pickle.dumps(e)\n clientreplycode = CR_EXCEPTION\n send_result_to_client = True\n unblocked = {}\n self.lock.acquire()\n except (TypeError, AttributeError) as t:\n if self.debug: self.logger.write(\"Execution Error\",\n \"command not supported: %s\" % str(command))\n if self.debug: self.logger.write(\"Execution Error\", \"%s\" % str(t))\n\n self.logger.write(\"Execution Error\",\n \"command not supported: %s\" % str(command))\n self.logger.write(\"Execution Error\", \"%s\" % str(t))\n\n givenresult = 'Method Does Not Exist: ', commandname\n clientreplycode = CR_EXCEPTION\n unblocked = {}\n send_result_to_client = True\n self.add_to_executed(command, (clientreplycode,givenresult,unblocked))\n\n if commandname not in METACOMMANDS:\n # if this client contacted me for this operation, return him the response\n if send_result_to_client and self.isleader and \\\n str(command.client) in self.connectionpool.poolbypeer.keys():\n self.send_reply_to_client(clientreplycode, givenresult, command)\n\n if self.nexttoexecute % GARBAGEPERIOD == 0 and self.isleader:\n mynumber = self.metacommandnumber\n self.metacommandnumber += 1\n garbagetuple = (\"_garbage_collect\", self.nexttoexecute, self.ballotnumber)\n garbagecommand = Proposal(self.me, mynumber, garbagetuple)\n if self.leader_initializing:\n self.handle_client_command(garbagecommand, prepare=True)\n else:\n self.handle_client_command(garbagecommand)\n if self.debug: self.logger.write(\"State:\", \"returning from performcore!\")", "metadata": "root.Replica.performcore", "header": "['class', 'Replica', '(', 'Node', ')', ':', '___EOS___']", "index": 208 }, { "content": " def send_replybatch_to_client(self, givenresult, command):\n if self.debug: self.logger.write(\"State\", \"Sending REPLY to CLIENT\")\n clientreply = create_message(MSG_CLIENTREPLY, self.me,\n {FLD_REPLY: givenresult,\n FLD_REPLYCODE: CR_BATCH,\n FLD_INRESPONSETO: command.clientcommandnumber})\n clientconn = self.connectionpool.get_connection_by_peer(command.client)\n if clientconn == None or clientconn.thesocket == None:\n if self.debug: self.logger.write(\"State\", \"Client connection does not exist.\")\n return\n clientconn.send(clientreply)", "metadata": "root.Replica.send_replybatch_to_client", "header": "['class', 'Replica', '(', 'Node', ')', ':', '___EOS___']", "index": 318 }, { "content": " def send_reply_to_client(self, clientreplycode, givenresult, command):\n if self.debug: self.logger.write(\"State\", \"Sending REPLY to CLIENT\")\n clientreply = create_message(MSG_CLIENTREPLY, self.me,\n {FLD_REPLY: givenresult,\n FLD_REPLYCODE: clientreplycode,\n FLD_INRESPONSETO: command.clientcommandnumber})\n if self.debug: self.logger.write(\"State\", \"Clientreply: %s\" % str(clientreply))\n clientconn = self.connectionpool.get_connection_by_peer(command.client)\n if clientconn == None or clientconn.thesocket == None:\n if self.debug: self.logger.write(\"State\", \"Client connection does not exist.\")\n return\n clientconn.send(clientreply)", "metadata": "root.Replica.send_reply_to_client", "header": "['class', 'Replica', '(', 'Node', ')', ':', '___EOS___']", "index": 330 }, { "content": " def perform(self, msg, designated=False):\n \"\"\"Take a given PERFORM message, add it to the set of decided commands,\n and call performcore to execute.\"\"\"\n if self.debug: self.logger.write(\"State:\", \"Performing msg %s\" % str(msg))\n if msg.commandnumber not in self.decisions:\n self.add_to_decisions(msg.commandnumber, msg.proposal)\n # If replica was using this commandnumber for a different proposal, initiate it again\n if msg.commandnumber in self.proposals and msg.proposal != self.proposals[msg.commandnumber]:\n self.pick_commandnumber_add_to_pending(self.proposals[msg.commandnumber])\n self.issue_pending_commands()\n\n while self.nexttoexecute in self.decisions:\n requestedcommand = self.decisions[self.nexttoexecute]\n if isinstance(requestedcommand, ProposalServerBatch):\n for command in requestedcommand.proposals:\n self.execute_command(command, msg, designated)\n else:\n self.execute_command(requestedcommand, msg, designated)\n self.nexttoexecute += 1\n # the window just got bumped by one\n # check if there are pending commands, and issue one of them\n self.issue_pending_commands()\n if self.debug: self.logger.write(\"State\", \"Returning from PERFORM!\")", "metadata": "root.Replica.perform", "header": "['class', 'Replica', '(', 'Node', ')', ':', '___EOS___']", "index": 343 }, { "content": " def execute_command(self, requestedcommand, msg, designated):\n # commands are executed one by one here.\n if requestedcommand in self.executed:\n if self.debug: self.logger.write(\"State\", \"Previously executed command %d.\"\n % self.nexttoexecute)\n # Execute the metacommand associated with this command\n if self.nexttoexecute > WINDOW:\n if self.debug: self.logger.write(\"State\",\n \"performcore %d\" % (self.nexttoexecute-WINDOW))\n self.performcore(self.decisions[self.nexttoexecute-WINDOW], True)\n # If we are a leader, we should send a reply to the client for this command\n # in case the client didn't receive the reply from the previous leader\n if self.isleader:\n prevrcode, prevresult, prevunblocked = self.executed[requestedcommand]\n if prevrcode == CR_BLOCK:\n # As dictionary is not sorted we have to start from the beginning every time\n for resultset in self.executed.itervalues():\n if resultset[EXC_UNBLOCKED] == requestedcommand:\n # This client has been UNBLOCKED\n prevresult = None\n prevrcode = CR_UNBLOCK\n # Send a reply to the client only if there was a client\n if type(requestedcommand.command) == str:\n commandname = requestedcommand.command\n else:\n commandname = requestedcommand.command[0]\n if (commandname not in METACOMMANDS) and (commandname != 'noop'):\n if self.debug: self.logger.write(\"State\", \"Sending reply to client.\")\n self.send_reply_to_client(prevrcode, prevresult, requestedcommand)\n elif requestedcommand not in self.executed:\n if self.debug: self.logger.write(\"State\", \"executing command %s.\" % str(requestedcommand))\n # check to see if there was a metacommand precisely WINDOW commands ago\n # that should now take effect\n # We are calling performcore 2 times, the timing gets screwed plus this\n # is very unefficient\n if self.nexttoexecute > WINDOW:\n if self.debug: self.logger.write(\"State\", \"performcore %d\" % \\\n (self.nexttoexecute-WINDOW))\n if not (isinstance(self.decisions[self.nexttoexecute-WINDOW], ProposalServerBatch) or\n isinstance(self.decisions[self.nexttoexecute-WINDOW], ProposalClientBatch)):\n self.performcore(self.decisions[self.nexttoexecute-WINDOW], True,\n designated=designated)\n if self.debug: self.logger.write(\"State\", \"performcore %s\" % str(requestedcommand))\n if isinstance(requestedcommand, ProposalClientBatch):\n self.performcore_clientbatch(requestedcommand, designated=designated)\n else:\n self.performcore(requestedcommand, designated=designated)", "metadata": "root.Replica.execute_command", "header": "['class', 'Replica', '(', 'Node', ')', ':', '___EOS___']", "index": 367 }, { "content": " def pick_commandnumber_add_to_pending(self, givenproposal):\n givencommandnumber = self.find_commandnumber()\n self.add_to_pendingcommands(givencommandnumber, givenproposal)", "metadata": "root.Replica.pick_commandnumber_add_to_pending", "header": "['class', 'Replica', '(', 'Node', ')', ':', '___EOS___']", "index": 415 }, { "content": " def issue_next_command(self):\n if self.debug: self.logger.write(\"State\", \"Pending commands: %s\" % str(self.pendingcommands))\n if self.debug: self.logger.write(\"State\", \"Pending commandset: %s\" % str(self.pendingcommandset))\n if len(self.pendingcommands) == 0:\n return\n smallestcommandnumber = sorted(self.pendingcommands.keys())[0]\n if smallestcommandnumber in self.pendingcommands:\n if self.active:\n self.do_command_propose_from_pending(smallestcommandnumber)\n else:\n self.do_command_prepare_from_pending(smallestcommandnumber)", "metadata": "root.Replica.issue_next_command", "header": "['class', 'Replica', '(', 'Node', ')', ':', '___EOS___']", "index": 419 }, { "content": " def issue_pending_commands(self):\n if self.debug: self.logger.write(\"State\", \"Pending commands: %s\" % str(self.pendingcommands))\n if len(self.pendingcommands) == 0:\n return\n sortedcommandnumbers = sorted(self.pendingcommands.keys())\n for smallestcommandnumber in sortedcommandnumbers:\n if self.active:\n self.do_command_propose_from_pending(smallestcommandnumber)\n else:\n self.do_command_prepare_from_pending(smallestcommandnumber)", "metadata": "root.Replica.issue_pending_commands", "header": "['class', 'Replica', '(', 'Node', ')', ':', '___EOS___']", "index": 431 }, { "content": " def msg_perform(self, conn, msg):\n \"\"\"received a PERFORM message, perform it and send an\n UPDATE message to the source if necessary\"\"\"\n self.perform(msg)\n\n if not self.stateuptodate:\n if self.debug: self.logger.write(\"State\", \"Updating..\")\n if msg.commandnumber == 1:\n self.stateuptodate = True\n return\n updatemessage = create_message(MSG_UPDATE, self.me)\n conn.send(updatemessage)", "metadata": "root.Replica.msg_perform", "header": "['class', 'Replica', '(', 'Node', ')', ':', '___EOS___']", "index": 442 }, { "content": " def msg_issue(self, conn, msg):\n self.issue_pending_commands()", "metadata": "root.Replica.msg_issue", "header": "['class', 'Replica', '(', 'Node', ')', ':', '___EOS___']", "index": 455 }, { "content": " def msg_helo(self, conn, msg):\n if self.debug: self.logger.write(\"State\", \"Received HELO\")\n # This is the first other replica, it should be added by this replica\n if len(self.replicas) == 0:\n if self.debug: self.logger.write(\"State\", \"Adding the first REPLICA\")\n # Agree on adding self and the first replica:\n self.become_leader()\n # Add self\n self.replicas[self.me] = 0\n addcommand = self.create_add_command(self.me)\n self.pick_commandnumber_add_to_pending(addcommand)\n for i in range(WINDOW+3):\n noopcommand = self.create_noop_command()\n self.pick_commandnumber_add_to_pending(noopcommand)\n self.issue_pending_commands()\n # Add replica\n addcommand = self.create_add_command(msg.source)\n self.pick_commandnumber_add_to_pending(addcommand)\n for i in range(WINDOW+3):\n noopcommand = self.create_noop_command()\n self.pick_commandnumber_add_to_pending(noopcommand)\n self.issue_pending_commands()\n else:\n if self.isleader:\n if self.debug: self.logger.write(\"State\", \"Adding the new node\")\n addcommand = self.create_add_command(msg.source)\n self.pick_commandnumber_add_to_pending(addcommand)\n for i in range(WINDOW+3):\n noopcommand = self.create_noop_command()\n self.pick_commandnumber_add_to_pending(noopcommand)\n self.issue_pending_commands()\n else:\n if self.debug: self.logger.write(\"State\", \"Not the leader, sending a HELOREPLY\")\n if self.debug: self.logger.write(\"State\", \"Leader is %s\" % str(self.find_leader()))\n heloreplymessage = create_message(MSG_HELOREPLY, self.me,\n {FLD_LEADER: self.find_leader()})\n conn.send(heloreplymessage)", "metadata": "root.Replica.msg_helo", "header": "['class', 'Replica', '(', 'Node', ')', ':', '___EOS___']", "index": 458 }, { "content": " def msg_update(self, conn, msg):\n \"\"\"a replica needs to be updated on the set of past decisions, send caller's decisions\"\"\"\n # This should be done only if it has not been done recently.\n with self.recentlyupdatedpeerslock:\n if msg.source in self.recentlyupdatedpeers:\n return\n updatereplymessage = create_message(MSG_UPDATEREPLY, self.me,\n {FLD_DECISIONS: self.decisions})\n conn.send(updatereplymessage)\n with self.recentlyupdatedpeerslock:\n self.recentlyupdatedpeers.append(msg.source)", "metadata": "root.Replica.msg_update", "header": "['class', 'Replica', '(', 'Node', ')', ':', '___EOS___']", "index": 496 }, { "content": " def msg_updatereply(self, conn, msg):\n \"\"\"merge decisions received with local decisions\"\"\"\n # If the node is already up-to-date, return.\n if self.stateuptodate:\n return\n for key,value in self.decisions.iteritems():\n if key in msg.decisions:\n assert self.decisions[key] == msg.decisions[key], \"Update Error\"\n # update decisions cumulatively\n self.decisions.update(msg.decisions)\n self.decisionset = set(self.decisions.values())\n self.usedcommandnumbers = self.usedcommandnumbers.union(set(self.decisions.keys()))\n # Execute the ones that we can execute\n while self.nexttoexecute in self.decisions:\n requestedcommand = self.decisions[self.nexttoexecute]\n if requestedcommand in self.executed:\n if self.debug: self.logger.write(\"State\",\n \"Previously executed command %d.\"\n % self.nexttoexecute)\n # Execute the metacommand associated with this command\n if self.nexttoexecute > WINDOW:\n if self.debug: self.logger.write(\"State\",\n \"performcore %d\"\n % (self.nexttoexecute-WINDOW))\n self.performcore(self.decisions[self.nexttoexecute-WINDOW], True)\n self.nexttoexecute += 1\n elif requestedcommand not in self.executed:\n if self.debug: self.logger.write(\"State\", \"executing command %d.\" % self.nexttoexecute)\n\n if self.nexttoexecute > WINDOW:\n if self.debug: self.logger.write(\"State\", \"performcore %d\" % \\\n (self.nexttoexecute-WINDOW))\n self.performcore(self.decisions[self.nexttoexecute-WINDOW], True)\n if self.debug: self.logger.write(\"State\", \"performcore %d\" % self.nexttoexecute)\n self.performcore(self.decisions[self.nexttoexecute])\n self.nexttoexecute += 1\n # the window got bumped\n # check if there are pending commands, and issue one of them\n self.issue_pending_commands()\n if self.debug: self.logger.write(\"State\", \"Update is done!\")\n self.stateuptodate = True", "metadata": "root.Replica.msg_updatereply", "header": "['class', 'Replica', '(', 'Node', ')', ':', '___EOS___']", "index": 508 }, { "content": " def do_noop(self):\n if self.debug: self.logger.write(\"State:\", \"doing noop!\")", "metadata": "root.Replica.do_noop", "header": "['class', 'Replica', '(', 'Node', ')', ':', '___EOS___']", "index": 550 }, { "content": " def _add_node(self, nodetype, nodename, epoch):\n nodetype = int(nodetype)\n if self.debug: self.logger.write(\"State\", \"Adding node: %s %s\" % (node_names[nodetype],\n nodename))\n ipaddr,port = nodename.split(\":\")\n nodepeer = Peer(ipaddr,int(port),nodetype)\n self.replicas[nodepeer] = 0\n\n # update the revision if nameserver\n if self.isnameserver:\n self.nameserver.update()\n\n # if leader, increment epoch in the ballotnumber\n temp = (self.ballotnumber[BALLOTEPOCH]+1,\n self.ballotnumber[BALLOTNO],\n self.ballotnumber[BALLOTNODE])\n if self.debug: self.logger.write(\"State:\", \"Incremented EPOCH: %s\" % str(temp))\n self.ballotnumber = temp\n\n # check leadership state\n if self.stateuptodate:\n chosenleader = self.find_leader()\n if chosenleader == self.me and not self.isleader:\n # become the leader\n if not self.stateuptodate:\n self.leader_initializing = True\n self.become_leader()\n elif chosenleader != self.me and self.isleader:\n # unbecome the leader\n self.unbecome_leader()", "metadata": "root.Replica._add_node", "header": "['class', 'Replica', '(', 'Node', ')', ':', '___EOS___']", "index": 553 }, { "content": " def _del_node(self, nodetype, nodename, epoch):\n nodetype = int(nodetype)\n if self.debug: self.logger.write(\"State\",\n \"Deleting node: %s %s\" % (node_names[nodetype], nodename))\n ipaddr,port = nodename.split(\":\")\n nodepeer = Peer(ipaddr,int(port),nodetype)\n try:\n del self.replicas[nodepeer]\n except KeyError:\n if self.debug: self.logger.write(\"State\",\n \"Cannot delete node that is not in the view: %s %s\"\n % (node_names[nodetype], nodename))\n # remove the node from nodesbeingdeleted\n if nodepeer in self.nodesbeingdeleted:\n self.nodesbeingdeleted.remove(nodepeer)\n\n # update the revision if nameserver\n if self.isnameserver:\n self.nameserver.update()\n\n # if leader, increment epoch in the ballotnumber\n temp = (self.ballotnumber[BALLOTEPOCH]+1,\n self.ballotnumber[BALLOTNO],\n self.ballotnumber[BALLOTNODE])\n if self.debug: self.logger.write(\"State:\", \"Incremented EPOCH: %s\" % str(temp))\n self.ballotnumber = temp\n\n # if deleted node is a replica and this replica is uptodate\n # check leadership state\n if self.stateuptodate:\n chosenleader = self.find_leader()\n if chosenleader == self.me and not self.isleader:\n # become the leader\n if not self.stateuptodate:\n self.leader_initializing = True\n self.become_leader()\n elif chosenleader != self.me and self.isleader:\n # unbecome the leader\n self.unbecome_leader()\n\n # if deleted node is self and the node is not just replaying history\n if nodepeer == self.me:\n if self.debug: self.logger.write(\"State\", \"I have been deleted from the view.\")\n self._rejoin()", "metadata": "root.Replica._del_node", "header": "['class', 'Replica', '(', 'Node', ')', ':', '___EOS___']", "index": 584 }, { "content": " def _garbage_collect(self, garbagecommandnumber, epoch):\n \"\"\" garbage collect \"\"\"\n if self.debug: self.logger.write(\"State\",\n \"Initiating garbage collection upto cmd#%d\"\n % garbagecommandnumber)\n snapshot = pickle.dumps(self.object)\n garbagemsg = create_message(MSG_GARBAGECOLLECT, self.me,\n {FLD_COMMANDNUMBER: garbagecommandnumber,\n FLD_SNAPSHOT: snapshot})\n self.send(garbagemsg,group=self.replicas)\n # do local garbage collection\n self.local_garbage_collect(garbagecommandnumber)", "metadata": "root.Replica._garbage_collect", "header": "['class', 'Replica', '(', 'Node', ')', ':', '___EOS___']", "index": 629 }, { "content": " def local_garbage_collect(self, commandnumber):\n \"\"\"\n Truncates decisions, executed and proposals\n up to given commandnumber\n \"\"\"\n keys = sorted(self.decisions.keys())\n # Sanity checking\n lastkey = keys[0]\n candelete = True\n for cmdno in keys:\n if cmdno == lastkey:\n lastkey += 1\n else:\n candelete = False\n break\n # Truncating\n if not candelete:\n return False\n for cmdno in keys:\n if cmdno < commandnumber:\n if self.decisions[cmdno] in self.executed:\n del self.executed[self.decisions[cmdno]]\n try:\n del self.proposals[cmdno]\n except:\n pass\n #del self.decisions[cmdno]\n else:\n break\n return True", "metadata": "root.Replica.local_garbage_collect", "header": "['class', 'Replica', '(', 'Node', ')', ':', '___EOS___']", "index": 642 }, { "content": " def become_leader(self):\n \"\"\"Leader State\n - active: indicates if the Leader has a *good* ballotnumber\n - ballotnumber: the highest ballotnumber Leader has used\n - outstandingprepares: ResponseCollector dictionary for MSG_PREPARE,\n indexed by ballotnumber\n - outstandingproposes: ResponseCollector dictionary for MSG_PROPOSE,\n indexed by commandnumber\n - receivedclientrequests: commands received from clients as\n <(client,clientcommandnumber):command> mappings\n - backoff: backoff amount that is used to determine how much a leader should\n backoff during a collusion\n - commandgap: next commandnumber that will be used by this leader\n \"\"\"\n if not self.isleader:\n self.isleader = True\n self.active = False\n self.outstandingprepares = {}\n self.outstandingproposes = {}\n self.receivedclientrequests = {}\n self.backoff = 0\n self.commandgap = 1\n self.leader_initializing = True\n\n backoff_thread = Thread(target=self.update_backoff)\n backoff_event.clear()\n backoff_thread.start()\n if self.debug: self.logger.write(\"State\", \"Becoming LEADER!\")", "metadata": "root.Replica.become_leader", "header": "['class', 'Replica', '(', 'Node', ')', ':', '___EOS___']", "index": 674 }, { "content": " def unbecome_leader(self):\n \"\"\"drop LEADER state, become a replica\"\"\"\n # fail-stop tolerance, coupled with retries in the client, mean that a\n # leader can at any time discard all of its internal state and the protocol\n # will still work correctly.\n if self.debug: self.logger.write(\"State:\", \"Unbecoming LEADER!\")\n self.isleader = False\n backoff_event.set()", "metadata": "root.Replica.unbecome_leader", "header": "['class', 'Replica', '(', 'Node', ')', ':', '___EOS___']", "index": 703 }, { "content": " def update_backoff(self):\n \"\"\"used by the backoffthread to decrease the backoff amount by half periodically\"\"\"\n while not backoff_event.isSet():\n self.backoff = self.backoff/2\n backoff_event.wait(BACKOFFDECREASETIMEOUT)", "metadata": "root.Replica.update_backoff", "header": "['class', 'Replica', '(', 'Node', ')', ':', '___EOS___']", "index": 712 }, { "content": " def detect_colliding_leader(self, ballotnumber):\n \"\"\"detects a colliding leader from the highest ballotnumber received from replicas\"\"\"\n otherleader_addr,otherleader_port = ballotnumber[BALLOTNODE].split(\":\")\n otherleader = Peer(otherleader_addr, int(otherleader_port), NODE_REPLICA)\n return otherleader", "metadata": "root.Replica.detect_colliding_leader", "header": "['class', 'Replica', '(', 'Node', ')', ':', '___EOS___']", "index": 718 }, { "content": " def leader_is_alive(self):\n \"\"\"returns a tuple if the leader is alive and the currentleader\"\"\"\n currentleader = self.find_leader()\n if currentleader != self.me:\n if self.debug: self.logger.write(\"State\", \"Sending PING to %s\" % str(currentleader))\n pingmessage = create_message(MSG_PING, self.me)\n successid = self.send(pingmessage, peer=currentleader)\n if successid < 0:\n self.replicas[currentleader] += 1\n return False, currentleader\n return True, currentleader", "metadata": "root.Replica.leader_is_alive", "header": "['class', 'Replica', '(', 'Node', ')', ':', '___EOS___']", "index": 724 }, { "content": " def find_leader(self):\n \"\"\"returns the minimum peer that is alive as the leader\"\"\"\n # sort the replicas first\n replicas = sorted(self.replicas.items(), key=lambda t: t[0])\n if self.debug: self.logger.write(\"State\", \"All Replicas in my view:%s\" %str(replicas))\n for (replica,liveness) in replicas:\n if liveness == 0:\n del replicas\n if self.debug: self.logger.write(\"State\", \"Leader is %s\" %str(replica))\n return replica\n del replicas\n if self.debug: self.logger.write(\"State\", \"Leader is me\")\n return self.me", "metadata": "root.Replica.find_leader", "header": "['class', 'Replica', '(', 'Node', ')', ':', '___EOS___']", "index": 736 }, { "content": " def update_ballotnumber(self, seedballotnumber):\n \"\"\"update the ballotnumber with a higher value than the given ballotnumber\"\"\"\n assert seedballotnumber[BALLOTEPOCH] == self.ballotnumber[BALLOTEPOCH], \\\n \"%s is in epoch %d instead of %d\" % \\\n (str(self.me), seedballotnumber[BALLOTEPOCH], self.ballotnumber[BALLOTEPOCH])\n temp = (self.ballotnumber[BALLOTEPOCH],\n seedballotnumber[BALLOTNO]+1,\n self.ballotnumber[BALLOTNODE])\n if self.debug: self.logger.write(\"State:\", \"Updated ballotnumber to %s\" % str(temp))\n self.ballotnumber = temp", "metadata": "root.Replica.update_ballotnumber", "header": "['class', 'Replica', '(', 'Node', ')', ':', '___EOS___']", "index": 750 }, { "content": " def find_commandnumber(self):\n \"\"\"returns the first gap in proposals and decisions combined\"\"\"\n while self.commandgap <= len(self.usedcommandnumbers):\n if self.commandgap in self.usedcommandnumbers:\n self.commandgap += 1\n else:\n if self.debug: self.logger.write(\"State\", \"Picked command number: %d\" % self.commandgap)\n self.usedcommandnumbers.add(self.commandgap)\n return self.commandgap\n if self.debug: self.logger.write(\"State\", \"Picked command number: %d\" % self.commandgap)\n self.usedcommandnumbers.add(self.commandgap)\n return self.commandgap", "metadata": "root.Replica.find_commandnumber", "header": "['class', 'Replica', '(', 'Node', ')', ':', '___EOS___']", "index": 761 }, { "content": " def add_to_executed(self, key, value):\n self.executed[key] = value", "metadata": "root.Replica.add_to_executed", "header": "['class', 'Replica', '(', 'Node', ')', ':', '___EOS___']", "index": 774 }, { "content": " def add_to_decisions(self, key, value):\n self.decisions[key] = value\n if isinstance(value, ProposalServerBatch):\n for item in value.proposals:\n self.decisionset.add(item)\n else:\n self.decisionset.add(value)\n self.usedcommandnumbers.add(key)", "metadata": "root.Replica.add_to_decisions", "header": "['class', 'Replica', '(', 'Node', ')', ':', '___EOS___']", "index": 777 }, { "content": " def add_to_proposals(self, key, value):\n self.proposals[key] = value\n if isinstance(value, ProposalServerBatch):\n for item in value.proposals:\n self.proposalset.add(item)\n else:\n self.proposalset.add(value)\n self.usedcommandnumbers.add(key)", "metadata": "root.Replica.add_to_proposals", "header": "['class', 'Replica', '(', 'Node', ')', ':', '___EOS___']", "index": 786 }, { "content": " def add_to_pendingcommands(self, key, value):\n # If a Replica adds a pendingcommand before it is up to date\n # it assigns 1 as a commandnumber for a command. This later\n # gets overwritten when the same command is added later with\n # a higher commandnumber in the pendingcommandset but not in\n # in the pendingcommands as they have different keys. The case\n # that causes this to happen should be prevented, adding an if\n # case in this function will not fix the logic, will just get rid\n # of the symptom.\n self.pendingcommands[key] = value\n if isinstance(value, ProposalServerBatch):\n for item in value.proposals:\n self.pendingcommandset.add(item)\n else:\n self.pendingcommandset.add(value)", "metadata": "root.Replica.add_to_pendingcommands", "header": "['class', 'Replica', '(', 'Node', ')', ':', '___EOS___']", "index": 795 }, { "content": " def remove_from_executed(self, key):\n del self.executed[key]", "metadata": "root.Replica.remove_from_executed", "header": "['class', 'Replica', '(', 'Node', ')', ':', '___EOS___']", "index": 811 }, { "content": " def remove_from_decisions(self, key):\n value = self.decisions[key]\n if isinstance(value, ProposalServerBatch):\n for item in value.proposals:\n self.decisionset.remove(item)\n else:\n self.decisionset.remove(value)\n del self.decisions[key]\n self.usedcommandnumbers.remove(key)\n self.commandgap = key", "metadata": "root.Replica.remove_from_decisions", "header": "['class', 'Replica', '(', 'Node', ')', ':', '___EOS___']", "index": 814 }, { "content": " def remove_from_proposals(self, key):\n value = self.proposals[key]\n if isinstance(value, ProposalServerBatch):\n for item in value.proposals:\n self.proposalset.remove(item)\n else:\n self.proposalset.remove(value)\n del self.proposals[key]\n self.usedcommandnumbers.remove(key)\n self.commandgap = key", "metadata": "root.Replica.remove_from_proposals", "header": "['class', 'Replica', '(', 'Node', ')', ':', '___EOS___']", "index": 825 }, { "content": " def remove_from_pendingcommands(self, key):\n value = self.pendingcommands[key]\n if isinstance(value, ProposalServerBatch):\n for item in value.proposals:\n self.pendingcommandset.remove(item)\n else:\n self.pendingcommandset.remove(value)\n del self.pendingcommands[key]", "metadata": "root.Replica.remove_from_pendingcommands", "header": "['class', 'Replica', '(', 'Node', ')', ':', '___EOS___']", "index": 836 }, { "content": " def handle_client_command(self, givencommand, sendcount=1, prepare=False):\n \"\"\"handle received command\n - if it has been received before check if it has been executed\n -- if it has been executed send the result\n -- if it has not been executed yet send INPROGRESS\n - if this request has not been received before initiate a Paxos round for the command\"\"\"\n if not self.isleader:\n if self.debug: self.logger.write(\"Error\", \"Should not have come here: Called to handle client command but not Leader.\")\n clientreply = create_message(MSG_CLIENTREPLY, self.me,\n {FLD_REPLY: '',\n FLD_REPLYCODE: CR_REJECTED,\n FLD_INRESPONSETO: givencommand.clientcommandnumber})\n if self.debug: self.logger.write(\"State\", \"Rejecting clientrequest: %s\" % str(clientreply))\n conn = self.connectionpool.get_connection_by_peer(givencommand.client)\n if conn is not None:\n conn.send(clientreply)\n else:\n if self.debug: self.logger.write(\"Error\", \"Cannot create connection to client\")\n return\n\n if sendcount > 0 and (givencommand.client,\n givencommand.clientcommandnumber) in self.receivedclientrequests:\n if self.debug: self.logger.write(\"State\", \"Client request received previously:\")\n if self.debug: self.logger.write(\"State\", \"Client: %s Commandnumber: %s Replicas: %s\"\n % (str(givencommand.client),\n str(givencommand.clientcommandnumber),\n str(self.replicas)))\n # Check if the request has been executed\n if givencommand in self.executed:\n # send REPLY\n clientreply = create_message(MSG_CLIENTREPLY, self.me,\n {FLD_REPLY: self.executed[givencommand][EXC_RESULT],\n FLD_REPLYCODE: self.executed[givencommand][EXC_RCODE],\n FLD_INRESPONSETO: givencommand.clientcommandnumber})\n if self.debug: self.logger.write(\"State\", \"Sending Clientreply: %s\" % str(clientreply))\n # Check if the request is somewhere in the Paxos pipeline\n elif givencommand in self.pendingcommandset or \\\n givencommand in self.proposalset or \\\n givencommand in self.decisionset:\n # send INPROGRESS\n clientreply = create_message(MSG_CLIENTREPLY, self.me,\n {FLD_REPLY: '',\n FLD_REPLYCODE: CR_INPROGRESS,\n FLD_INRESPONSETO: givencommand.clientcommandnumber})\n if self.debug: self.logger.write(\"State\", \"Sending INPROGRESS: %s\\nReplicas: %s\"\n % (str(clientreply),str(self.replicas)))\n conn = self.connectionpool.get_connection_by_peer(givencommand.client)\n if conn is not None:\n conn.send(clientreply)\n else:\n if self.debug: self.logger.write(\"Error\", \"Cannot create connection to client\")\n else:\n # The caller haven't received this command before\n self.receivedclientrequests[(givencommand.client,\n givencommand.clientcommandnumber)] = givencommand\n if self.debug: self.logger.write(\"State\",\n \"Initiating command. Leader is active: %s\" % self.active)\n self.pick_commandnumber_add_to_pending(givencommand)\n self.issue_pending_commands()", "metadata": "root.Replica.handle_client_command", "header": "['class', 'Replica', '(', 'Node', ')', ':', '___EOS___']", "index": 845 }, { "content": " def handle_client_command_batch(self, msgconnlist, prepare=False):\n \"\"\"handle received command\n - if it has been received before check if it has been executed\n -- if it has been executed send the result\n -- if it has not been executed yet send INPROGRESS\n - if this request has not been received before initiate a Paxos round for the command\"\"\"\n if not self.isleader:\n if self.debug: self.logger.write(\"Error\",\n \"Should not have come here: Not Leader.\")\n for (msg,conn) in msgconnlist:\n clientreply = create_message(MSG_CLIENTREPLY, self.me,\n {FLD_REPLY: '',\n FLD_REPLYCODE: CR_REJECTED,\n FLD_INRESPONSETO: msg.command.clientcommandnumber})\n conn.send(clientreply)\n return\n\n clientreply = None\n commandstohandle = []\n for (msg,conn) in msgconnlist:\n if msg.sendcount == 0:\n # The caller haven't received this command before\n self.receivedclientrequests[(msg.command.client,\n msg.command.clientcommandnumber)] = msg.command\n commandstohandle.append(msg.command)\n continue\n if (msg.command.client, msg.command.clientcommandnumber) in self.receivedclientrequests:\n if self.debug: self.logger.write(\"State\", \"Client request received previously:\")\n # Check if the request has been executed\n if msg.command in self.executed:\n # send REPLY\n clientreply = create_message(MSG_CLIENTREPLY, self.me,\n {FLD_REPLY: self.executed[msg.command][EXC_RESULT],\n FLD_REPLYCODE: self.executed[msg.command][EXC_RCODE],\n FLD_INRESPONSETO: msg.command.clientcommandnumber})\n if self.debug: self.logger.write(\"State\", \"Clientreply: %s\" % str(clientreply))\n # Check if the request is somewhere in the Paxos pipeline\n elif msg.command in self.pendingcommandset or msg.command in self.proposalset \\\n or msg.command in self.decisionset:\n # send INPROGRESS\n clientreply = create_message(MSG_CLIENTREPLY, self.me,\n {FLD_REPLY: '',\n FLD_REPLYCODE: CR_INPROGRESS,\n FLD_INRESPONSETO: msg.command.clientcommandnumber})\n if self.debug: self.logger.write(\"State\", \"Clientreply: %s\\nReplicas: %s\"\n % (str(clientreply),str(self.replicas)))\n if clientreply:\n conn.send(clientreply)\n if self.debug: self.logger.write(\"State\", \"Initiating a new command. Leader is active: %s\" % self.active)\n # Check if batching is still required\n if len(commandstohandle) == 0:\n return\n elif len(commandstohandle) == 1:\n self.pick_commandnumber_add_to_pending(commandstohandle[0])\n else:\n self.pick_commandnumber_add_to_pending(ProposalServerBatch(commandstohandle))\n self.issue_pending_commands()", "metadata": "root.Replica.handle_client_command_batch", "header": "['class', 'Replica', '(', 'Node', ')', ':', '___EOS___']", "index": 905 }, { "content": " def send_reject_to_client(self, conn, clientcommandnumber):\n conn.send(create_message(MSG_CLIENTREPLY, self.me,\n {FLD_REPLY: '',\n FLD_REPLYCODE: CR_REJECTED,\n FLD_INRESPONSETO: clientcommandnumber}))", "metadata": "root.Replica.send_reject_to_client", "header": "['class', 'Replica', '(', 'Node', ')', ':', '___EOS___']", "index": 963 }, { "content": " def msg_clientbatch(self, conn, msg):\n self.msg_clientrequest(conn, msg)", "metadata": "root.Replica.msg_clientbatch", "header": "['class', 'Replica', '(', 'Node', ')', ':', '___EOS___']", "index": 968 }, { "content": " def msg_clientrequest(self, conn, msg):\n \"\"\"called holding self.lock\n handles clientrequest message received according to replica's state\n - if not leader: reject\n - if leader: add connection to client connections and handle request\"\"\"\n if len(self.replicas) == 0:\n if self.debug: self.logger.write(\"State\", \"Adding SELF\")\n # Agree on adding self and the first replica:\n self.become_leader()\n # Add self\n self.replicas[self.me] = 0\n addcommand = self.create_add_command(self.me)\n self.pick_commandnumber_add_to_pending(addcommand)\n for i in range(WINDOW+3):\n noopcommand = self.create_noop_command()\n self.pick_commandnumber_add_to_pending(noopcommand)\n self.issue_pending_commands()\n return\n if not self.stateuptodate:\n return\n if self.isleader:\n # if leader, handle the clientrequest\n if self.token and msg.token != self.token:\n if self.debug: self.logger.write(\"Error\", \"Security Token mismatch.\")\n self.send_reject_to_client(conn, msg.command.clientcommandnumber)\n else:\n if self.debug: self.logger.write(\"State\", \"I'm the leader, handling the request.\")\n self.handle_client_command(msg.command, msg.sendcount,\n prepare=self.leader_initializing)\n else:\n leaderalive, leader = self.leader_is_alive()\n if leaderalive and leader != self.me:\n if self.debug: self.logger.write(\"State\", \"Not Leader: Rejecting CLIENTREQUEST\")\n self.send_reject_to_client(conn, msg.command.clientcommandnumber)\n elif leader == self.me:\n # check if should become leader\n self.become_leader()\n if self.token and msg.token != self.token:\n if self.debug: self.logger.write(\"Error\", \"Security Token mismatch.\")\n self.send_reject_to_client(conn, msg.command.clientcommandnumber)\n else:\n self.handle_client_command(msg.command, msg.sendcount,\n prepare=self.leader_initializing)\n elif not leaderalive and self.find_leader() == self.me:\n # check if should become leader\n self.become_leader()\n if leader not in self.nodesbeingdeleted and leader in self.replicas:\n # if leader is not already (being) deleted\n # take old leader out of the configuration\n if self.debug: self.logger.write(\"State\",\n \"Taking old leader out of the configuration.\")\n self.nodesbeingdeleted.add(leader)\n delcommand = self.create_delete_command(leader)\n self.pick_commandnumber_add_to_pending(delcommand)\n for i in range(WINDOW):\n noopcommand = self.create_noop_command()\n self.pick_commandnumber_add_to_pending(noopcommand)\n self.issue_pending_commands()\n # Check token and answer to client\n if self.token and msg.token != self.token:\n if self.debug: self.logger.write(\"Error\", \"Security Token mismatch.\")\n self.send_reject_to_client(conn, msg.command.clientcommandnumber)\n else:\n self.handle_client_command(msg.command, msg.sendcount,\n prepare=self.leader_initializing)", "metadata": "root.Replica.msg_clientrequest", "header": "['class', 'Replica', '(', 'Node', ')', ':', '___EOS___']", "index": 971 }, { "content": " def msg_clientrequest_batch(self, msgconnlist):\n \"\"\"called holding self.lock\n handles clientrequest messages that are batched together\"\"\"\n if len(self.replicas) == 0:\n if self.debug: self.logger.write(\"State\", \"Adding SELF\")\n # Agree on adding self and the first replica:\n self.become_leader()\n # Add self\n self.replicas[self.me] = 0\n addcommand = self.create_add_command(self.me)\n self.pick_commandnumber_add_to_pending(addcommand)\n for i in range(WINDOW+3):\n noopcommand = self.create_noop_command()\n self.pick_commandnumber_add_to_pending(noopcommand)\n self.issue_pending_commands()\n return\n if not self.stateuptodate:\n return\n if self.isleader:\n # if leader, handle the clientrequest\n for (msg,conn) in msgconnlist:\n if self.token and msg.token != self.token:\n if self.debug: self.logger.write(\"Error\", \"Security Token mismatch.\")\n self.send_reject_to_client(conn, msg.command.clientcommandnumber)\n msgconnlist.remove((msg,conn))\n self.handle_client_command_batch(msgconnlist, prepare=self.leader_initializing)\n else:\n leaderalive, leader = self.leader_is_alive()\n if leaderalive and leader != self.me:\n if self.debug: self.logger.write(\"State\", \"Not Leader: Rejecting all CLIENTREQUESTS\")\n for (msg,conn) in msgconnlist:\n self.send_reject_to_client(conn, msg.command.clientcommandnumber)\n elif leader == self.me:\n # check if should become leader\n self.become_leader()\n for (msg,conn) in msgconnlist:\n if self.token and msg.token != self.token:\n if self.debug: self.logger.write(\"Error\", \"Security Token mismatch.\")\n self.send_reject_to_client(conn, msg.command.clientcommandnumber)\n msgconnlist.remove((msg,conn))\n self.handle_client_command_batch(msgconnlist, prepare=self.leader_initializing)\n elif not leaderalive and self.find_leader() == self.me:\n self.become_leader()\n\n if leader not in self.nodesbeingdeleted and leader in self.replicas:\n # if leader is not already (being) deleted\n # take old leader out of the configuration\n if self.debug: self.logger.write(\"State\",\n \"Taking old leader out of the configuration.\")\n self.nodesbeingdeleted.add(leader)\n delcommand = self.create_delete_command(leader)\n self.pick_commandnumber_add_to_pending(delcommand)\n for i in range(WINDOW):\n noopcommand = self.create_noop_command()\n self.pick_commandnumber_add_to_pending(noopcommand)\n # Check token and answer to client\n for (msg,conn) in msgconnlist:\n if self.token and msg.token != self.token:\n if self.debug: self.logger.write(\"Error\", \"Security Token mismatch.\")\n self.send_reject_to_client(conn, msg.command.clientcommandnumber)\n msgconnlist.remove((msg,conn))\n self.handle_client_command_batch(msgconnlist, prepare=self.leader_initializing)", "metadata": "root.Replica.msg_clientrequest_batch", "header": "['class', 'Replica', '(', 'Node', ')', ':', '___EOS___']", "index": 1037 }, { "content": " def msg_clientreply(self, conn, msg):\n \"\"\"this only occurs in response to commands initiated by the shell\"\"\"\n return", "metadata": "root.Replica.msg_clientreply", "header": "['class', 'Replica', '(', 'Node', ')', ':', '___EOS___']", "index": 1100 }, { "content": " def do_command_propose_from_pending(self, givencommandnumber):\n \"\"\"Initiates givencommandnumber from pendingcommands list.\n Stage p2a.\n - Remove command from pending and transfer it to proposals\n - If no Replicas, retreat and return\n - Else start from the PROPOSE STAGE:\n -- create MSG_PROPOSE: message carries ballotnumber, commandnumber, proposal\n -- create ResponseCollector object for PROPOSE STAGE:\n ResponseCollector keeps the state related to MSG_PROPOSE\n -- add the ResponseCollector to the outstanding propose set\n -- send MSG_PROPOSE to Replica nodes\n \"\"\"\n givenproposal = self.pendingcommands[givencommandnumber]\n self.remove_from_pendingcommands(givencommandnumber)\n self.add_to_proposals(givencommandnumber, givenproposal)\n recentballotnumber = self.ballotnumber\n if self.debug: self.logger.write(\"State\", \"Proposing command: %d:%s with ballotnumber %s\"\n % (givencommandnumber,givenproposal,str(recentballotnumber)))\n # Since we never propose a commandnumber that is beyond the window,\n # we can simply use the current replica set here\n prc = ResponseCollector(self.replicas, recentballotnumber,\n givencommandnumber, givenproposal)\n if len(prc.quorum) == 0:\n if self.debug: self.logger.write(\"Error\", \"There are no Replicas, returning!\")\n self.remove_from_proposals(givencommandnumber)\n self.pick_commandnumber_add_to_pending(givenproposal)\n return\n self.outstandingproposes[givencommandnumber] = prc\n propose = create_message(MSG_PROPOSE, self.me,\n {FLD_BALLOTNUMBER: recentballotnumber,\n FLD_COMMANDNUMBER: givencommandnumber,\n FLD_PROPOSAL: givenproposal,\n FLD_SERVERBATCH: isinstance(givenproposal, ProposalServerBatch)})\n self.send(propose, group=prc.quorum)", "metadata": "root.Replica.do_command_propose_from_pending", "header": "['class', 'Replica', '(', 'Node', ')', ':', '___EOS___']", "index": 1105 }, { "content": " def do_command_prepare_from_pending(self, givencommandnumber):\n \"\"\"Initiates givencommandnumber from pendingcommands list.\n Stage p1a.\n - Remove command from pending and transfer it to proposals\n - If no Replicas, retreat and return\n - Else start from the PREPARE STAGE:\n -- create MSG_PREPARE: message carries the corresponding ballotnumber\n -- create ResponseCollector object for PREPARE STAGE:\n ResponseCollector keeps the state related to MSG_PREPARE\n -- add the ResponseCollector to the outstanding prepare set\n -- send MSG_PREPARE to Replica nodes\n \"\"\"\n givenproposal = self.pendingcommands[givencommandnumber]\n self.remove_from_pendingcommands(givencommandnumber)\n self.add_to_proposals(givencommandnumber, givenproposal)\n newballotnumber = self.ballotnumber\n if self.debug: self.logger.write(\"State\", \"Preparing command: %d:%s with ballotnumber %s\"\n % (givencommandnumber, givenproposal,str(newballotnumber)))\n prc = ResponseCollector(self.replicas, newballotnumber,\n givencommandnumber, givenproposal)\n if len(prc.quorum) == 0:\n if self.debug: self.logger.write(\"Error\", \"There are no Replicas, returning!\")\n self.remove_from_proposals(givencommandnumber)\n self.pick_commandnumber_add_to_pending(givenproposal)\n return\n self.outstandingprepares[newballotnumber] = prc\n prepare = create_message(MSG_PREPARE, self.me,\n {FLD_BALLOTNUMBER: newballotnumber})\n self.send(prepare, group=prc.quorum)", "metadata": "root.Replica.do_command_prepare_from_pending", "header": "['class', 'Replica', '(', 'Node', ')', ':', '___EOS___']", "index": 1140 }, { "content": " def msg_prepare(self, conn, msg):\n \"\"\"\n MSG_PREPARE is accepted only if it carries a ballotnumber greater\n than the highest ballotnumber Replica has ever received.\n\n Replies:\n - MSG_PREPARE_ADOPTED carries the ballotnumber that is received and\n all pvalues accepted thus far.\n - MSG_PREPARE_PREEMPTED carries the highest ballotnumber Replica\n has seen and all pvalues accepted thus far.\n \"\"\"\n # this ballot should be strictly higher than previously accepted ballots\n if msg.ballotnumber >= self.quorumballotnumber:\n if self.debug: self.logger.write(\"Paxos State\",\n \"prepare received with acceptable ballotnumber %s\"\n % str(msg.ballotnumber))\n\n self.quorumballotnumber = msg.ballotnumber\n self.last_accept_msg_id = msg.id\n replymsg = create_message(MSG_PREPARE_ADOPTED, self.me,\n {FLD_BALLOTNUMBER: self.quorumballotnumber,\n FLD_INRESPONSETO: msg.ballotnumber,\n FLD_PVALUESET: self.quorumaccepted.pvalues})\n st = 'ADOPTED'\n # or else it should be a precise duplicate of the last request\n # in this case we do nothing\n elif msg.ballotnumber == self.quorumballotnumber and \\\n msg.id == self.last_accept_msg_id:\n if self.debug: self.logger.write(\"Paxos State\",\"message received before: %s\" % msg)\n return\n else:\n if self.debug: self.logger.write(\"Paxos State\",\n (\"prepare received with non-acceptable \"\n \"ballotnumber %s \") % (str(msg.ballotnumber),))\n self.last_accept_msg_id = msg.id\n replymsg = create_message(MSG_PREPARE_PREEMPTED, self.me,\n {FLD_BALLOTNUMBER: self.quorumballotnumber,\n FLD_INRESPONSETO: msg.ballotnumber,\n FLD_PVALUESET: self.quorumaccepted.pvalues})\n st = 'PREEMPTED'\n if self.debug: self.logger.write(\"Paxos State\", \"Prepare responding %s with %s to %s\"\n % (st, str(self.quorumballotnumber), str(msg.ballotnumber)))\n conn.send(replymsg)", "metadata": "root.Replica.msg_prepare", "header": "['class', 'Replica', '(', 'Node', ')', ':', '___EOS___']", "index": 1171 }, { "content": " def msg_propose(self, conn, msg):\n \"\"\"\n MSG_PROPOSE is accepted only if it carries a ballotnumber greater\n than the highest ballotnumber Replica has received.\n\n Replies:\n - MSG_PROPOSE_ACCEPT carries ballotnumber and commandnumber received.\n - MSG_PROPOSE_REJECT carries the highest ballotnumber Replica has\n seen and the commandnumber that is received.\n \"\"\"\n if msg.ballotnumber >= self.quorumballotnumber:\n if self.debug: self.logger.write(\"Paxos State\",\n \"propose received with acceptable ballotnumber %s\"\n % str(msg.ballotnumber))\n self.quorumballotnumber = msg.ballotnumber\n newpvalue = PValue(msg.ballotnumber,msg.commandnumber,msg.proposal)\n self.quorumaccepted.add(newpvalue)\n replymsg = create_message(MSG_PROPOSE_ACCEPT, self.me,\n {FLD_BALLOTNUMBER: self.quorumballotnumber,\n FLD_INRESPONSETO: msg.ballotnumber,\n FLD_COMMANDNUMBER: msg.commandnumber})\n conn.send(replymsg)\n if self.durable:\n self.file.write(str(newpvalue))\n os.fsync(self.file)\n else:\n if self.debug: self.logger.write(\"Paxos State\",\n \"propose received with non-acceptable ballotnumber %s\"\n % str(msg.ballotnumber))\n replymsg = create_message(MSG_PROPOSE_REJECT, self.me,\n {FLD_BALLOTNUMBER: self.quorumballotnumber,\n FLD_INRESPONSETO: msg.ballotnumber,\n FLD_COMMANDNUMBER: msg.commandnumber})\n conn.send(replymsg)", "metadata": "root.Replica.msg_propose", "header": "['class', 'Replica', '(', 'Node', ')', ':', '___EOS___']", "index": 1215 }, { "content": " def msg_garbagecollect(self, conn, msg):\n if self.debug: self.logger.write(\"Paxos State\",\n \"Doing garbage collection upto %d\" % msg.commandnumber)\n success = self.quorumaccepted.truncateto(msg.commandnumber)\n if success:\n self.objectsnapshot = (msg.commandnumber,pickle.loads(msg.snapshot))\n else:\n if self.debug: self.logger.write(\"Garbage Collection Error\",\n \"Garbege Collection failed.\")", "metadata": "root.Replica.msg_garbagecollect", "header": "['class', 'Replica', '(', 'Node', ')', ':', '___EOS___']", "index": 1250 }, { "content": " def msg_prepare_adopted(self, conn, msg):\n \"\"\"MSG_PREPARE_ADOPTED is handled only if it belongs to an outstanding MSG_PREPARE,\n otherwise it is discarded.\n When MSG_PREPARE_ADOPTED is received, the corresponding ResponseCollector is retrieved\n and its state is updated accordingly.\n\n State Updates:\n - message is added to the received dictionary\n - the pvalue with the ResponseCollector's commandnumber is added to the possiblepvalueset\n - if naccepts is greater than the quorum size PREPARE STAGE is successful.\n -- Start the PROPOSE STAGE:\n --- create the pvalueset with highest ballotnumbers for distinctive commandnumbers\n --- update own proposals dictionary according to pmax dictionary\n --- remove the old ResponseCollector from the outstanding prepare set\n --- run the PROPOSE STAGE for each pvalue in proposals dictionary\n ---- create ResponseCollector object for PROPOSE STAGE: ResponseCollector keeps\n the state related to MSG_PROPOSE\n ---- add the new ResponseCollector to the outstanding propose set\n ---- create MSG_PROPOSE: message carries the corresponding ballotnumber, commandnumber and the proposal\n ---- send MSG_PROPOSE to the same Replica nodes from the PREPARE STAGE\n \"\"\"\n if msg.inresponseto in self.outstandingprepares:\n prc = self.outstandingprepares[msg.inresponseto]\n prc.receivedcount += 1\n prc.receivedfrom.add(conn.peerid)\n if self.debug: self.logger.write(\"Paxos State\",\n \"got an accept for ballotno %s \"\\\n \"commandno %s proposal %s with %d/%d\"\\\n % (prc.ballotnumber, prc.commandnumber, prc.proposal,\n prc.receivedcount, prc.ntotal))\n assert msg.ballotnumber == prc.ballotnumber, \"[%s] MSG_PREPARE_ADOPTED cannot have non-matching ballotnumber\" % self\n # add all the p-values from the response to the possiblepvalueset\n if msg.pvalueset is not None:\n prc.possiblepvalueset.union(msg.pvalueset)\n\n if prc.receivedcount >= prc.nquorum:\n if self.debug: self.logger.write(\"Paxos State\", \"suffiently many accepts on prepare!\")\n # take this response collector out of the outstanding prepare set\n del self.outstandingprepares[msg.inresponseto]\n # choose pvalues with distinctive commandnumbers and highest ballotnumbers\n pmaxset = prc.possiblepvalueset.pmax()\n for commandnumber,proposal in pmaxset.iteritems():\n self.add_to_proposals(commandnumber, proposal)\n # If the commandnumber we were planning to use is overwritten\n # we should try proposing with a new commandnumber\n if self.proposals[prc.commandnumber] != prc.proposal:\n self.pick_commandnumber_add_to_pending(prc.proposal)\n self.issue_pending_commands()\n for chosencommandnumber,chosenproposal in self.proposals.iteritems():\n # send proposals for every outstanding proposal that is collected\n if self.debug: self.logger.write(\"Paxos State\", \"Sending PROPOSE for %d, %s\"\n % (chosencommandnumber, chosenproposal))\n newprc = ResponseCollector(prc.quorum, prc.ballotnumber,\n chosencommandnumber, chosenproposal)\n self.outstandingproposes[chosencommandnumber] = newprc\n propose = create_message(MSG_PROPOSE, self.me,\n {FLD_BALLOTNUMBER: prc.ballotnumber,\n FLD_COMMANDNUMBER: chosencommandnumber,\n FLD_PROPOSAL: chosenproposal,\n FLD_SERVERBATCH: isinstance(chosenproposal,\n ProposalServerBatch)})\n self.send(propose, group=newprc.quorum)\n # As leader collected all proposals its state is up-to-date\n # and it is done initializing\n self.leader_initializing = False\n self.stateuptodate = True\n # become active\n self.active = True", "metadata": "root.Replica.msg_prepare_adopted", "header": "['class', 'Replica', '(', 'Node', ')', ':', '___EOS___']", "index": 1261 }, { "content": " def msg_prepare_preempted(self, conn, msg):\n \"\"\"MSG_PREPARE_PREEMPTED is handled only if it belongs to an outstanding MSG_PREPARE,\n otherwise it is discarded.\n A MSG_PREPARE_PREEMPTED causes the PREPARE STAGE to be unsuccessful, hence the current\n state is deleted and a ne PREPARE STAGE is initialized.\n\n State Updates:\n - kill the PREPARE STAGE that received a MSG_PREPARE_PREEMPTED\n -- remove the old ResponseCollector from the outstanding prepare set\n - remove the command from proposals, add it to pendingcommands\n - update the ballotnumber\n - initiate command\n \"\"\"\n if msg.inresponseto in self.outstandingprepares:\n prc = self.outstandingprepares[msg.inresponseto]\n if self.debug: self.logger.write(\"Paxos State\",\n \"got a reject for ballotno %s proposal %s with %d/%d\"\n % (prc.ballotnumber, prc.proposal,\n prc.receivedcount, prc.ntotal))\n # take this response collector out of the outstanding prepare set\n del self.outstandingprepares[msg.inresponseto]\n # become inactive\n self.active = False\n # handle reject\n self._handlereject(msg, prc)", "metadata": "root.Replica.msg_prepare_preempted", "header": "['class', 'Replica', '(', 'Node', ')', ':', '___EOS___']", "index": 1330 }, { "content": " def msg_propose_accept(self, conn, msg):\n \"\"\"MSG_PROPOSE_ACCEPT is handled only if it belongs to an outstanding MSG_PREPARE,\n otherwise it is discarded.\n When MSG_PROPOSE_ACCEPT is received, the corresponding ResponseCollector is retrieved\n and its state is updated accordingly.\n\n State Updates:\n - increment receivedcount\n - if receivedcount is greater than the quorum size, PROPOSE STAGE is successful.\n -- remove the old ResponseCollector from the outstanding prepare set\n -- create MSG_PERFORM: message carries the chosen commandnumber and proposal.\n -- send MSG_PERFORM to all Replicas and Leaders\n -- execute the command\n \"\"\"\n if msg.commandnumber in self.outstandingproposes:\n prc = self.outstandingproposes[msg.commandnumber]\n if msg.inresponseto == prc.ballotnumber:\n prc.receivedcount += 1\n prc.receivedfrom.add(conn.peerid)\n if self.debug: self.logger.write(\"Paxos State\",\n \"got an accept for proposal ballotno %s \"\\\n \"commandno %s proposal %s making %d/%d accepts\" % \\\n (prc.ballotnumber, prc.commandnumber,\n prc.proposal, prc.receivedcount, prc.ntotal))\n if prc.receivedcount >= prc.nquorum:\n if self.debug: self.logger.write(\"Paxos State\", \"Agreed on %s\" % str(prc.proposal))\n # take this response collector out of the outstanding propose set\n self.add_to_proposals(prc.commandnumber, prc.proposal)\n # delete outstanding messages that caller does not need to check for anymore\n del self.outstandingproposes[msg.commandnumber]\n\n # now we can perform this action on the replicas\n performmessage = create_message(MSG_PERFORM, self.me,\n {FLD_COMMANDNUMBER: prc.commandnumber,\n FLD_PROPOSAL: prc.proposal,\n FLD_SERVERBATCH: isinstance(prc.proposal,\n ProposalServerBatch),\n FLD_CLIENTBATCH: isinstance(prc.proposal,\n ProposalClientBatch),\n FLD_DECISIONBALLOTNUMBER: prc.ballotnumber})\n\n if self.debug: self.logger.write(\"Paxos State\", \"Sending PERFORM!\")\n if len(self.replicas) > 0:\n self.send(performmessage, group=self.replicas)\n self.perform(parse_message(performmessage), designated=True)\n if self.debug: self.logger.write(\"State\", \"returning from msg_propose_accept\")", "metadata": "root.Replica.msg_propose_accept", "header": "['class', 'Replica', '(', 'Node', ')', ':', '___EOS___']", "index": 1356 }, { "content": " def msg_propose_reject(self, conn, msg):\n \"\"\"MSG_PROPOSE_REJECT is handled only if it belongs to an outstanding MSG_PROPOSE,\n otherwise it is discarded.\n A MSG_PROPOSE_REJECT causes the PROPOSE STAGE to be unsuccessful, hence the current\n state is deleted and a new PREPARE STAGE is initialized.\n\n State Updates:\n - kill the PROPOSE STAGE that received a MSG_PROPOSE_REJECT\n -- remove the old ResponseCollector from the outstanding prepare set\n - remove the command from proposals, add it to pendingcommands\n - update the ballotnumber\n - initiate command\n \"\"\"\n if msg.commandnumber in self.outstandingproposes:\n prc = self.outstandingproposes[msg.commandnumber]\n if msg.inresponseto == prc.ballotnumber:\n if self.debug: self.logger.write(\"Paxos State\",\n \"got a reject for proposal ballotno %s \"\\\n \"commandno %s proposal %s still %d \"\\\n \"out of %d accepts\" % \\\n (prc.ballotnumber, prc.commandnumber,\n prc.proposal, prc.receivedcount, prc.ntotal))\n # take this response collector out of the outstanding propose set\n del self.outstandingproposes[msg.commandnumber]\n # become inactive\n self.active = False\n # handle reject\n self._handlereject(msg, prc)", "metadata": "root.Replica.msg_propose_reject", "header": "['class', 'Replica', '(', 'Node', ')', ':', '___EOS___']", "index": 1403 }, { "content": " def _handlereject(self, msg, prc):\n if self.debug: self.logger.write(\"State\", \"Handling the reject.\")\n if msg.ballotnumber[BALLOTEPOCH] == self.ballotnumber[BALLOTEPOCH]:\n if self.debug: self.logger.write(\"State\", \"Updating ballotnumber and retrying.\")\n # update the ballot number\n self.update_ballotnumber(msg.ballotnumber)\n # remove the proposal from proposals\n try:\n self.remove_from_proposals(prc.commandnumber)\n except KeyError:\n if self.debug: self.logger.write(\"State\", \"Proposal already removed.\")\n self.pick_commandnumber_add_to_pending(prc.proposal)\n leader_causing_reject = self.detect_colliding_leader(msg.ballotnumber)\n if leader_causing_reject < self.me:\n # if caller lost to a replica whose name precedes its, back off more\n self.backoff += BACKOFFINCREASE\n if self.debug: self.logger.write(\"Paxos State\",\n \"There is another leader: %s\" % \\\n str(leader_causing_reject))\n time.sleep(self.backoff)\n self.issue_pending_commands()\n\n # if the epoch is wrong, should collect the state and start from beginning\n else:\n if self.debug: self.logger.write(\"State\", \"In wrong EPOCH.\")\n self._rejoin()", "metadata": "root.Replica._handlereject", "header": "['class', 'Replica', '(', 'Node', ')', ':', '___EOS___']", "index": 1432 }, { "content": " def _rejoin(self):\n if not self.stateuptodate:\n return\n if self.debug: self.logger.write(\"State\", \"Rejoining.\")\n # leadership state\n self.isleader = False\n self.leader_initializing = False\n self.stateuptodate = False\n # commands that are proposed: <commandnumber:command>\n self.proposals = {}\n self.proposalset = set()\n # commands that are received, not yet proposed: <commandnumber:command>\n self.pendingcommands = {}\n self.pendingcommandset = set()\n # nodes being added/deleted\n self.nodesbeingdeleted = set()\n # keep nodes that are recently updated\n self.recentlyupdatedpeerslock = Lock()\n self.recentlyupdatedpeers = []\n # send msg_helo to the replicas in the view\n for replicapeer in self.replicas:\n if replicapeer != self.me:\n if self.debug: self.logger.write(\"State\", \"Sending HELO to %s\" %\n str(replicapeer))\n helomessage = create_message(MSG_HELO, self.me)\n successid = self.send(helomessage, peer=replicapeer)", "metadata": "root.Replica._rejoin", "header": "['class', 'Replica', '(', 'Node', ')', ':', '___EOS___']", "index": 1459 }, { "content": " def ping_neighbor(self):\n \"\"\"used to ping neighbors periodically\"\"\"\n while True:\n # Go through all peers in the view\n for peer in self.replicas:\n successid = 0\n if peer == self.me:\n continue\n # Check when last heard from peer\n if peer in self.nodeliveness:\n nosound = time.time() - self.nodeliveness[peer]\n else:\n # This peer did not send a message, send a PING\n nosound = LIVENESSTIMEOUT + 1\n\n if nosound <= LIVENESSTIMEOUT:\n # Peer is alive\n self.replicas[peer] = 0\n continue\n if nosound > LIVENESSTIMEOUT:\n # Send PING to peer\n if self.debug: self.logger.write(\"State\", \"Sending PING to %s\" % str(peer))\n pingmessage = create_message(MSG_PING, self.me)\n successid = self.send(pingmessage, peer=peer)\n if successid < 0 or nosound > (2*LIVENESSTIMEOUT):\n # The neighbor is not responding\n if self.debug: self.logger.write(\"State\",\n \"Neighbor not responding %s\" % str(peer))\n # Mark the neighbor\n self.replicas[peer] += 1\n # Check leadership\n if not self.isleader and self.find_leader() == self.me:\n if self.debug: self.logger.write(\"State\",\n \"Becoming leader\")\n self.become_leader()\n if self.isleader and \\\n peer not in self.nodesbeingdeleted and \\\n peer in self.replicas:\n if self.debug: self.logger.write(\"State\",\n \"Deleting node %s\" % str(peer))\n self.nodesbeingdeleted.add(peer)\n delcommand = self.create_delete_command(peer)\n self.pick_commandnumber_add_to_pending(delcommand)\n for i in range(WINDOW):\n noopcommand = self.create_noop_command()\n self.pick_commandnumber_add_to_pending(noopcommand)\n issuemsg = create_message(MSG_ISSUE, self.me)\n self.send(issuemsg, peer=self.me)\n\n with self.recentlyupdatedpeerslock:\n self.recentlyupdatedpeers = []\n time.sleep(LIVENESSTIMEOUT)", "metadata": "root.Replica.ping_neighbor", "header": "['class', 'Replica', '(', 'Node', ')', ':', '___EOS___']", "index": 1486 }, { "content": " def create_delete_command(self, node):\n # include the ballotnumber in the metacommand\n mynumber = self.metacommandnumber\n self.metacommandnumber += 1\n nodename = node.addr + \":\" + str(node.port)\n operationtuple = (\"_del_node\", node.type, nodename, self.ballotnumber)\n command = Proposal(self.me, mynumber, operationtuple)\n return command", "metadata": "root.Replica.create_delete_command", "header": "['class', 'Replica', '(', 'Node', ')', ':', '___EOS___']", "index": 1539 }, { "content": " def create_add_command(self, node):\n mynumber = self.metacommandnumber\n self.metacommandnumber += 1\n nodename = node.addr + \":\" + str(node.port)\n operationtuple = (\"_add_node\", node.type, nodename, self.ballotnumber)\n command = Proposal(self.me, mynumber, operationtuple)\n return command", "metadata": "root.Replica.create_add_command", "header": "['class', 'Replica', '(', 'Node', ')', ':', '___EOS___']", "index": 1548 }, { "content": " def create_noop_command(self):\n mynumber = self.metacommandnumber\n self.metacommandnumber += 1\n nooptuple = (\"noop\")\n command = Proposal(self.me, mynumber, nooptuple)\n return command", "metadata": "root.Replica.create_noop_command", "header": "['class', 'Replica', '(', 'Node', ')', ':', '___EOS___']", "index": 1556 }, { "content": " def cmd_command(self, *args):\n \"\"\"shell command [command]: initiate a new command.\"\"\"\n try:\n cmdproposal = Proposal(self.me, random.randint(1,10000000), args[1:])\n self.handle_client_command(cmdproposal)\n except IndexError as e:\n print \"command expects only one command: \", str(e)", "metadata": "root.Replica.cmd_command", "header": "['class', 'Replica', '(', 'Node', ')', ':', '___EOS___']", "index": 1564 }, { "content": " def cmd_goleader(self, args):\n \"\"\"start Leader state\"\"\"\n self.become_leader()", "metadata": "root.Replica.cmd_goleader", "header": "['class', 'Replica', '(', 'Node', ')', ':', '___EOS___']", "index": 1572 }, { "content": " def cmd_showobject(self, args):\n \"\"\"print replicated object information\"\"\"\n print self.object", "metadata": "root.Replica.cmd_showobject", "header": "['class', 'Replica', '(', 'Node', ')', ':', '___EOS___']", "index": 1576 }, { "content": " def cmd_info(self, args):\n \"\"\"print next commandnumber to execute and executed commands\"\"\"\n print str(self)", "metadata": "root.Replica.cmd_info", "header": "['class', 'Replica', '(', 'Node', ')', ':', '___EOS___']", "index": 1580 }, { "content": " def cmd_proposals(self,args):\n \"\"\"prints proposals\"\"\"\n for cmdnum,command in self.proposals.iteritems():\n print \"%d: %s\" % (cmdnum,str(command))", "metadata": "root.Replica.cmd_proposals", "header": "['class', 'Replica', '(', 'Node', ')', ':', '___EOS___']", "index": 1584 }, { "content": " def cmd_pending(self,args):\n \"\"\"prints pending commands\"\"\"\n for cmdnum,command in self.pendingcommands.iteritems():\n print \"%d: %s\" % (cmdnum,str(command))", "metadata": "root.Replica.cmd_pending", "header": "['class', 'Replica', '(', 'Node', ')', ':', '___EOS___']", "index": 1589 }, { "content": " def terminate_handler(self, signal, frame):\n self._graceexit()", "metadata": "root.Replica.terminate_handler", "header": "['class', 'Replica', '(', 'Node', ')', ':', '___EOS___']", "index": 1595 }, { "content": " def _graceexit(self, exitcode=0):\n sys.stdout.flush()\n sys.stderr.flush()\n if hasattr(self, 'logger'): self.logger.close()\n os._exit(exitcode)", "metadata": "root.Replica._graceexit", "header": "['class', 'Replica', '(', 'Node', ')', ':', '___EOS___']", "index": 1598 }, { "content": "def main():\n replicanode = Replica()\n replicanode.startservice()\n signal.signal(signal.SIGINT, replicanode.terminate_handler)\n signal.signal(signal.SIGTERM, replicanode.terminate_handler)\n signal.pause()", "metadata": "root.main", "header": "['module', '___EOS___']", "index": 1604 } ]
[ { "span": "from threading import Thread, Lock, Timer, Event", "start_line": 10, "start_column": 0, "end_line": 10, "end_column": 48 }, { "span": "from concoord.nameserver import Nameserver", "start_line": 13, "start_column": 0, "end_line": 13, "end_column": 42 }, { "span": "from concoord.exception import ConCoordException, BlockingReturn, UnblockingReturn", "start_line": 15, "start_column": 0, "end_line": 15, "end_column": 82 } ]
[]
1
false
[ "[CLS]_", "Un", "used_", "import_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "'''", "\\", "10", ";", "@", "author", ":", " ", "Den", "iz", " ", "Alt", "inb", "uk", "en", ",", " ", "Emi", "n", " ", "Gun", " ", "Si", "rer", "\\", "10", ";", "@", "note", ":", " ", "The", " ", "Replica", " ", "keep", "s", " ", "an", " ", "object", " ", "and", " ", "respond", "s", " ", "to", " ", "Perform", " ", "message", "s", " ", "receive", "d", " ", "from", " ", "the", " ", "Leader", ".", "\\", "10", ";", "@", "copyr", "ight", ":", " ", "See", " ", "LICENSE", "\\", "10", ";'", "''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "inspect_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "time_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "os_", ",_", "sys_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "signal_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "c", "Pickle_", "as_", "pickle_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "threading_", "import_", "Thread_", ",_", "Lock_", ",_", "Timer_", ",_", "Event_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "conc", "oor", "d_", "._", "pack_", "import_", "Propos", "al_", ",_", "PV", "alue_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "conc", "oor", "d_", "._", "pvalue_", "import_", "PV", "alu", "e", "Set_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "conc", "oor", "d_", "._", "nameserv", "er_", "import_", "Names", "erver_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "conc", "oor", "d_", "._", "response", "collector_", "import_", "Respons", "e", "Collector_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "conc", "oor", "d_", "._", "exception_", "import_", "Con", "Coord", "Exception_", ",_", "Block", "ing", "Return_", ",_", "Unb", "locking", "Return_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "conc", "oor", "d_", "._", "node_", "import_", "*_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "conc", "oor", "d_", "._", "enums_", "import_", "*_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "conc", "oor", "d_", "._", "utils_", "import_", "*_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "conc", "oor", "d_", "._", "message_", "import_", "*_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "backoff", "\\u", "event_", "=_", "Event_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "\\u\\u", "name\\u\\u_", "==_", "'\\u", "\\u", "main", "\\u\\u'_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "main_", "(_", ")_", "\\u\\u\\uDEDENT\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "class_", "Replica", "_", "(_", "Node_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "LEA", "DER", " ", "STATE_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "##", " ", "PA", "XO", "S", " ", "METHODS_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "##", " ", "PA", "XO", "S", " ", "ACCEPT", "OR", " ", "MESSAGE", " ", "HANDLER", "S_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "##", " ", "PA", "XO", "S", " ", "REPLICA", " ", "MESSAGE", " ", "HANDLER", "S_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "##", " ", "SHELL", " ", "COMMANDS_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "##", " ", "TERMINAT", "ION", " ", "METHODS_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "[SEP]_", "class_", "Replica", "_", "(_", "Node_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "def_", "\\u\\u", "init\\u\\u_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "Node_", "._", "\\u\\u", "init\\u\\u_", "(_", "self_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "load", " ", "and", " ", "initialize", " ", "the", " ", "object", " ", "to", " ", "be", " ", "replicate", "d_", "\\u\\u\\uNL\\u\\u\\u_", "import_", "importlib_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "object", "loc_", ",_", "a_", ",_", "classname_", "=_", "self_", "._", "object", "name_", "._", "rpartition_", "(_", "'.'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "object_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "module_", "=_", "importlib_", "._", "import", "\\u", "module_", "(_", "object", "loc_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "hasattr_", "(_", "module_", ",_", "classname_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "object_", "=_", "getattr_", "(_", "module_", ",_", "classname_", ")_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "(_", "Value", "Error_", ",_", "Import", "Error_", ",_", "Attribute", "Error_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "object_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "not_", "self_", "._", "object_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "logger_", "._", "write_", "(_", "\"", "Object", " ", "Error", "\"_", ",_", "\"", "Object", " ", "cann", "ot", " ", "be", " ", "found", ".\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "\\u", "grace", "exit_", "(_", "1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "token_", "=_", "getattr_", "(_", "self_", "._", "object_", ",_", "'\\u", "%", "s", "\\u\\u", "conc", "oor", "d\\u", "token", "'_", "%_", "self_", "._", "object", "name_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "Attribute", "Error_", "as_", "e_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "self_", "._", "debug_", ":_", "self_", "._", "logger_", "._", "write_", "(_", "\"", "State", "\"_", ",_", "\"", "Object", " ", "initialize", "d", " ", "with", "out", " ", "a", " ", "token", ".\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "token_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "leader", "ship", " ", "state_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "leader", "\\u", "initiali", "zin", "g_", "=_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "isl", "eader", "_", "=_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "ballot", "number_", "=_", "(_", "0_", ",_", "0_", ",_", "self_", "._", "id_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "next", "toe", "xec", "ute", "_", "=_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "decide", "d", " ", "command", "s", ":", " ", "<", "command", "number", ":", "command", ">_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "decision", "s_", "=_", "{_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "decision", "set_", "=_", "set_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "executed", " ", "command", "s", ":", " ", "<", "command", ":(", "repl", "yco", "de", ",", "command", "result", ",", "unbl", "ock", "ed", "{})", ">_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "executed", "_", "=_", "{_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "command", "s", " ", "tha", "t", " ", "are", " ", "proposed", ":", " ", "<", "command", "number", ":", "command", ">_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "proposals", "_", "=_", "{_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "proposals", "et_", "=_", "set_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "command", "s", " ", "tha", "t", " ", "are", " ", "receive", "d", ",", " ", "not", " ", "ye", "t", " ", "proposed", ":", " ", "<", "command", "number", ":", "command", ">_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "pend", "ing", "commands_", "=_", "{_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "pend", "ing", "command", "set_", "=_", "set_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "command", "numbers", " ", "know", "n", " ", "to", " ", "be", " ", "in", " ", "use_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "used", "command", "numbers_", "=_", "set_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "nodes", " ", "bei", "ng", " ", "adde", "d", "/", "deleted_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "nodes", "bei", "ng", "deleted_", "=_", "set_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "number", " ", "for", " ", "meta", "command", "s", " ", "initiate", "d", " ", "from", " ", "this", " ", "replica_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "meta", "command", "number_", "=_", "0_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "keep", " ", "nodes", " ", "tha", "t", " ", "are", " ", "recent", "ly", " ", "updated_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "recent", "ly", "update", "dp", "eer", "slo", "ck_", "=_", "Lock_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "recent", "ly", "update", "dp", "eer", "s_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Qu", "or", "um", " ", "state_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "self_", "._", "durab", "le_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "file_", "=_", "open_", "(_", "'", "conc", "oor", "dlo", "g", "'_", ",_", "'", "a", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "quorum", "ballot", "number_", "=_", "(_", "0_", ",_", "0_", ",_", "''_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "last", "\\u", "accept", "\\u", "msg", "\\u", "id_", "=_", "-_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "quorum", "accepted_", "=_", "PV", "alu", "e", "Set_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "object", "snapshot_", "=_", "(_", "0_", ",_", "None_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "PERF", "ORM", "ANCE", " ", "MEASURE", "MENT", " ", "VARS", "_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "first", "starttime_", "=_", "0_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "first", "stop", "time_", "=_", "0_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "second", "starttime_", "=_", "0_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "second", "stop", "time_", "=_", "0_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "count_", "=_", "0_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "throughput", "\\u", "runs_", "=_", "0_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "throughput", "\\u", "stop_", "=_", "0_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "throughput", "\\u", "start_", "=_", "0_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Replica", "_", "(_", "Node_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "\\u\\u", "str\\u\\u_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "rstr", "_", "=_", "\"%", "s", " ", "%", "s", ":", "%", "d", "\\\\", "n", "\"_", "%_", "(_", "\"", "LEA", "DER", "\"_", "if_", "self_", "._", "isl", "eader", "_", "else_", "node", "\\u", "names_", "[_", "self_", "._", "type_", "]_", ",_", "self_", "._", "addr_", ",_", "self_", "._", "port_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "rstr", "_", "+=_", "\"", "Mem", "bers", ":\\\\", "n", "%", "s", "\\\\", "n", "\"_", "%_", "\"\\\\", "n", "\"_", "._", "join_", "(_", "str_", "(_", "peer_", ")_", "for_", "peer_", "in_", "self_", "._", "replicas_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "rstr", "_", "+=_", "\"", "Wait", "ing", " ", "to", " ", "execute", " ", "command", " ", "%", "d", ".\\\\", "n", "\"_", "%_", "self_", "._", "next", "toe", "xec", "ute", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "rstr", "_", "+=_", "\"", "Command", "s", ":\\\\", "n", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "command", "number_", ",_", "command_", "in_", "self_", "._", "decision", "s_", "._", "iteritems_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "state_", "=_", "''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "command_", "in_", "self_", "._", "executed", "_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "isinstance_", "(_", "command_", ",_", "Propos", "al", "Client", "Batch_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "state_", "=_", "'\\\\", "t", "'_", "+_", "str_", "(_", "self_", "._", "executed", "_", "[_", "command_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "state_", "=_", "'\\\\", "t", "'_", "+_", "cr", "\\u", "codes_", "[_", "self_", "._", "executed", "_", "[_", "command_", "]_", "[_", "0_", "]_", "]_", "+_", "'\\\\", "t", "'_", "+_", "str_", "(_", "self_", "._", "executed", "_", "[_", "command_", "]_", "[_", "1_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "rstr", "_", "+=_", "str_", "(_", "command", "number_", ")_", "+_", "\":", "\\\\", "t", "\"_", "+_", "str_", "(_", "command_", ")_", "+_", "state_", "+_", "'\\\\", "n", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "len_", "(_", "self_", "._", "pend", "ing", "commands_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "rstr", "_", "+=_", "\"", "Pend", "ing", " ", "Command", "s", ":\\\\", "n", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "command", "number_", ",_", "command_", "in_", "self_", "._", "pend", "ing", "commands_", "._", "iteritems_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "rstr", "_", "+=_", "str_", "(_", "command", "number_", ")_", "+_", "\":", "\\\\", "t", "\"_", "+_", "str_", "(_", "command_", ")_", "+_", "'\\\\", "n", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "len_", "(_", "self_", "._", "proposals", "_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "rstr", "_", "+=_", "\"", "Propos", "als", ":\\\\", "n", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "command", "number_", ",_", "command_", "in_", "self_", "._", "proposals", "_", "._", "iteritems_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "rstr", "_", "+=_", "str_", "(_", "command", "number_", ")_", "+_", "\":", "\\\\", "t", "\"_", "+_", "str_", "(_", "command_", ")_", "+_", "'\\\\", "n", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Add", " ", "QU", "OR", "UM", " ", "State_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "rstr", "_", "+=_", "\"", "Qu", "or", "um", " ", "Ball", "ot", " ", "Number", ":", " ", "%", "s", "\\\\", "n", "\"_", "%_", "str_", "(_", "self_", "._", "quorum", "ballot", "number_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "rstr", "_", "+=_", "\"", "Accept", "ed", " ", "PV", "alues", ":", " ", "%", "s", "\\\\", "n", "\"_", "%_", "str_", "(_", "self_", "._", "quorum", "accepted_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "return_", "rstr", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Replica", "_", "(_", "Node_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "\\u", "import", "\\u", "object_", "(_", "self_", ",_", "name_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "mod_", "=_", "\\u\\u", "import\\u\\u_", "(_", "name_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "components_", "=_", "name_", "._", "split_", "(_", "'.'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "comp_", "in_", "components_", "[_", "1_", ":_", "]_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "mod_", "=_", "getattr_", "(_", "mod_", ",_", "comp_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "mod_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Replica", "_", "(_", "Node_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "starts", "ervice", "_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "Start", " ", "the", " ", "background", " ", "service", "s", " ", "associate", "d", " ", "with", " ", "a", " ", "replica", ".\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "Node_", "._", "starts", "ervice", "_", "(_", "self_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "self_", "._", "isn", "ames", "erver_", "and_", "not_", "self_", "._", "user", "oute", "53_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "self_", "._", "debug_", ":_", "self_", "._", "logger_", "._", "write_", "(_", "\"", "State", "\"_", ",_", "\"", "Start", "ing", " ", "the", " ", "Names", "erver", " ", "Thread", ".\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Start", " ", "a", " ", "thread", " ", "for", " ", "the", " ", "UD", "P", " ", "server_", "\\u\\u\\uNL\\u\\u\\u_", "UD", "P", "\\u", "server", "\\u", "thread_", "=_", "Thread_", "(_", "target_", "=_", "self_", "._", "nameserv", "er_", "._", "ud", "p", "\\u", "server", "\\u", "loop_", ",_", "name_", "=_", "'", "UD", "PS", "erver", "Thread", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "UD", "P", "\\u", "server", "\\u", "thread_", "._", "start_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Replica", "_", "(_", "Node_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "@_", "staticmethod_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "\\u", "appl", "y", "\\u", "args", "\\u", "to", "\\u", "method_", "(_", "method_", ",_", "args_", ",_", "\\u", "conc", "oor", "d\\u", "command_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "argspec_", "=_", "inspect_", "._", "getargs", "pec_", "(_", "method_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "argspec_", "._", "args_", "and_", "argspec_", "._", "args_", "[_", "-_", "1_", "]_", "==_", "'\\u", "conc", "oor", "d\\u", "command", "'_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "method_", "(_", "*_", "args_", ",_", "\\u", "conc", "oor", "d\\u", "command_", "=_", "\\u", "conc", "oor", "d\\u", "command_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "argspec_", "._", "keywords_", "is_", "not_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "method_", "(_", "*_", "args_", ",_", "\\u", "conc", "oor", "d\\u", "command_", "=_", "\\u", "conc", "oor", "d\\u", "command_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "method_", "(_", "*_", "args_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Replica", "_", "(_", "Node_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "perform", "core", "\\u", "client", "batch_", "(_", "self_", ",_", "command", "batch_", ",_", "designate", "d_", "=_", "False_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "'''", "perform", "s", " ", "all", " ", "client", "request", "s", " ", "in", " ", "a", " ", "client", "batch", " ", "and", " ", "return", "s", " ", "a", " ", "batched", " ", "result", ".'''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "self_", "._", "debug_", ":_", "self_", "._", "logger_", "._", "write_", "(_", "\"", "State", "\"_", ",_", "\"", "Perform", "ing", " ", "client", " ", "batch", ".\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "client", "replies_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "command", "tuple_", "in_", "command", "batch_", "._", "command_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "command", "name_", "=_", "command", "tuple_", "[_", "0_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "command", "args_", "=_", "command", "tuple_", "[_", "1_", ":_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Result", " ", "triple_", "\\u\\u\\uNL\\u\\u\\u_", "client", "repl", "yco", "de_", ",_", "give", "nre", "sult_", ",_", "unbl", "ock", "ed_", "=_", "(_", "-_", "1_", ",_", "None_", ",_", "{_", "}_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "method_", "=_", "getattr_", "(_", "self_", "._", "object_", ",_", "command", "name_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Watch", " ", "out", " ", "for", " ", "the", " ", "lock", " ", "release", " ", "and", " ", "acquir", "e", "!", "_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "lock_", "._", "release_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "give", "nre", "sult_", "=_", "method_", "(_", "*_", "command", "args_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "client", "repl", "yco", "de_", "=_", "CR", "\\u", "OK_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "Block", "ing", "Return_", "as_", "blockin", "gre", "tex", "p_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "if_", "self_", "._", "debug_", ":_", "self_", "._", "logger_", "._", "write_", "(_", "\"", "State", "\"_", ",_", "\"", "Block", "ing", " ", "Client", ".\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "give", "nre", "sult_", "=_", "blockin", "gre", "tex", "p_", "._", "return", "value_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "client", "repl", "yco", "de_", "=_", "CR", "\\u", "BLOCK_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "Unb", "locking", "Return_", "as_", "unbl", "ock", "ingr", "ete", "xp_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "if_", "self_", "._", "debug_", ":_", "self_", "._", "logger_", "._", "write_", "(_", "\"", "State", "\"_", ",_", "\"", "Unb", "locking", " ", "Client", "(", "s", ").\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Get", " ", "the", " ", "informati", "on", " ", "abo", "ut", " ", "the", " ", "method", " ", "call_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "The", "se", " ", "will", " ", "be", " ", "used", " ", "to", " ", "update", " ", "executed", " ", "and_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "to", " ", "send", " ", "repl", "y", " ", "message", " ", "to", " ", "the", " ", "caller", " ", "client_", "\\u\\u\\uNL\\u\\u\\u_", "give", "nre", "sult_", "=_", "unbl", "ock", "ingr", "ete", "xp_", "._", "return", "value_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "unbl", "ock", "ed_", "=_", "unbl", "ock", "ingr", "ete", "xp_", "._", "unbl", "ock", "ed_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "client", "repl", "yco", "de_", "=_", "CR", "\\u", "OK_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "If", " ", "there", " ", "are", " ", "clients", " ", "to", " ", "be", " ", "unbl", "ock", "ed", " ", "tha", "t", " ", "have_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "bee", "n", " ", "block", "ed", " ", "previ", "ously", ",", " ", "send", " ", "them", " ", "unbl", "ock", " ", "messages_", "\\u\\u\\uNL\\u\\u\\u_", "for_", "unbl", "ock", "edc", "lien", "tco", "mmand", "_", "in_", "unbl", "ock", "ed_", "._", "iterkeys_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "self_", "._", "send", "\\u", "repl", "y", "\\u", "to", "\\u", "client_", "(_", "CR", "\\u", "UN", "BLOCK_", ",_", "None_", ",_", "unbl", "ock", "edc", "lien", "tco", "mmand", "_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "Exception_", "as_", "e_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "if_", "self_", "._", "debug_", ":_", "self_", "._", "logger_", "._", "write_", "(_", "\"", "Execut", "ion", " ", "Error", "\"_", ",_", "\"", "Error", " ", "dur", "ing", " ", "method", " ", "invocation", ":", " ", "%", "s", "\"_", "%_", "str_", "(_", "e_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "give", "nre", "sult_", "=_", "pickle_", "._", "dumps_", "(_", "e_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "client", "repl", "yco", "de_", "=_", "CR", "\\u", "EXCEPTION_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "unbl", "ock", "ed_", "=_", "{_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "lock_", "._", "acquire_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "(_", "Type", "Error_", ",_", "Attribute", "Error_", ")_", "as_", "t_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "self_", "._", "debug_", ":_", "self_", "._", "logger_", "._", "write_", "(_", "\"", "Execut", "ion", " ", "Error", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "command", " ", "not", " ", "support", "ed", ":", " ", "%", "s", "\"_", "%_", "str_", "(_", "command", "name_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "self_", "._", "debug_", ":_", "self_", "._", "logger_", "._", "write_", "(_", "\"", "Execut", "ion", " ", "Error", "\"_", ",_", "\"%", "s", "\"_", "%_", "str_", "(_", "t_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "give", "nre", "sult_", "=_", "'", "Meth", "od", " ", "Do", "es", " ", "Not", " ", "Exist", ":", " ", "'_", ",_", "command", "name_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "client", "repl", "yco", "de_", "=_", "CR", "\\u", "EXCEPTION_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "unbl", "ock", "ed_", "=_", "{_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "client", "replies_", "._", "append_", "(_", "(_", "client", "repl", "yco", "de_", ",_", "give", "nre", "sult_", ",_", "unbl", "ock", "ed_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "add", "\\u", "to", "\\u", "executed", "_", "(_", "command", "batch_", ",_", "client", "replies_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "self_", "._", "isl", "eader", "_", "and_", "str_", "(_", "command", "batch_", "._", "client_", ")_", "in_", "self_", "._", "connecti", "onp", "ool_", "._", "pool", "by", "peer_", "._", "keys_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "send", "\\u", "repl", "yb", "atch", "\\u", "to", "\\u", "client_", "(_", "client", "replies_", ",_", "command", "batch_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "self_", "._", "next", "toe", "xec", "ute", "_", "%_", "GAR", "BA", "GE", "PERIOD_", "==_", "0_", "and_", "self_", "._", "isl", "eader", "_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "myn", "umber_", "=_", "self_", "._", "meta", "command", "number_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "meta", "command", "number_", "+=_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "gar", "bage", "tuple_", "=_", "(_", "\"\\u", "gar", "bage", "\\u", "collect", "\"_", ",_", "self_", "._", "next", "toe", "xec", "ute", "_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "gar", "bage", "command_", "=_", "Propos", "al_", "(_", "self_", "._", "me_", ",_", "myn", "umber_", ",_", "gar", "bage", "tuple_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "self_", "._", "leader", "\\u", "initiali", "zin", "g_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "handle", "\\u", "client", "\\u", "command_", "(_", "gar", "bage", "command_", ",_", "prepare_", "=_", "True_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "handle", "\\u", "client", "\\u", "command_", "(_", "gar", "bage", "command_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "self_", "._", "debug_", ":_", "self_", "._", "logger_", "._", "write_", "(_", "\"", "State", ":\"_", ",_", "\"", "return", "ing", " ", "from", " ", "perform", "core", "!\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Replica", "_", "(_", "Node_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "perform", "core_", "(_", "self_", ",_", "command_", ",_", "dome", "ta", "only_", "=_", "False_", ",_", "designate", "d_", "=_", "False_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "The", " ", "core", " ", "function", " ", "tha", "t", " ", "perform", "s", " ", "a", " ", "give", "n", " ", "command", " ", "in", " ", "a", " ", "slot", " ", "number", ".", " ", "It", "\\", "10", ";", " ", " ", " ", " ", "execute", "s", " ", "regular", " ", "command", "s", " ", "as", " ", "well", " ", "as", " ", "MET", "A", "-", "level", " ", "command", "s", " ", "(", "command", "s", " ", "relate", "d", "\\", "10", ";", " ", " ", " ", " ", "to", " ", "the", " ", "manage", "ment", "s", " ", "of", " ", "the", " ", "Pa", "xo", "s", " ", "protoc", "ol", ")", " ", "with", " ", "a", " ", "dela", "y", " ", "of", " ", "WIND", "OW", " ", "command", "s", ".\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "command", "tuple_", "=_", "command_", "._", "command_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "type_", "(_", "command", "tuple_", ")_", "==_", "str_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "command", "name_", "=_", "command", "tuple_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "command", "args_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "command", "name_", "=_", "command", "tuple_", "[_", "0_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "command", "args_", "=_", "command", "tuple_", "[_", "1_", ":_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "isme", "ta_", "=_", "(_", "command", "name_", "in_", "MET", "AC", "OM", "MAN", "DS_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "noop_", "=_", "(_", "command", "name_", "==_", "\"", "noop", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "send", "\\u", "result", "\\u", "to", "\\u", "client_", "=_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "self_", "._", "debug_", ":_", "self_", "._", "logger_", "._", "write_", "(_", "\"", "State", ":\"_", ",_", "\"--", "->", " ", "Command", ":", " ", "%", "s", " ", "Do", "Meta", "On", "ly", ":", " ", "%", "s", " ", "Is", "Meta", ":", " ", "%", "s", "\"_", "\\u\\u\\uNL\\u\\u\\u_", "%_", "(_", "command_", ",_", "dome", "ta", "only_", ",_", "isme", "ta_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Result", " ", "triple_", "\\u\\u\\uNL\\u\\u\\u_", "client", "repl", "yco", "de_", ",_", "give", "nre", "sult_", ",_", "unbl", "ock", "ed_", "=_", "(_", "-_", "1_", ",_", "None_", ",_", "{_", "}_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "dome", "ta", "only_", "and_", "not_", "isme", "ta_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "noop_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "method_", "=_", "getattr_", "(_", "self_", ",_", "NOO", "P_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "client", "repl", "yco", "de_", "=_", "CR", "\\u", "OK_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "give", "nre", "sult_", "=_", "\"", "NOO", "P", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "unbl", "ock", "ed_", "=_", "{_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "send", "\\u", "result", "\\u", "to", "\\u", "client_", "=_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "dome", "ta", "only_", "and_", "isme", "ta_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "execute", " ", "a", " ", "meta", "command", " ", "whe", "n", " ", "the", " ", "window", " ", "has", " ", "expired_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "self_", "._", "debug_", ":_", "self_", "._", "logger_", "._", "write_", "(_", "\"", "State", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "command", "name", ":", " ", "%", "s", " ", "args", ":", " ", "%", "s", "\"_", "%_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "command", "name_", ",_", "str_", "(_", "command", "args_", ")_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "method_", "=_", "getattr_", "(_", "self_", ",_", "command", "name_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "client", "repl", "yco", "de_", "=_", "CR", "\\u", "META_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "give", "nre", "sult_", "=_", "self_", "._", "\\u", "appl", "y", "\\u", "args", "\\u", "to", "\\u", "method_", "(_", "method_", ",_", "command", "args_", ",_", "command_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "unbl", "ock", "ed_", "=_", "{_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "send", "\\u", "result", "\\u", "to", "\\u", "client_", "=_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "not_", "dome", "ta", "only_", "and_", "isme", "ta_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "meta", " ", "command", ",", " ", "but", " ", "the", " ", "window", " ", "has", " ", "not", " ", "pass", "ed", " ", "ye", "t", ",_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "so", " ", "just", " ", "mark", " ", "it", " ", "as", " ", "executed", " ", "with", "out", " ", "actual", "ly", " ", "executi", "ng", " ", "it_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "the", " ", "real", " ", "executi", "on", " ", "will", " ", "take", " ", "place", " ", "whe", "n", " ", "the", " ", "window", " ", "has", " ", "expired_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "add", "\\u", "to", "\\u", "executed", "_", "(_", "command_", ",_", "(_", "CR", "\\u", "META_", ",_", "META_", ",_", "{_", "}_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "not_", "dome", "ta", "only_", "and_", "not_", "isme", "ta_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "this", " ", "is", " ", "the", " ", "work", "horse", " ", "case", " ", "tha", "t", " ", "execute", "s", " ", "most", " ", "normal", " ", "commands_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "method_", "=_", "getattr_", "(_", "self_", "._", "object_", ",_", "command", "name_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Watch", " ", "out", " ", "for", " ", "the", " ", "lock", " ", "release", " ", "and", " ", "acquir", "e", "!", "_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "lock_", "._", "release_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "give", "nre", "sult_", "=_", "self_", "._", "\\u", "appl", "y", "\\u", "args", "\\u", "to", "\\u", "method_", "(_", "method_", ",_", "command", "args_", ",_", "command_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "client", "repl", "yco", "de_", "=_", "CR", "\\u", "OK_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "send", "\\u", "result", "\\u", "to", "\\u", "client_", "=_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "Block", "ing", "Return_", "as_", "blockin", "gre", "tex", "p_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "if_", "self_", "._", "debug_", ":_", "self_", "._", "logger_", "._", "write_", "(_", "\"", "State", "\"_", ",_", "\"", "Block", "ing", " ", "Client", ".\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "give", "nre", "sult_", "=_", "blockin", "gre", "tex", "p_", "._", "return", "value_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "client", "repl", "yco", "de_", "=_", "CR", "\\u", "BLOCK_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "send", "\\u", "result", "\\u", "to", "\\u", "client_", "=_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "Unb", "locking", "Return_", "as_", "unbl", "ock", "ingr", "ete", "xp_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "if_", "self_", "._", "debug_", ":_", "self_", "._", "logger_", "._", "write_", "(_", "\"", "State", "\"_", ",_", "\"", "Unb", "locking", " ", "Client", "(", "s", ").\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Get", " ", "the", " ", "informati", "on", " ", "abo", "ut", " ", "the", " ", "method", " ", "call_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "The", "se", " ", "will", " ", "be", " ", "used", " ", "to", " ", "update", " ", "executed", " ", "and_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "to", " ", "send", " ", "repl", "y", " ", "message", " ", "to", " ", "the", " ", "caller", " ", "client_", "\\u\\u\\uNL\\u\\u\\u_", "give", "nre", "sult_", "=_", "unbl", "ock", "ingr", "ete", "xp_", "._", "return", "value_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "unbl", "ock", "ed_", "=_", "unbl", "ock", "ingr", "ete", "xp_", "._", "unbl", "ock", "ed_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "client", "repl", "yco", "de_", "=_", "CR", "\\u", "OK_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "send", "\\u", "result", "\\u", "to", "\\u", "client_", "=_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "If", " ", "there", " ", "are", " ", "clients", " ", "to", " ", "be", " ", "unbl", "ock", "ed", " ", "tha", "t", " ", "have_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "bee", "n", " ", "block", "ed", " ", "previ", "ously", ",", " ", "send", " ", "them", " ", "unbl", "ock", " ", "messages_", "\\u\\u\\uNL\\u\\u\\u_", "for_", "unbl", "ock", "edc", "lien", "tco", "mmand", "_", "in_", "unbl", "ock", "ed_", "._", "iterkeys_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "self_", "._", "send", "\\u", "repl", "y", "\\u", "to", "\\u", "client_", "(_", "CR", "\\u", "UN", "BLOCK_", ",_", "None_", ",_", "unbl", "ock", "edc", "lien", "tco", "mmand", "_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "Exception_", "as_", "e_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "if_", "self_", "._", "debug_", ":_", "self_", "._", "logger_", "._", "write_", "(_", "\"", "Execut", "ion", " ", "Error", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "Error", " ", "dur", "ing", " ", "method", " ", "invocation", ":", " ", "%", "s", "\"_", "%_", "str_", "(_", "e_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "give", "nre", "sult_", "=_", "pickle_", "._", "dumps_", "(_", "e_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "client", "repl", "yco", "de_", "=_", "CR", "\\u", "EXCEPTION_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "send", "\\u", "result", "\\u", "to", "\\u", "client_", "=_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "unbl", "ock", "ed_", "=_", "{_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "lock_", "._", "acquire_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "(_", "Type", "Error_", ",_", "Attribute", "Error_", ")_", "as_", "t_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "self_", "._", "debug_", ":_", "self_", "._", "logger_", "._", "write_", "(_", "\"", "Execut", "ion", " ", "Error", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "command", " ", "not", " ", "support", "ed", ":", " ", "%", "s", "\"_", "%_", "str_", "(_", "command_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "self_", "._", "debug_", ":_", "self_", "._", "logger_", "._", "write_", "(_", "\"", "Execut", "ion", " ", "Error", "\"_", ",_", "\"%", "s", "\"_", "%_", "str_", "(_", "t_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "logger_", "._", "write_", "(_", "\"", "Execut", "ion", " ", "Error", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "command", " ", "not", " ", "support", "ed", ":", " ", "%", "s", "\"_", "%_", "str_", "(_", "command_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "logger_", "._", "write_", "(_", "\"", "Execut", "ion", " ", "Error", "\"_", ",_", "\"%", "s", "\"_", "%_", "str_", "(_", "t_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "give", "nre", "sult_", "=_", "'", "Meth", "od", " ", "Do", "es", " ", "Not", " ", "Exist", ":", " ", "'_", ",_", "command", "name_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "client", "repl", "yco", "de_", "=_", "CR", "\\u", "EXCEPTION_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "unbl", "ock", "ed_", "=_", "{_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "send", "\\u", "result", "\\u", "to", "\\u", "client_", "=_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "add", "\\u", "to", "\\u", "executed", "_", "(_", "command_", ",_", "(_", "client", "repl", "yco", "de_", ",_", "give", "nre", "sult_", ",_", "unbl", "ock", "ed_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "command", "name_", "not_", "in_", "MET", "AC", "OM", "MAN", "DS_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "if", " ", "this", " ", "client", " ", "contact", "ed", " ", "me", " ", "for", " ", "this", " ", "operati", "on", ",", " ", "return", " ", "him", " ", "the", " ", "response_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "send", "\\u", "result", "\\u", "to", "\\u", "client_", "and_", "self_", "._", "isl", "eader", "_", "and_", "str_", "(_", "command_", "._", "client_", ")_", "in_", "self_", "._", "connecti", "onp", "ool_", "._", "pool", "by", "peer_", "._", "keys_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "send", "\\u", "repl", "y", "\\u", "to", "\\u", "client_", "(_", "client", "repl", "yco", "de_", ",_", "give", "nre", "sult_", ",_", "command_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "self_", "._", "next", "toe", "xec", "ute", "_", "%_", "GAR", "BA", "GE", "PERIOD_", "==_", "0_", "and_", "self_", "._", "isl", "eader", "_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "myn", "umber_", "=_", "self_", "._", "meta", "command", "number_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "meta", "command", "number_", "+=_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "gar", "bage", "tuple_", "=_", "(_", "\"\\u", "gar", "bage", "\\u", "collect", "\"_", ",_", "self_", "._", "next", "toe", "xec", "ute", "_", ",_", "self_", "._", "ballot", "number_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "gar", "bage", "command_", "=_", "Propos", "al_", "(_", "self_", "._", "me_", ",_", "myn", "umber_", ",_", "gar", "bage", "tuple_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "self_", "._", "leader", "\\u", "initiali", "zin", "g_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "handle", "\\u", "client", "\\u", "command_", "(_", "gar", "bage", "command_", ",_", "prepare_", "=_", "True_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "handle", "\\u", "client", "\\u", "command_", "(_", "gar", "bage", "command_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "self_", "._", "debug_", ":_", "self_", "._", "logger_", "._", "write_", "(_", "\"", "State", ":\"_", ",_", "\"", "return", "ing", " ", "from", " ", "perform", "core", "!\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Replica", "_", "(_", "Node_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "send", "\\u", "repl", "yb", "atch", "\\u", "to", "\\u", "client_", "(_", "self_", ",_", "give", "nre", "sult_", ",_", "command_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "self_", "._", "debug_", ":_", "self_", "._", "logger_", "._", "write_", "(_", "\"", "State", "\"_", ",_", "\"", "Sen", "ding", " ", "REPLY", " ", "to", " ", "CLIENT", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "client", "reply_", "=_", "create", "\\u", "message_", "(_", "MS", "G", "\\u", "CLIENT", "REPLY_", ",_", "self_", "._", "me_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "{_", "FL", "D", "\\u", "REPLY_", ":_", "give", "nre", "sult_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "FL", "D", "\\u", "REPLY", "CODE_", ":_", "CR", "\\u", "BATCH", "_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "FL", "D", "\\u", "IN", "RESPONSE", "TO_", ":_", "command_", "._", "client", "command", "number_", "}_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "client", "conn_", "=_", "self_", "._", "connecti", "onp", "ool_", "._", "get", "\\u", "connecti", "on", "\\u", "by", "\\u", "peer_", "(_", "command_", "._", "client_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "client", "conn_", "==_", "None_", "or_", "client", "conn_", "._", "thes", "ocket", "_", "==_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "self_", "._", "debug_", ":_", "self_", "._", "logger_", "._", "write_", "(_", "\"", "State", "\"_", ",_", "\"", "Client", " ", "connecti", "on", " ", "doe", "s", " ", "not", " ", "exist", ".\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "client", "conn_", "._", "send_", "(_", "client", "reply_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Replica", "_", "(_", "Node_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "send", "\\u", "repl", "y", "\\u", "to", "\\u", "client_", "(_", "self_", ",_", "client", "repl", "yco", "de_", ",_", "give", "nre", "sult_", ",_", "command_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "self_", "._", "debug_", ":_", "self_", "._", "logger_", "._", "write_", "(_", "\"", "State", "\"_", ",_", "\"", "Sen", "ding", " ", "REPLY", " ", "to", " ", "CLIENT", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "client", "reply_", "=_", "create", "\\u", "message_", "(_", "MS", "G", "\\u", "CLIENT", "REPLY_", ",_", "self_", "._", "me_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "{_", "FL", "D", "\\u", "REPLY_", ":_", "give", "nre", "sult_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "FL", "D", "\\u", "REPLY", "CODE_", ":_", "client", "repl", "yco", "de_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "FL", "D", "\\u", "IN", "RESPONSE", "TO_", ":_", "command_", "._", "client", "command", "number_", "}_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "self_", "._", "debug_", ":_", "self_", "._", "logger_", "._", "write_", "(_", "\"", "State", "\"_", ",_", "\"", "Client", "repl", "y", ":", " ", "%", "s", "\"_", "%_", "str_", "(_", "client", "reply_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "client", "conn_", "=_", "self_", "._", "connecti", "onp", "ool_", "._", "get", "\\u", "connecti", "on", "\\u", "by", "\\u", "peer_", "(_", "command_", "._", "client_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "client", "conn_", "==_", "None_", "or_", "client", "conn_", "._", "thes", "ocket", "_", "==_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "self_", "._", "debug_", ":_", "self_", "._", "logger_", "._", "write_", "(_", "\"", "State", "\"_", ",_", "\"", "Client", " ", "connecti", "on", " ", "doe", "s", " ", "not", " ", "exist", ".\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "client", "conn_", "._", "send_", "(_", "client", "reply_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Replica", "_", "(_", "Node_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "perform_", "(_", "self_", ",_", "msg_", ",_", "designate", "d_", "=_", "False_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "Tak", "e", " ", "a", " ", "give", "n", " ", "PERF", "ORM", " ", "message", ",", " ", "add", " ", "it", " ", "to", " ", "the", " ", "set", " ", "of", " ", "decide", "d", " ", "command", "s", ",", "\\", "10", ";", " ", " ", " ", " ", "and", " ", "call", " ", "perform", "core", " ", "to", " ", "execute", ".\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "self_", "._", "debug_", ":_", "self_", "._", "logger_", "._", "write_", "(_", "\"", "State", ":\"_", ",_", "\"", "Perform", "ing", " ", "msg", " ", "%", "s", "\"_", "%_", "str_", "(_", "msg_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "msg_", "._", "command", "number_", "not_", "in_", "self_", "._", "decision", "s_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "add", "\\u", "to", "\\u", "decision", "s_", "(_", "msg_", "._", "command", "number_", ",_", "msg_", "._", "proposal_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "If", " ", "replica", " ", "was", " ", "usi", "ng", " ", "this", " ", "command", "number", " ", "for", " ", "a", " ", "different", " ", "propos", "al", ",", " ", "initiate", " ", "it", " ", "again", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "msg_", "._", "command", "number_", "in_", "self_", "._", "proposals", "_", "and_", "msg_", "._", "proposal_", "!=_", "self_", "._", "proposals", "_", "[_", "msg_", "._", "command", "number_", "]_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "pick", "\\u", "command", "number", "\\u", "add", "\\u", "to", "\\u", "pending_", "(_", "self_", "._", "proposals", "_", "[_", "msg_", "._", "command", "number_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "issue", "\\u", "pend", "ing", "\\u", "commands_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "while_", "self_", "._", "next", "toe", "xec", "ute", "_", "in_", "self_", "._", "decision", "s_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "request", "edc", "ommand", "_", "=_", "self_", "._", "decision", "s_", "[_", "self_", "._", "next", "toe", "xec", "ute", "_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "isinstance_", "(_", "request", "edc", "ommand", "_", ",_", "Propos", "al", "Server", "Batch_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "for_", "command_", "in_", "request", "edc", "ommand", "_", "._", "proposals", "_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "self_", "._", "execute", "\\u", "command_", "(_", "command_", ",_", "msg_", ",_", "designate", "d_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "execute", "\\u", "command_", "(_", "request", "edc", "ommand", "_", ",_", "msg_", ",_", "designate", "d_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "next", "toe", "xec", "ute", "_", "+=_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "the", " ", "window", " ", "just", " ", "got", " ", "bump", "ed", " ", "by", " ", "one_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "check", " ", "if", " ", "there", " ", "are", " ", "pend", "ing", " ", "command", "s", ",", " ", "and", " ", "issue", " ", "one", " ", "of", " ", "them", "_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "issue", "\\u", "pend", "ing", "\\u", "commands_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "self_", "._", "debug_", ":_", "self_", "._", "logger_", "._", "write_", "(_", "\"", "State", "\"_", ",_", "\"", "Return", "ing", " ", "from", " ", "PERF", "ORM", "!\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Replica", "_", "(_", "Node_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "execute", "\\u", "command_", "(_", "self_", ",_", "request", "edc", "ommand", "_", ",_", "msg_", ",_", "designate", "d_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "command", "s", " ", "are", " ", "executed", " ", "one", " ", "by", " ", "one", " ", "here", "._", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "request", "edc", "ommand", "_", "in_", "self_", "._", "executed", "_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "self_", "._", "debug_", ":_", "self_", "._", "logger_", "._", "write_", "(_", "\"", "State", "\"_", ",_", "\"", "Prev", "ious", "ly", " ", "executed", " ", "command", " ", "%", "d", ".\"_", "\\u\\u\\uNL\\u\\u\\u_", "%_", "self_", "._", "next", "toe", "xec", "ute", "_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Execut", "e", " ", "the", " ", "meta", "command", " ", "associate", "d", " ", "with", " ", "this", " ", "command_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "self_", "._", "next", "toe", "xec", "ute", "_", ">_", "WINDOW_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "self_", "._", "debug_", ":_", "self_", "._", "logger_", "._", "write_", "(_", "\"", "State", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "perform", "core", " ", "%", "d", "\"_", "%_", "(_", "self_", "._", "next", "toe", "xec", "ute", "_", "-_", "WINDOW_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "perform", "core_", "(_", "self_", "._", "decision", "s_", "[_", "self_", "._", "next", "toe", "xec", "ute", "_", "-_", "WINDOW_", "]_", ",_", "True_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "If", " ", "we", " ", "are", " ", "a", " ", "leader", ",", " ", "we", " ", "shou", "ld", " ", "send", " ", "a", " ", "repl", "y", " ", "to", " ", "the", " ", "client", " ", "for", " ", "this", " ", "command_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "in", " ", "case", " ", "the", " ", "client", " ", "did", "n", "'", "t", " ", "receive", " ", "the", " ", "repl", "y", " ", "from", " ", "the", " ", "previ", "ous", " ", "leader_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "self_", "._", "isl", "eader", "_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "prev", "rcode", "_", ",_", "prev", "result_", ",_", "prev", "unbl", "ock", "ed_", "=_", "self_", "._", "executed", "_", "[_", "request", "edc", "ommand", "_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "prev", "rcode", "_", "==_", "CR", "\\u", "BLOCK_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "As", " ", "dictionar", "y", " ", "is", " ", "not", " ", "sorte", "d", " ", "we", " ", "have", " ", "to", " ", "start", " ", "from", " ", "the", " ", "beginn", "ing", " ", "every", " ", "time_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "for_", "results", "et_", "in_", "self_", "._", "executed", "_", "._", "itervalues_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "if_", "results", "et_", "[_", "EXC", "\\u", "UN", "BLOCK", "ED_", "]_", "==_", "request", "edc", "ommand", "_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Thi", "s", " ", "client", " ", "has", " ", "bee", "n", " ", "UN", "BLOCK", "ED_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "prev", "result_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "prev", "rcode", "_", "=_", "CR", "\\u", "UN", "BLOCK_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Sen", "d", " ", "a", " ", "repl", "y", " ", "to", " ", "the", " ", "client", " ", "only", " ", "if", " ", "there", " ", "was", " ", "a", " ", "client_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "type_", "(_", "request", "edc", "ommand", "_", "._", "command_", ")_", "==_", "str_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "command", "name_", "=_", "request", "edc", "ommand", "_", "._", "command_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "command", "name_", "=_", "request", "edc", "ommand", "_", "._", "command_", "[_", "0_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "(_", "command", "name_", "not_", "in_", "MET", "AC", "OM", "MAN", "DS_", ")_", "and_", "(_", "command", "name_", "!=_", "'", "noop", "'_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "if_", "self_", "._", "debug_", ":_", "self_", "._", "logger_", "._", "write_", "(_", "\"", "State", "\"_", ",_", "\"", "Sen", "ding", " ", "repl", "y", " ", "to", " ", "client", ".\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "send", "\\u", "repl", "y", "\\u", "to", "\\u", "client_", "(_", "prev", "rcode", "_", ",_", "prev", "result_", ",_", "request", "edc", "ommand", "_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "request", "edc", "ommand", "_", "not_", "in_", "self_", "._", "executed", "_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "self_", "._", "debug_", ":_", "self_", "._", "logger_", "._", "write_", "(_", "\"", "State", "\"_", ",_", "\"", "executi", "ng", " ", "command", " ", "%", "s", ".\"_", "%_", "str_", "(_", "request", "edc", "ommand", "_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "check", " ", "to", " ", "see", " ", "if", " ", "there", " ", "was", " ", "a", " ", "meta", "command", " ", "precise", "ly", " ", "WIND", "OW", " ", "command", "s", " ", "ago_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "tha", "t", " ", "shou", "ld", " ", "now", " ", "take", " ", "effect_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "We", " ", "are", " ", "calling", " ", "perform", "core", " ", "2", " ", "times", ",", " ", "the", " ", "tim", "ing", " ", "gets", " ", "scre", "wed", " ", "plus", " ", "this_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "is", " ", "very", " ", "une", "ffic", "ient_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "self_", "._", "next", "toe", "xec", "ute", "_", ">_", "WINDOW_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "self_", "._", "debug_", ":_", "self_", "._", "logger_", "._", "write_", "(_", "\"", "State", "\"_", ",_", "\"", "perform", "core", " ", "%", "d", "\"_", "%_", "(_", "self_", "._", "next", "toe", "xec", "ute", "_", "-_", "WINDOW_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "not_", "(_", "isinstance_", "(_", "self_", "._", "decision", "s_", "[_", "self_", "._", "next", "toe", "xec", "ute", "_", "-_", "WINDOW_", "]_", ",_", "Propos", "al", "Server", "Batch_", ")_", "or_", "\\u\\u\\uNL\\u\\u\\u_", "isinstance_", "(_", "self_", "._", "decision", "s_", "[_", "self_", "._", "next", "toe", "xec", "ute", "_", "-_", "WINDOW_", "]_", ",_", "Propos", "al", "Client", "Batch_", ")_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "self_", "._", "perform", "core_", "(_", "self_", "._", "decision", "s_", "[_", "self_", "._", "next", "toe", "xec", "ute", "_", "-_", "WINDOW_", "]_", ",_", "True_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "designate", "d_", "=_", "designate", "d_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "self_", "._", "debug_", ":_", "self_", "._", "logger_", "._", "write_", "(_", "\"", "State", "\"_", ",_", "\"", "perform", "core", " ", "%", "s", "\"_", "%_", "str_", "(_", "request", "edc", "ommand", "_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "isinstance_", "(_", "request", "edc", "ommand", "_", ",_", "Propos", "al", "Client", "Batch_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "perform", "core", "\\u", "client", "batch_", "(_", "request", "edc", "ommand", "_", ",_", "designate", "d_", "=_", "designate", "d_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "perform", "core_", "(_", "request", "edc", "ommand", "_", ",_", "designate", "d_", "=_", "designate", "d_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Replica", "_", "(_", "Node_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "pick", "\\u", "command", "number", "\\u", "add", "\\u", "to", "\\u", "pending_", "(_", "self_", ",_", "give", "npr", "opo", "sal", "_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "give", "ncom", "mand", "number_", "=_", "self_", "._", "find", "\\u", "command", "number_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "add", "\\u", "to", "\\u", "pend", "ing", "commands_", "(_", "give", "ncom", "mand", "number_", ",_", "give", "npr", "opo", "sal", "_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Replica", "_", "(_", "Node_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "issue", "\\u", "next", "\\u", "command_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "self_", "._", "debug_", ":_", "self_", "._", "logger_", "._", "write_", "(_", "\"", "State", "\"_", ",_", "\"", "Pend", "ing", " ", "command", "s", ":", " ", "%", "s", "\"_", "%_", "str_", "(_", "self_", "._", "pend", "ing", "commands_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "self_", "._", "debug_", ":_", "self_", "._", "logger_", "._", "write_", "(_", "\"", "State", "\"_", ",_", "\"", "Pend", "ing", " ", "command", "set", ":", " ", "%", "s", "\"_", "%_", "str_", "(_", "self_", "._", "pend", "ing", "command", "set_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "len_", "(_", "self_", "._", "pend", "ing", "commands_", ")_", "==_", "0_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "smallest", "command", "number_", "=_", "sorted_", "(_", "self_", "._", "pend", "ing", "commands_", "._", "keys_", "(_", ")_", ")_", "[_", "0_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "smallest", "command", "number_", "in_", "self_", "._", "pend", "ing", "commands_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "self_", "._", "active_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "do", "\\u", "command", "\\u", "propos", "e\\u", "from", "\\u", "pending_", "(_", "smallest", "command", "number_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "do", "\\u", "command", "\\u", "prepar", "e\\u", "from", "\\u", "pending_", "(_", "smallest", "command", "number_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Replica", "_", "(_", "Node_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "issue", "\\u", "pend", "ing", "\\u", "commands_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "self_", "._", "debug_", ":_", "self_", "._", "logger_", "._", "write_", "(_", "\"", "State", "\"_", ",_", "\"", "Pend", "ing", " ", "command", "s", ":", " ", "%", "s", "\"_", "%_", "str_", "(_", "self_", "._", "pend", "ing", "commands_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "len_", "(_", "self_", "._", "pend", "ing", "commands_", ")_", "==_", "0_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "sorte", "dco", "mmand", "numbers_", "=_", "sorted_", "(_", "self_", "._", "pend", "ing", "commands_", "._", "keys_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "smallest", "command", "number_", "in_", "sorte", "dco", "mmand", "numbers_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "self_", "._", "active_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "do", "\\u", "command", "\\u", "propos", "e\\u", "from", "\\u", "pending_", "(_", "smallest", "command", "number_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "do", "\\u", "command", "\\u", "prepar", "e\\u", "from", "\\u", "pending_", "(_", "smallest", "command", "number_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Replica", "_", "(_", "Node_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "msg", "\\u", "perform_", "(_", "self_", ",_", "conn_", ",_", "msg_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "receive", "d", " ", "a", " ", "PERF", "ORM", " ", "message", ",", " ", "perform", " ", "it", " ", "and", " ", "send", " ", "an", "\\", "10", ";", " ", " ", " ", " ", "UPDATE", " ", "message", " ", "to", " ", "the", " ", "source", " ", "if", " ", "necessar", "y", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "perform_", "(_", "msg_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "not_", "self_", "._", "state", "upto", "date_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "self_", "._", "debug_", ":_", "self_", "._", "logger_", "._", "write_", "(_", "\"", "State", "\"_", ",_", "\"", "Up", "dati", "ng", "..\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "msg_", "._", "command", "number_", "==_", "1_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "state", "upto", "date_", "=_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "update", "message_", "=_", "create", "\\u", "message_", "(_", "MS", "G", "\\u", "UPDATE_", ",_", "self_", "._", "me_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "conn_", "._", "send_", "(_", "update", "message_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Replica", "_", "(_", "Node_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "msg", "\\u", "issue_", "(_", "self_", ",_", "conn_", ",_", "msg_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "issue", "\\u", "pend", "ing", "\\u", "commands_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Replica", "_", "(_", "Node_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "msg", "\\u", "hel", "o_", "(_", "self_", ",_", "conn_", ",_", "msg_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "self_", "._", "debug_", ":_", "self_", "._", "logger_", "._", "write_", "(_", "\"", "State", "\"_", ",_", "\"", "Receive", "d", " ", "HE", "LO", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Thi", "s", " ", "is", " ", "the", " ", "first", " ", "other", " ", "replica", ",", " ", "it", " ", "shou", "ld", " ", "be", " ", "adde", "d", " ", "by", " ", "this", " ", "replica_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "len_", "(_", "self_", "._", "replicas_", ")_", "==_", "0_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "self_", "._", "debug_", ":_", "self_", "._", "logger_", "._", "write_", "(_", "\"", "State", "\"_", ",_", "\"", "Add", "ing", " ", "the", " ", "first", " ", "REPLICA", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Agr", "ee", " ", "on", " ", "addin", "g", " ", "self", " ", "and", " ", "the", " ", "first", " ", "replica", ":_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "bec", "ome", "\\u", "leader_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Add", " ", "self_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "replicas_", "[_", "self_", "._", "me_", "]_", "=_", "0_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "addc", "ommand", "_", "=_", "self_", "._", "create", "\\u", "add", "\\u", "command_", "(_", "self_", "._", "me_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "pick", "\\u", "command", "number", "\\u", "add", "\\u", "to", "\\u", "pending_", "(_", "addc", "ommand", "_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "i_", "in_", "range_", "(_", "WINDOW_", "+_", "3_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "noop", "command_", "=_", "self_", "._", "create", "\\u", "noop", "\\u", "command_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "pick", "\\u", "command", "number", "\\u", "add", "\\u", "to", "\\u", "pending_", "(_", "noop", "command_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "issue", "\\u", "pend", "ing", "\\u", "commands_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Add", " ", "replica_", "\\u\\u\\uNL\\u\\u\\u_", "addc", "ommand", "_", "=_", "self_", "._", "create", "\\u", "add", "\\u", "command_", "(_", "msg_", "._", "source_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "pick", "\\u", "command", "number", "\\u", "add", "\\u", "to", "\\u", "pending_", "(_", "addc", "ommand", "_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "i_", "in_", "range_", "(_", "WINDOW_", "+_", "3_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "noop", "command_", "=_", "self_", "._", "create", "\\u", "noop", "\\u", "command_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "pick", "\\u", "command", "number", "\\u", "add", "\\u", "to", "\\u", "pending_", "(_", "noop", "command_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "issue", "\\u", "pend", "ing", "\\u", "commands_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "self_", "._", "isl", "eader", "_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "self_", "._", "debug_", ":_", "self_", "._", "logger_", "._", "write_", "(_", "\"", "State", "\"_", ",_", "\"", "Add", "ing", " ", "the", " ", "new", " ", "node", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "addc", "ommand", "_", "=_", "self_", "._", "create", "\\u", "add", "\\u", "command_", "(_", "msg_", "._", "source_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "pick", "\\u", "command", "number", "\\u", "add", "\\u", "to", "\\u", "pending_", "(_", "addc", "ommand", "_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "i_", "in_", "range_", "(_", "WINDOW_", "+_", "3_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "noop", "command_", "=_", "self_", "._", "create", "\\u", "noop", "\\u", "command_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "pick", "\\u", "command", "number", "\\u", "add", "\\u", "to", "\\u", "pending_", "(_", "noop", "command_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "issue", "\\u", "pend", "ing", "\\u", "commands_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "self_", "._", "debug_", ":_", "self_", "._", "logger_", "._", "write_", "(_", "\"", "State", "\"_", ",_", "\"", "Not", " ", "the", " ", "leader", ",", " ", "sendin", "g", " ", "a", " ", "HE", "LO", "REPLY", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "self_", "._", "debug_", ":_", "self_", "._", "logger_", "._", "write_", "(_", "\"", "State", "\"_", ",_", "\"", "Leader", " ", "is", " ", "%", "s", "\"_", "%_", "str_", "(_", "self_", "._", "find", "\\u", "leader_", "(_", ")_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "hel", "ore", "ply", "message_", "=_", "create", "\\u", "message_", "(_", "MS", "G", "\\u", "HE", "LO", "REPLY_", ",_", "self_", "._", "me_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "{_", "FL", "D", "\\u", "LEA", "DER", "_", ":_", "self_", "._", "find", "\\u", "leader_", "(_", ")_", "}_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "conn_", "._", "send_", "(_", "hel", "ore", "ply", "message_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Replica", "_", "(_", "Node_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "msg", "\\u", "update_", "(_", "self_", ",_", "conn_", ",_", "msg_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "a", " ", "replica", " ", "need", "s", " ", "to", " ", "be", " ", "update", "d", " ", "on", " ", "the", " ", "set", " ", "of", " ", "past", " ", "decision", "s", ",", " ", "send", " ", "caller", "'", "s", " ", "decision", "s", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Thi", "s", " ", "shou", "ld", " ", "be", " ", "don", "e", " ", "only", " ", "if", " ", "it", " ", "has", " ", "not", " ", "bee", "n", " ", "don", "e", " ", "recent", "ly", "._", "\\u\\u\\uNL\\u\\u\\u_", "with_", "self_", "._", "recent", "ly", "update", "dp", "eer", "slo", "ck_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "msg_", "._", "source_", "in_", "self_", "._", "recent", "ly", "update", "dp", "eer", "s_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "updater", "epl", "yme", "ssa", "ge_", "=_", "create", "\\u", "message_", "(_", "MS", "G", "\\u", "UPDATE", "REPLY_", ",_", "self_", "._", "me_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "{_", "FL", "D", "\\u", "DEC", "ISI", "ONS", "_", ":_", "self_", "._", "decision", "s_", "}_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "conn_", "._", "send_", "(_", "updater", "epl", "yme", "ssa", "ge_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "with_", "self_", "._", "recent", "ly", "update", "dp", "eer", "slo", "ck_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "recent", "ly", "update", "dp", "eer", "s_", "._", "append_", "(_", "msg_", "._", "source_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Replica", "_", "(_", "Node_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "msg", "\\u", "updater", "epl", "y_", "(_", "self_", ",_", "conn_", ",_", "msg_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "merge", " ", "decision", "s", " ", "receive", "d", " ", "with", " ", "local", " ", "decision", "s", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "If", " ", "the", " ", "node", " ", "is", " ", "alr", "ead", "y", " ", "up", "-", "to", "-", "date", ",", " ", "return", "._", "\\u\\u\\uNL\\u\\u\\u_", "if_", "self_", "._", "state", "upto", "date_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "for_", "key_", ",_", "value_", "in_", "self_", "._", "decision", "s_", "._", "iteritems_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "key_", "in_", "msg_", "._", "decision", "s_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "assert_", "self_", "._", "decision", "s_", "[_", "key_", "]_", "==_", "msg_", "._", "decision", "s_", "[_", "key_", "]_", ",_", "\"", "Update", " ", "Error", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "update", " ", "decision", "s", " ", "cumul", "ative", "ly_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "decision", "s_", "._", "update_", "(_", "msg_", "._", "decision", "s_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "decision", "set_", "=_", "set_", "(_", "self_", "._", "decision", "s_", "._", "values_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "used", "command", "numbers_", "=_", "self_", "._", "used", "command", "numbers_", "._", "union_", "(_", "set_", "(_", "self_", "._", "decision", "s_", "._", "keys_", "(_", ")_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Execut", "e", " ", "the", " ", "ones", " ", "tha", "t", " ", "we", " ", "can", " ", "execute_", "\\u\\u\\uNL\\u\\u\\u_", "while_", "self_", "._", "next", "toe", "xec", "ute", "_", "in_", "self_", "._", "decision", "s_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "request", "edc", "ommand", "_", "=_", "self_", "._", "decision", "s_", "[_", "self_", "._", "next", "toe", "xec", "ute", "_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "request", "edc", "ommand", "_", "in_", "self_", "._", "executed", "_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "self_", "._", "debug_", ":_", "self_", "._", "logger_", "._", "write_", "(_", "\"", "State", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "Prev", "ious", "ly", " ", "executed", " ", "command", " ", "%", "d", ".\"_", "\\u\\u\\uNL\\u\\u\\u_", "%_", "self_", "._", "next", "toe", "xec", "ute", "_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Execut", "e", " ", "the", " ", "meta", "command", " ", "associate", "d", " ", "with", " ", "this", " ", "command_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "self_", "._", "next", "toe", "xec", "ute", "_", ">_", "WINDOW_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "if_", "self_", "._", "debug_", ":_", "self_", "._", "logger_", "._", "write_", "(_", "\"", "State", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "perform", "core", " ", "%", "d", "\"_", "\\u\\u\\uNL\\u\\u\\u_", "%_", "(_", "self_", "._", "next", "toe", "xec", "ute", "_", "-_", "WINDOW_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "perform", "core_", "(_", "self_", "._", "decision", "s_", "[_", "self_", "._", "next", "toe", "xec", "ute", "_", "-_", "WINDOW_", "]_", ",_", "True_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "next", "toe", "xec", "ute", "_", "+=_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "request", "edc", "ommand", "_", "not_", "in_", "self_", "._", "executed", "_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "self_", "._", "debug_", ":_", "self_", "._", "logger_", "._", "write_", "(_", "\"", "State", "\"_", ",_", "\"", "executi", "ng", " ", "command", " ", "%", "d", ".\"_", "%_", "self_", "._", "next", "toe", "xec", "ute", "_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "self_", "._", "next", "toe", "xec", "ute", "_", ">_", "WINDOW_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "if_", "self_", "._", "debug_", ":_", "self_", "._", "logger_", "._", "write_", "(_", "\"", "State", "\"_", ",_", "\"", "perform", "core", " ", "%", "d", "\"_", "%_", "(_", "self_", "._", "next", "toe", "xec", "ute", "_", "-_", "WINDOW_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "perform", "core_", "(_", "self_", "._", "decision", "s_", "[_", "self_", "._", "next", "toe", "xec", "ute", "_", "-_", "WINDOW_", "]_", ",_", "True_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "self_", "._", "debug_", ":_", "self_", "._", "logger_", "._", "write_", "(_", "\"", "State", "\"_", ",_", "\"", "perform", "core", " ", "%", "d", "\"_", "%_", "self_", "._", "next", "toe", "xec", "ute", "_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "perform", "core_", "(_", "self_", "._", "decision", "s_", "[_", "self_", "._", "next", "toe", "xec", "ute", "_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "next", "toe", "xec", "ute", "_", "+=_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "the", " ", "window", " ", "got", " ", "bump", "ed_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "check", " ", "if", " ", "there", " ", "are", " ", "pend", "ing", " ", "command", "s", ",", " ", "and", " ", "issue", " ", "one", " ", "of", " ", "them", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "issue", "\\u", "pend", "ing", "\\u", "commands_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "self_", "._", "debug_", ":_", "self_", "._", "logger_", "._", "write_", "(_", "\"", "State", "\"_", ",_", "\"", "Update", " ", "is", " ", "don", "e", "!\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "state", "upto", "date_", "=_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Replica", "_", "(_", "Node_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "do", "\\u", "noop_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "self_", "._", "debug_", ":_", "self_", "._", "logger_", "._", "write_", "(_", "\"", "State", ":\"_", ",_", "\"", "doi", "ng", " ", "noop", "!\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Replica", "_", "(_", "Node_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "\\u", "add", "\\u", "node_", "(_", "self_", ",_", "nodet", "ype_", ",_", "nodename_", ",_", "epoch_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "nodet", "ype_", "=_", "int_", "(_", "nodet", "ype_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "self_", "._", "debug_", ":_", "self_", "._", "logger_", "._", "write_", "(_", "\"", "State", "\"_", ",_", "\"", "Add", "ing", " ", "node", ":", " ", "%", "s", " ", "%", "s", "\"_", "%_", "(_", "node", "\\u", "names_", "[_", "nodet", "ype_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "nodename_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "ipaddr_", ",_", "port_", "=_", "nodename_", "._", "split_", "(_", "\":\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "node", "peer_", "=_", "Peer", "_", "(_", "ipaddr_", ",_", "int_", "(_", "port_", ")_", ",_", "nodet", "ype_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "replicas_", "[_", "node", "peer_", "]_", "=_", "0_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "update", " ", "the", " ", "revis", "ion", " ", "if", " ", "nameserv", "er_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "self_", "._", "isn", "ames", "erver_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "nameserv", "er_", "._", "update_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "if", " ", "leader", ",", " ", "increment", " ", "epoch", " ", "in", " ", "the", " ", "ballot", "number_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "temp_", "=_", "(_", "self_", "._", "ballot", "number_", "[_", "BAL", "LOT", "EPOCH", "_", "]_", "+_", "1_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "ballot", "number_", "[_", "BAL", "LOT", "NO_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "ballot", "number_", "[_", "BAL", "LOT", "NODE_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "self_", "._", "debug_", ":_", "self_", "._", "logger_", "._", "write_", "(_", "\"", "State", ":\"_", ",_", "\"", "Increment", "ed", " ", "EPOCH", ":", " ", "%", "s", "\"_", "%_", "str_", "(_", "temp_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "ballot", "number_", "=_", "temp_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "check", " ", "leader", "ship", " ", "state_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "self_", "._", "state", "upto", "date_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "chosen", "leader_", "=_", "self_", "._", "find", "\\u", "leader_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "chosen", "leader_", "==_", "self_", "._", "me_", "and_", "not_", "self_", "._", "isl", "eader", "_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "bec", "ome", " ", "the", " ", "leader_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "not_", "self_", "._", "state", "upto", "date_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "self_", "._", "leader", "\\u", "initiali", "zin", "g_", "=_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "bec", "ome", "\\u", "leader_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "chosen", "leader_", "!=_", "self_", "._", "me_", "and_", "self_", "._", "isl", "eader", "_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "unb", "ecom", "e", " ", "the", " ", "leader_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "unb", "ecom", "e\\u", "leader_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Replica", "_", "(_", "Node_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "\\u", "del", "\\u", "node_", "(_", "self_", ",_", "nodet", "ype_", ",_", "nodename_", ",_", "epoch_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "nodet", "ype_", "=_", "int_", "(_", "nodet", "ype_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "self_", "._", "debug_", ":_", "self_", "._", "logger_", "._", "write_", "(_", "\"", "State", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "Del", "eti", "ng", " ", "node", ":", " ", "%", "s", " ", "%", "s", "\"_", "%_", "(_", "node", "\\u", "names_", "[_", "nodet", "ype_", "]_", ",_", "nodename_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "ipaddr_", ",_", "port_", "=_", "nodename_", "._", "split_", "(_", "\":\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "node", "peer_", "=_", "Peer", "_", "(_", "ipaddr_", ",_", "int_", "(_", "port_", ")_", ",_", "nodet", "ype_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "del_", "self_", "._", "replicas_", "[_", "node", "peer_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "Key", "Error_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "self_", "._", "debug_", ":_", "self_", "._", "logger_", "._", "write_", "(_", "\"", "State", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "Cann", "ot", " ", "delete", " ", "node", " ", "tha", "t", " ", "is", " ", "not", " ", "in", " ", "the", " ", "view", ":", " ", "%", "s", " ", "%", "s", "\"_", "\\u\\u\\uNL\\u\\u\\u_", "%_", "(_", "node", "\\u", "names_", "[_", "nodet", "ype_", "]_", ",_", "nodename_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "remove", " ", "the", " ", "node", " ", "from", " ", "nodes", "bei", "ng", "deleted_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "node", "peer_", "in_", "self_", "._", "nodes", "bei", "ng", "deleted_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "nodes", "bei", "ng", "deleted_", "._", "remove_", "(_", "node", "peer_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "update", " ", "the", " ", "revis", "ion", " ", "if", " ", "nameserv", "er_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "self_", "._", "isn", "ames", "erver_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "nameserv", "er_", "._", "update_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "if", " ", "leader", ",", " ", "increment", " ", "epoch", " ", "in", " ", "the", " ", "ballot", "number_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "temp_", "=_", "(_", "self_", "._", "ballot", "number_", "[_", "BAL", "LOT", "EPOCH", "_", "]_", "+_", "1_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "ballot", "number_", "[_", "BAL", "LOT", "NO_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "ballot", "number_", "[_", "BAL", "LOT", "NODE_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "self_", "._", "debug_", ":_", "self_", "._", "logger_", "._", "write_", "(_", "\"", "State", ":\"_", ",_", "\"", "Increment", "ed", " ", "EPOCH", ":", " ", "%", "s", "\"_", "%_", "str_", "(_", "temp_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "ballot", "number_", "=_", "temp_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "if", " ", "delete", "d", " ", "node", " ", "is", " ", "a", " ", "replica", " ", "and", " ", "this", " ", "replica", " ", "is", " ", "upto", "date_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "check", " ", "leader", "ship", " ", "state_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "self_", "._", "state", "upto", "date_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "chosen", "leader_", "=_", "self_", "._", "find", "\\u", "leader_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "chosen", "leader_", "==_", "self_", "._", "me_", "and_", "not_", "self_", "._", "isl", "eader", "_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "bec", "ome", " ", "the", " ", "leader_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "not_", "self_", "._", "state", "upto", "date_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "self_", "._", "leader", "\\u", "initiali", "zin", "g_", "=_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "bec", "ome", "\\u", "leader_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "chosen", "leader_", "!=_", "self_", "._", "me_", "and_", "self_", "._", "isl", "eader", "_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "unb", "ecom", "e", " ", "the", " ", "leader_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "unb", "ecom", "e\\u", "leader_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "if", " ", "delete", "d", " ", "node", " ", "is", " ", "self", " ", "and", " ", "the", " ", "node", " ", "is", " ", "not", " ", "just", " ", "repla", "ying", " ", "history_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "node", "peer_", "==_", "self_", "._", "me_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "self_", "._", "debug_", ":_", "self_", "._", "logger_", "._", "write_", "(_", "\"", "State", "\"_", ",_", "\"", "I", " ", "have", " ", "bee", "n", " ", "delete", "d", " ", "from", " ", "the", " ", "view", ".\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "\\u", "rej", "oin", "_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Replica", "_", "(_", "Node_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "\\u", "gar", "bage", "\\u", "collect_", "(_", "self_", ",_", "gar", "bage", "command", "number_", ",_", "epoch_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", " ", "gar", "bage", " ", "collect", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "self_", "._", "debug_", ":_", "self_", "._", "logger_", "._", "write_", "(_", "\"", "State", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "Initiat", "ing", " ", "gar", "bage", " ", "collection", " ", "upto", " ", "cmd", "#", "%", "d", "\"_", "\\u\\u\\uNL\\u\\u\\u_", "%_", "gar", "bage", "command", "number_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "snapshot_", "=_", "pickle_", "._", "dumps_", "(_", "self_", "._", "object_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "gar", "bage", "msg_", "=_", "create", "\\u", "message_", "(_", "MS", "G", "\\u", "GAR", "BA", "GE", "COLL", "ECT", "_", ",_", "self_", "._", "me_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "{_", "FL", "D", "\\u", "COMMA", "ND", "NUMBER_", ":_", "gar", "bage", "command", "number_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "FL", "D", "\\u", "SNAPSHOT", "_", ":_", "snapshot_", "}_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "send_", "(_", "gar", "bage", "msg_", ",_", "group_", "=_", "self_", "._", "replicas_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "do", " ", "local", " ", "gar", "bage", " ", "collection_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "local", "\\u", "gar", "bage", "\\u", "collect_", "(_", "gar", "bage", "command", "number_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Replica", "_", "(_", "Node_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "local", "\\u", "gar", "bage", "\\u", "collect_", "(_", "self_", ",_", "command", "number_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Truncate", "s", " ", "decision", "s", ",", " ", "executed", " ", "and", " ", "proposals", "\\", "10", ";", " ", " ", " ", " ", "up", " ", "to", " ", "give", "n", " ", "command", "number", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "keys_", "=_", "sorted_", "(_", "self_", "._", "decision", "s_", "._", "keys_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Sanit", "y", " ", "checking", "_", "\\u\\u\\uNL\\u\\u\\u_", "last", "key_", "=_", "keys_", "[_", "0_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "cand", "ele", "te_", "=_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "cmd", "no_", "in_", "keys_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "cmd", "no_", "==_", "last", "key_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "last", "key_", "+=_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "cand", "ele", "te_", "=_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "break_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Trun", "cati", "ng_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "not_", "cand", "ele", "te_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "for_", "cmd", "no_", "in_", "keys_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "cmd", "no_", "<_", "command", "number_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "self_", "._", "decision", "s_", "[_", "cmd", "no_", "]_", "in_", "self_", "._", "executed", "_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "del_", "self_", "._", "executed", "_", "[_", "self_", "._", "decision", "s_", "[_", "cmd", "no_", "]_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "del_", "self_", "._", "proposals", "_", "[_", "cmd", "no_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "pass_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", "del", " ", "self", ".", "decision", "s", "[", "cmd", "no", "]_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "break_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Replica", "_", "(_", "Node_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "bec", "ome", "\\u", "leader_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "Leader", " ", "State", "\\", "10", ";", " ", " ", " ", " ", "-", " ", "active", ":", " ", "indicat", "es", " ", "if", " ", "the", " ", "Leader", " ", "has", " ", "a", " ", "*", "good", "*", " ", "ballot", "number", "\\", "10", ";", " ", " ", " ", " ", "-", " ", "ballot", "number", ":", " ", "the", " ", "high", "est", " ", "ballot", "number", " ", "Leader", " ", "has", " ", "used", "\\", "10", ";", " ", " ", " ", " ", "-", " ", "outstanding", "prepar", "es", ":", " ", "Respons", "e", "Collect", "or", " ", "dictionar", "y", " ", "for", " ", "MS", "G", "\\u", "PREP", "ARE", ",", "\\", "10", ";", " ", " ", " ", " ", "indexe", "d", " ", "by", " ", "ballot", "number", "\\", "10", ";", " ", " ", " ", " ", "-", " ", "outstanding", "propos", "es", ":", " ", "Respons", "e", "Collect", "or", " ", "dictionar", "y", " ", "for", " ", "MS", "G", "\\u", "PROP", "OSE", ",", "\\", "10", ";", " ", " ", " ", " ", "indexe", "d", " ", "by", " ", "command", "number", "\\", "10", ";", " ", " ", " ", " ", "-", " ", "receive", "dcl", "ient", "request", "s", ":", " ", "command", "s", " ", "receive", "d", " ", "from", " ", "clients", " ", "as", "\\", "10", ";", " ", " ", " ", " ", "<", "(", "client", ",", "client", "command", "number", "):", "command", ">", " ", "mapping", "s", "\\", "10", ";", " ", " ", " ", " ", "-", " ", "backoff", ":", " ", "backoff", " ", "amo", "unt", " ", "tha", "t", " ", "is", " ", "used", " ", "to", " ", "dete", "rmin", "e", " ", "how", " ", "muc", "h", " ", "a", " ", "leader", " ", "shou", "ld", "\\", "10", ";", " ", " ", " ", " ", "backoff", " ", "dur", "ing", " ", "a", " ", "coll", "usion", "\\", "10", ";", " ", " ", " ", " ", "-", " ", "command", "gap", ":", " ", "next", " ", "command", "number", " ", "tha", "t", " ", "will", " ", "be", " ", "used", " ", "by", " ", "this", " ", "leader", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "not_", "self_", "._", "isl", "eader", "_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "isl", "eader", "_", "=_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "active_", "=_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "outstanding", "prepar", "es_", "=_", "{_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "outstanding", "propos", "es_", "=_", "{_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "receive", "dcl", "ient", "requests_", "=_", "{_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "backoff_", "=_", "0_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "command", "gap_", "=_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "leader", "\\u", "initiali", "zin", "g_", "=_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "backoff", "\\u", "thread_", "=_", "Thread_", "(_", "target_", "=_", "self_", "._", "update", "\\u", "backoff_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "backoff", "\\u", "event_", "._", "clear_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "backoff", "\\u", "thread_", "._", "start_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "self_", "._", "debug_", ":_", "self_", "._", "logger_", "._", "write_", "(_", "\"", "State", "\"_", ",_", "\"", "Be", "comi", "ng", " ", "LEA", "DER", "!\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Replica", "_", "(_", "Node_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "unb", "ecom", "e\\u", "leader_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "drop", " ", "LEA", "DER", " ", "state", ",", " ", "bec", "ome", " ", "a", " ", "replica", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "fail", "-", "stop", " ", "tolera", "nce", ",", " ", "couple", "d", " ", "with", " ", "retrie", "s", " ", "in", " ", "the", " ", "client", ",", " ", "mean", " ", "tha", "t", " ", "a_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "leader", " ", "can", " ", "at", " ", "any", " ", "time", " ", "discard", " ", "all", " ", "of", " ", "its", " ", "internal", " ", "state", " ", "and", " ", "the", " ", "protocol_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "will", " ", "still", " ", "work", " ", "correct", "ly", "._", "\\u\\u\\uNL\\u\\u\\u_", "if_", "self_", "._", "debug_", ":_", "self_", "._", "logger_", "._", "write_", "(_", "\"", "State", ":\"_", ",_", "\"", "Unb", "ecom", "ing", " ", "LEA", "DER", "!\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "isl", "eader", "_", "=_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "backoff", "\\u", "event_", "._", "set_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Replica", "_", "(_", "Node_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "update", "\\u", "backoff_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "used", " ", "by", " ", "the", " ", "backoff", "thread", " ", "to", " ", "decrease", " ", "the", " ", "backoff", " ", "amo", "unt", " ", "by", " ", "half", " ", "periodic", "ally", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "while_", "not_", "backoff", "\\u", "event_", "._", "is", "Set_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "backoff_", "=_", "self_", "._", "backoff_", "/_", "2_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "backoff", "\\u", "event_", "._", "wait_", "(_", "BACK", "OFF", "DEC", "REA", "SET", "IME", "OUT_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Replica", "_", "(_", "Node_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "detect", "\\u", "colli", "ding", "\\u", "leader_", "(_", "self_", ",_", "ballot", "number_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "detect", "s", " ", "a", " ", "colli", "ding", " ", "leader", " ", "from", " ", "the", " ", "high", "est", " ", "ballot", "number", " ", "receive", "d", " ", "from", " ", "replica", "s", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "other", "leader", "\\u", "addr_", ",_", "other", "leader", "\\u", "port_", "=_", "ballot", "number_", "[_", "BAL", "LOT", "NODE_", "]_", "._", "split_", "(_", "\":\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "other", "leader_", "=_", "Peer", "_", "(_", "other", "leader", "\\u", "addr_", ",_", "int_", "(_", "other", "leader", "\\u", "port_", ")_", ",_", "NODE", "\\u", "REPLICA", "_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "other", "leader_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Replica", "_", "(_", "Node_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "leader", "\\u", "is", "\\u", "alive_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "return", "s", " ", "a", " ", "tuple", " ", "if", " ", "the", " ", "leader", " ", "is", " ", "alive", " ", "and", " ", "the", " ", "currentl", "eader", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "currentl", "eader", "_", "=_", "self_", "._", "find", "\\u", "leader_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "currentl", "eader", "_", "!=_", "self_", "._", "me_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "self_", "._", "debug_", ":_", "self_", "._", "logger_", "._", "write_", "(_", "\"", "State", "\"_", ",_", "\"", "Sen", "ding", " ", "PING", " ", "to", " ", "%", "s", "\"_", "%_", "str_", "(_", "currentl", "eader", "_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "ping", "message_", "=_", "create", "\\u", "message_", "(_", "MS", "G", "\\u", "PING", "_", ",_", "self_", "._", "me_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "success", "id_", "=_", "self_", "._", "send_", "(_", "ping", "message_", ",_", "peer_", "=_", "currentl", "eader", "_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "success", "id_", "<_", "0_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "replicas_", "[_", "currentl", "eader", "_", "]_", "+=_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "False_", ",_", "currentl", "eader", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "True_", ",_", "currentl", "eader", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Replica", "_", "(_", "Node_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "find", "\\u", "leader_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "return", "s", " ", "the", " ", "minim", "um", " ", "peer", " ", "tha", "t", " ", "is", " ", "alive", " ", "as", " ", "the", " ", "leader", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "sort", " ", "the", " ", "replica", "s", " ", "first_", "\\u\\u\\uNL\\u\\u\\u_", "replicas_", "=_", "sorted_", "(_", "self_", "._", "replicas_", "._", "items_", "(_", ")_", ",_", "key_", "=_", "lambda_", "t_", ":_", "t_", "[_", "0_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "self_", "._", "debug_", ":_", "self_", "._", "logger_", "._", "write_", "(_", "\"", "State", "\"_", ",_", "\"", "All", " ", "Replica", "s", " ", "in", " ", "my", " ", "view", ":", "%", "s", "\"_", "%_", "str_", "(_", "replicas_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "(_", "replica_", ",_", "live", "ness_", ")_", "in_", "replicas_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "live", "ness_", "==_", "0_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "del_", "replicas_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "self_", "._", "debug_", ":_", "self_", "._", "logger_", "._", "write_", "(_", "\"", "State", "\"_", ",_", "\"", "Leader", " ", "is", " ", "%", "s", "\"_", "%_", "str_", "(_", "replica_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "replica_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "del_", "replicas_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "self_", "._", "debug_", ":_", "self_", "._", "logger_", "._", "write_", "(_", "\"", "State", "\"_", ",_", "\"", "Leader", " ", "is", " ", "me", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "self_", "._", "me_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Replica", "_", "(_", "Node_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "update", "\\u", "ballot", "number_", "(_", "self_", ",_", "seed", "ballot", "number_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "update", " ", "the", " ", "ballot", "number", " ", "with", " ", "a", " ", "higher", " ", "value", " ", "than", " ", "the", " ", "give", "n", " ", "ballot", "number", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "assert_", "seed", "ballot", "number_", "[_", "BAL", "LOT", "EPOCH", "_", "]_", "==_", "self_", "._", "ballot", "number_", "[_", "BAL", "LOT", "EPOCH", "_", "]_", ",_", "\"%", "s", " ", "is", " ", "in", " ", "epoch", " ", "%", "d", " ", "inst", "ead", " ", "of", " ", "%", "d", "\"_", "%_", "(_", "str_", "(_", "self_", "._", "me_", ")_", ",_", "seed", "ballot", "number_", "[_", "BAL", "LOT", "EPOCH", "_", "]_", ",_", "self_", "._", "ballot", "number_", "[_", "BAL", "LOT", "EPOCH", "_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "temp_", "=_", "(_", "self_", "._", "ballot", "number_", "[_", "BAL", "LOT", "EPOCH", "_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "seed", "ballot", "number_", "[_", "BAL", "LOT", "NO_", "]_", "+_", "1_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "ballot", "number_", "[_", "BAL", "LOT", "NODE_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "self_", "._", "debug_", ":_", "self_", "._", "logger_", "._", "write_", "(_", "\"", "State", ":\"_", ",_", "\"", "Update", "d", " ", "ballot", "number", " ", "to", " ", "%", "s", "\"_", "%_", "str_", "(_", "temp_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "ballot", "number_", "=_", "temp_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Replica", "_", "(_", "Node_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "find", "\\u", "command", "number_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "return", "s", " ", "the", " ", "first", " ", "gap", " ", "in", " ", "proposals", " ", "and", " ", "decision", "s", " ", "combin", "ed", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "while_", "self_", "._", "command", "gap_", "<=_", "len_", "(_", "self_", "._", "used", "command", "numbers_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "self_", "._", "command", "gap_", "in_", "self_", "._", "used", "command", "numbers_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "command", "gap_", "+=_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "self_", "._", "debug_", ":_", "self_", "._", "logger_", "._", "write_", "(_", "\"", "State", "\"_", ",_", "\"", "Picke", "d", " ", "command", " ", "number", ":", " ", "%", "d", "\"_", "%_", "self_", "._", "command", "gap_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "used", "command", "numbers_", "._", "add_", "(_", "self_", "._", "command", "gap_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "self_", "._", "command", "gap_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "self_", "._", "debug_", ":_", "self_", "._", "logger_", "._", "write_", "(_", "\"", "State", "\"_", ",_", "\"", "Picke", "d", " ", "command", " ", "number", ":", " ", "%", "d", "\"_", "%_", "self_", "._", "command", "gap_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "used", "command", "numbers_", "._", "add_", "(_", "self_", "._", "command", "gap_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "self_", "._", "command", "gap_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Replica", "_", "(_", "Node_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "add", "\\u", "to", "\\u", "executed", "_", "(_", "self_", ",_", "key_", ",_", "value_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "executed", "_", "[_", "key_", "]_", "=_", "value_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Replica", "_", "(_", "Node_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "add", "\\u", "to", "\\u", "decision", "s_", "(_", "self_", ",_", "key_", ",_", "value_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "decision", "s_", "[_", "key_", "]_", "=_", "value_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "isinstance_", "(_", "value_", ",_", "Propos", "al", "Server", "Batch_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "for_", "item_", "in_", "value_", "._", "proposals", "_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "decision", "set_", "._", "add_", "(_", "item_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "decision", "set_", "._", "add_", "(_", "value_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "used", "command", "numbers_", "._", "add_", "(_", "key_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Replica", "_", "(_", "Node_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "add", "\\u", "to", "\\u", "proposals", "_", "(_", "self_", ",_", "key_", ",_", "value_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "proposals", "_", "[_", "key_", "]_", "=_", "value_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "isinstance_", "(_", "value_", ",_", "Propos", "al", "Server", "Batch_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "for_", "item_", "in_", "value_", "._", "proposals", "_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "proposals", "et_", "._", "add_", "(_", "item_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "proposals", "et_", "._", "add_", "(_", "value_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "used", "command", "numbers_", "._", "add_", "(_", "key_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Replica", "_", "(_", "Node_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "add", "\\u", "to", "\\u", "pend", "ing", "commands_", "(_", "self_", ",_", "key_", ",_", "value_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "If", " ", "a", " ", "Replica", " ", "adds", " ", "a", " ", "pend", "ing", "command", " ", "bef", "ore", " ", "it", " ", "is", " ", "up", " ", "to", " ", "date_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "it", " ", "assign", "s", " ", "1", " ", "as", " ", "a", " ", "command", "number", " ", "for", " ", "a", " ", "command", ".", " ", "Thi", "s", " ", "later_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "gets", " ", "overwrit", "ten", " ", "whe", "n", " ", "the", " ", "same", " ", "command", " ", "is", " ", "adde", "d", " ", "late", "r", " ", "with_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "a", " ", "higher", " ", "command", "number", " ", "in", " ", "the", " ", "pend", "ing", "command", "set", " ", "but", " ", "not", " ", "in_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "in", " ", "the", " ", "pend", "ing", "command", "s", " ", "as", " ", "the", "y", " ", "have", " ", "different", " ", "keys", ".", " ", "The", " ", "case_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "tha", "t", " ", "caus", "es", " ", "this", " ", "to", " ", "happ", "en", " ", "shou", "ld", " ", "be", " ", "prevent", "ed", ",", " ", "addin", "g", " ", "an", " ", "if_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "case", " ", "in", " ", "this", " ", "function", " ", "will", " ", "not", " ", "fix", " ", "the", " ", "logic", ",", " ", "will", " ", "just", " ", "get", " ", "rid_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "of", " ", "the", " ", "symp", "tom", "._", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "pend", "ing", "commands_", "[_", "key_", "]_", "=_", "value_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "isinstance_", "(_", "value_", ",_", "Propos", "al", "Server", "Batch_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "for_", "item_", "in_", "value_", "._", "proposals", "_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "pend", "ing", "command", "set_", "._", "add_", "(_", "item_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "pend", "ing", "command", "set_", "._", "add_", "(_", "value_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Replica", "_", "(_", "Node_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "remove", "\\u", "from", "\\u", "executed", "_", "(_", "self_", ",_", "key_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "del_", "self_", "._", "executed", "_", "[_", "key_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Replica", "_", "(_", "Node_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "remove", "\\u", "from", "\\u", "decision", "s_", "(_", "self_", ",_", "key_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "value_", "=_", "self_", "._", "decision", "s_", "[_", "key_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "isinstance_", "(_", "value_", ",_", "Propos", "al", "Server", "Batch_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "for_", "item_", "in_", "value_", "._", "proposals", "_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "decision", "set_", "._", "remove_", "(_", "item_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "decision", "set_", "._", "remove_", "(_", "value_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "del_", "self_", "._", "decision", "s_", "[_", "key_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "used", "command", "numbers_", "._", "remove_", "(_", "key_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "command", "gap_", "=_", "key_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Replica", "_", "(_", "Node_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "remove", "\\u", "from", "\\u", "proposals", "_", "(_", "self_", ",_", "key_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "value_", "=_", "self_", "._", "proposals", "_", "[_", "key_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "isinstance_", "(_", "value_", ",_", "Propos", "al", "Server", "Batch_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "for_", "item_", "in_", "value_", "._", "proposals", "_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "proposals", "et_", "._", "remove_", "(_", "item_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "proposals", "et_", "._", "remove_", "(_", "value_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "del_", "self_", "._", "proposals", "_", "[_", "key_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "used", "command", "numbers_", "._", "remove_", "(_", "key_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "command", "gap_", "=_", "key_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Replica", "_", "(_", "Node_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "remove", "\\u", "from", "\\u", "pend", "ing", "commands_", "(_", "self_", ",_", "key_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "value_", "=_", "self_", "._", "pend", "ing", "commands_", "[_", "key_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "isinstance_", "(_", "value_", ",_", "Propos", "al", "Server", "Batch_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "for_", "item_", "in_", "value_", "._", "proposals", "_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "pend", "ing", "command", "set_", "._", "remove_", "(_", "item_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "pend", "ing", "command", "set_", "._", "remove_", "(_", "value_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "del_", "self_", "._", "pend", "ing", "commands_", "[_", "key_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Replica", "_", "(_", "Node_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "handle", "\\u", "client", "\\u", "command_", "(_", "self_", ",_", "give", "ncom", "mand", "_", ",_", "send", "count_", "=_", "1_", ",_", "prepare_", "=_", "False_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "handle", " ", "receive", "d", " ", "command", "\\", "10", ";", " ", " ", " ", " ", "-", " ", "if", " ", "it", " ", "has", " ", "bee", "n", " ", "receive", "d", " ", "bef", "ore", " ", "check", " ", "if", " ", "it", " ", "has", " ", "bee", "n", " ", "executed", "\\", "10", ";", " ", " ", " ", " ", "--", " ", "if", " ", "it", " ", "has", " ", "bee", "n", " ", "executed", " ", "send", " ", "the", " ", "result", "\\", "10", ";", " ", " ", " ", " ", "--", " ", "if", " ", "it", " ", "has", " ", "not", " ", "bee", "n", " ", "executed", " ", "ye", "t", " ", "send", " ", "IN", "PROGRESS", "\\", "10", ";", " ", " ", " ", " ", "-", " ", "if", " ", "this", " ", "request", " ", "has", " ", "not", " ", "bee", "n", " ", "receive", "d", " ", "bef", "ore", " ", "initiate", " ", "a", " ", "Pa", "xo", "s", " ", "round", " ", "for", " ", "the", " ", "command", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "not_", "self_", "._", "isl", "eader", "_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "self_", "._", "debug_", ":_", "self_", "._", "logger_", "._", "write_", "(_", "\"", "Error", "\"_", ",_", "\"", "Sho", "ul", "d", " ", "not", " ", "have", " ", "come", " ", "here", ":", " ", "Call", "ed", " ", "to", " ", "handle", " ", "client", " ", "command", " ", "but", " ", "not", " ", "Leader", ".\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "client", "reply_", "=_", "create", "\\u", "message_", "(_", "MS", "G", "\\u", "CLIENT", "REPLY_", ",_", "self_", "._", "me_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "{_", "FL", "D", "\\u", "REPLY_", ":_", "''_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "FL", "D", "\\u", "REPLY", "CODE_", ":_", "CR", "\\u", "REJECT", "ED_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "FL", "D", "\\u", "IN", "RESPONSE", "TO_", ":_", "give", "ncom", "mand", "_", "._", "client", "command", "number_", "}_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "self_", "._", "debug_", ":_", "self_", "._", "logger_", "._", "write_", "(_", "\"", "State", "\"_", ",_", "\"", "Reject", "ing", " ", "client", "request", ":", " ", "%", "s", "\"_", "%_", "str_", "(_", "client", "reply_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "conn_", "=_", "self_", "._", "connecti", "onp", "ool_", "._", "get", "\\u", "connecti", "on", "\\u", "by", "\\u", "peer_", "(_", "give", "ncom", "mand", "_", "._", "client_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "conn_", "is_", "not_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "conn_", "._", "send_", "(_", "client", "reply_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "self_", "._", "debug_", ":_", "self_", "._", "logger_", "._", "write_", "(_", "\"", "Error", "\"_", ",_", "\"", "Cann", "ot", " ", "create", " ", "connecti", "on", " ", "to", " ", "client", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "send", "count_", ">_", "0_", "and_", "(_", "give", "ncom", "mand", "_", "._", "client_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "give", "ncom", "mand", "_", "._", "client", "command", "number_", ")_", "in_", "self_", "._", "receive", "dcl", "ient", "requests_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "self_", "._", "debug_", ":_", "self_", "._", "logger_", "._", "write_", "(_", "\"", "State", "\"_", ",_", "\"", "Client", " ", "request", " ", "receive", "d", " ", "previ", "ously", ":\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "self_", "._", "debug_", ":_", "self_", "._", "logger_", "._", "write_", "(_", "\"", "State", "\"_", ",_", "\"", "Client", ":", " ", "%", "s", " ", "Command", "number", ":", " ", "%", "s", " ", "Replica", "s", ":", " ", "%", "s", "\"_", "\\u\\u\\uNL\\u\\u\\u_", "%_", "(_", "str_", "(_", "give", "ncom", "mand", "_", "._", "client_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "str_", "(_", "give", "ncom", "mand", "_", "._", "client", "command", "number_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "str_", "(_", "self_", "._", "replicas_", ")_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Check", " ", "if", " ", "the", " ", "request", " ", "has", " ", "bee", "n", " ", "executed", "_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "give", "ncom", "mand", "_", "in_", "self_", "._", "executed", "_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "send", " ", "REPLY_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "client", "reply_", "=_", "create", "\\u", "message_", "(_", "MS", "G", "\\u", "CLIENT", "REPLY_", ",_", "self_", "._", "me_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "{_", "FL", "D", "\\u", "REPLY_", ":_", "self_", "._", "executed", "_", "[_", "give", "ncom", "mand", "_", "]_", "[_", "EXC", "\\u", "RESULT_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "FL", "D", "\\u", "REPLY", "CODE_", ":_", "self_", "._", "executed", "_", "[_", "give", "ncom", "mand", "_", "]_", "[_", "EXC", "\\u", "RC", "ODE", "_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "FL", "D", "\\u", "IN", "RESPONSE", "TO_", ":_", "give", "ncom", "mand", "_", "._", "client", "command", "number_", "}_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "self_", "._", "debug_", ":_", "self_", "._", "logger_", "._", "write_", "(_", "\"", "State", "\"_", ",_", "\"", "Sen", "ding", " ", "Client", "repl", "y", ":", " ", "%", "s", "\"_", "%_", "str_", "(_", "client", "reply_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Check", " ", "if", " ", "the", " ", "request", " ", "is", " ", "some", "where", " ", "in", " ", "the", " ", "Pa", "xo", "s", " ", "pipeline_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "give", "ncom", "mand", "_", "in_", "self_", "._", "pend", "ing", "command", "set_", "or_", "give", "ncom", "mand", "_", "in_", "self_", "._", "proposals", "et_", "or_", "give", "ncom", "mand", "_", "in_", "self_", "._", "decision", "set_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "send", " ", "IN", "PROGRESS", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "client", "reply_", "=_", "create", "\\u", "message_", "(_", "MS", "G", "\\u", "CLIENT", "REPLY_", ",_", "self_", "._", "me_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "{_", "FL", "D", "\\u", "REPLY_", ":_", "''_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "FL", "D", "\\u", "REPLY", "CODE_", ":_", "CR", "\\u", "IN", "PROGRESS", "_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "FL", "D", "\\u", "IN", "RESPONSE", "TO_", ":_", "give", "ncom", "mand", "_", "._", "client", "command", "number_", "}_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "self_", "._", "debug_", ":_", "self_", "._", "logger_", "._", "write_", "(_", "\"", "State", "\"_", ",_", "\"", "Sen", "ding", " ", "IN", "PROGRESS", ":", " ", "%", "s", "\\\\", "n", "Replica", "s", ":", " ", "%", "s", "\"_", "\\u\\u\\uNL\\u\\u\\u_", "%_", "(_", "str_", "(_", "client", "reply_", ")_", ",_", "str_", "(_", "self_", "._", "replicas_", ")_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "conn_", "=_", "self_", "._", "connecti", "onp", "ool_", "._", "get", "\\u", "connecti", "on", "\\u", "by", "\\u", "peer_", "(_", "give", "ncom", "mand", "_", "._", "client_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "conn_", "is_", "not_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "conn_", "._", "send_", "(_", "client", "reply_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "self_", "._", "debug_", ":_", "self_", "._", "logger_", "._", "write_", "(_", "\"", "Error", "\"_", ",_", "\"", "Cann", "ot", " ", "create", " ", "connecti", "on", " ", "to", " ", "client", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "The", " ", "caller", " ", "have", "n", "'", "t", " ", "receive", "d", " ", "this", " ", "command", " ", "before_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "receive", "dcl", "ient", "requests_", "[_", "(_", "give", "ncom", "mand", "_", "._", "client_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "give", "ncom", "mand", "_", "._", "client", "command", "number_", ")_", "]_", "=_", "give", "ncom", "mand", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "self_", "._", "debug_", ":_", "self_", "._", "logger_", "._", "write_", "(_", "\"", "State", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "Initiat", "ing", " ", "command", ".", " ", "Leader", " ", "is", " ", "active", ":", " ", "%", "s", "\"_", "%_", "self_", "._", "active_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "pick", "\\u", "command", "number", "\\u", "add", "\\u", "to", "\\u", "pending_", "(_", "give", "ncom", "mand", "_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "issue", "\\u", "pend", "ing", "\\u", "commands_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Replica", "_", "(_", "Node_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "handle", "\\u", "client", "\\u", "command", "\\u", "batch_", "(_", "self_", ",_", "msg", "conn", "list_", ",_", "prepare_", "=_", "False_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "handle", " ", "receive", "d", " ", "command", "\\", "10", ";", " ", " ", " ", " ", "-", " ", "if", " ", "it", " ", "has", " ", "bee", "n", " ", "receive", "d", " ", "bef", "ore", " ", "check", " ", "if", " ", "it", " ", "has", " ", "bee", "n", " ", "executed", "\\", "10", ";", " ", " ", " ", " ", "--", " ", "if", " ", "it", " ", "has", " ", "bee", "n", " ", "executed", " ", "send", " ", "the", " ", "result", "\\", "10", ";", " ", " ", " ", " ", "--", " ", "if", " ", "it", " ", "has", " ", "not", " ", "bee", "n", " ", "executed", " ", "ye", "t", " ", "send", " ", "IN", "PROGRESS", "\\", "10", ";", " ", " ", " ", " ", "-", " ", "if", " ", "this", " ", "request", " ", "has", " ", "not", " ", "bee", "n", " ", "receive", "d", " ", "bef", "ore", " ", "initiate", " ", "a", " ", "Pa", "xo", "s", " ", "round", " ", "for", " ", "the", " ", "command", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "not_", "self_", "._", "isl", "eader", "_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "self_", "._", "debug_", ":_", "self_", "._", "logger_", "._", "write_", "(_", "\"", "Error", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "Sho", "ul", "d", " ", "not", " ", "have", " ", "come", " ", "here", ":", " ", "Not", " ", "Leader", ".\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "(_", "msg_", ",_", "conn_", ")_", "in_", "msg", "conn", "list_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "client", "reply_", "=_", "create", "\\u", "message_", "(_", "MS", "G", "\\u", "CLIENT", "REPLY_", ",_", "self_", "._", "me_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "{_", "FL", "D", "\\u", "REPLY_", ":_", "''_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "FL", "D", "\\u", "REPLY", "CODE_", ":_", "CR", "\\u", "REJECT", "ED_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "FL", "D", "\\u", "IN", "RESPONSE", "TO_", ":_", "msg_", "._", "command_", "._", "client", "command", "number_", "}_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "conn_", "._", "send_", "(_", "client", "reply_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "client", "reply_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "command", "sto", "handle_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "(_", "msg_", ",_", "conn_", ")_", "in_", "msg", "conn", "list_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "msg_", "._", "send", "count_", "==_", "0_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "The", " ", "caller", " ", "have", "n", "'", "t", " ", "receive", "d", " ", "this", " ", "command", " ", "before_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "receive", "dcl", "ient", "requests_", "[_", "(_", "msg_", "._", "command_", "._", "client_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "msg_", "._", "command_", "._", "client", "command", "number_", ")_", "]_", "=_", "msg_", "._", "command_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "command", "sto", "handle_", "._", "append_", "(_", "msg_", "._", "command_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "continue_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "(_", "msg_", "._", "command_", "._", "client_", ",_", "msg_", "._", "command_", "._", "client", "command", "number_", ")_", "in_", "self_", "._", "receive", "dcl", "ient", "requests_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "self_", "._", "debug_", ":_", "self_", "._", "logger_", "._", "write_", "(_", "\"", "State", "\"_", ",_", "\"", "Client", " ", "request", " ", "receive", "d", " ", "previ", "ously", ":\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Check", " ", "if", " ", "the", " ", "request", " ", "has", " ", "bee", "n", " ", "executed", "_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "msg_", "._", "command_", "in_", "self_", "._", "executed", "_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "send", " ", "REPLY_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "client", "reply_", "=_", "create", "\\u", "message_", "(_", "MS", "G", "\\u", "CLIENT", "REPLY_", ",_", "self_", "._", "me_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "{_", "FL", "D", "\\u", "REPLY_", ":_", "self_", "._", "executed", "_", "[_", "msg_", "._", "command_", "]_", "[_", "EXC", "\\u", "RESULT_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "FL", "D", "\\u", "REPLY", "CODE_", ":_", "self_", "._", "executed", "_", "[_", "msg_", "._", "command_", "]_", "[_", "EXC", "\\u", "RC", "ODE", "_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "FL", "D", "\\u", "IN", "RESPONSE", "TO_", ":_", "msg_", "._", "command_", "._", "client", "command", "number_", "}_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "self_", "._", "debug_", ":_", "self_", "._", "logger_", "._", "write_", "(_", "\"", "State", "\"_", ",_", "\"", "Client", "repl", "y", ":", " ", "%", "s", "\"_", "%_", "str_", "(_", "client", "reply_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Check", " ", "if", " ", "the", " ", "request", " ", "is", " ", "some", "where", " ", "in", " ", "the", " ", "Pa", "xo", "s", " ", "pipeline_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "msg_", "._", "command_", "in_", "self_", "._", "pend", "ing", "command", "set_", "or_", "msg_", "._", "command_", "in_", "self_", "._", "proposals", "et_", "or_", "msg_", "._", "command_", "in_", "self_", "._", "decision", "set_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "send", " ", "IN", "PROGRESS", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "client", "reply_", "=_", "create", "\\u", "message_", "(_", "MS", "G", "\\u", "CLIENT", "REPLY_", ",_", "self_", "._", "me_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "{_", "FL", "D", "\\u", "REPLY_", ":_", "''_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "FL", "D", "\\u", "REPLY", "CODE_", ":_", "CR", "\\u", "IN", "PROGRESS", "_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "FL", "D", "\\u", "IN", "RESPONSE", "TO_", ":_", "msg_", "._", "command_", "._", "client", "command", "number_", "}_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "self_", "._", "debug_", ":_", "self_", "._", "logger_", "._", "write_", "(_", "\"", "State", "\"_", ",_", "\"", "Client", "repl", "y", ":", " ", "%", "s", "\\\\", "n", "Replica", "s", ":", " ", "%", "s", "\"_", "\\u\\u\\uNL\\u\\u\\u_", "%_", "(_", "str_", "(_", "client", "reply_", ")_", ",_", "str_", "(_", "self_", "._", "replicas_", ")_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "client", "reply_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "conn_", "._", "send_", "(_", "client", "reply_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "self_", "._", "debug_", ":_", "self_", "._", "logger_", "._", "write_", "(_", "\"", "State", "\"_", ",_", "\"", "Initiat", "ing", " ", "a", " ", "new", " ", "command", ".", " ", "Leader", " ", "is", " ", "active", ":", " ", "%", "s", "\"_", "%_", "self_", "._", "active_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Check", " ", "if", " ", "batch", "ing", " ", "is", " ", "still", " ", "required_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "len_", "(_", "command", "sto", "handle_", ")_", "==_", "0_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "len_", "(_", "command", "sto", "handle_", ")_", "==_", "1_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "pick", "\\u", "command", "number", "\\u", "add", "\\u", "to", "\\u", "pending_", "(_", "command", "sto", "handle_", "[_", "0_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "pick", "\\u", "command", "number", "\\u", "add", "\\u", "to", "\\u", "pending_", "(_", "Propos", "al", "Server", "Batch_", "(_", "command", "sto", "handle_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "issue", "\\u", "pend", "ing", "\\u", "commands_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Replica", "_", "(_", "Node_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "send", "\\u", "reject", "\\u", "to", "\\u", "client_", "(_", "self_", ",_", "conn_", ",_", "client", "command", "number_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "conn_", "._", "send_", "(_", "create", "\\u", "message_", "(_", "MS", "G", "\\u", "CLIENT", "REPLY_", ",_", "self_", "._", "me_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "{_", "FL", "D", "\\u", "REPLY_", ":_", "''_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "FL", "D", "\\u", "REPLY", "CODE_", ":_", "CR", "\\u", "REJECT", "ED_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "FL", "D", "\\u", "IN", "RESPONSE", "TO_", ":_", "client", "command", "number_", "}_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Replica", "_", "(_", "Node_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "msg", "\\u", "client", "batch_", "(_", "self_", ",_", "conn_", ",_", "msg_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "msg", "\\u", "client", "request_", "(_", "conn_", ",_", "msg_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Replica", "_", "(_", "Node_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "msg", "\\u", "client", "request_", "(_", "self_", ",_", "conn_", ",_", "msg_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "call", "ed", " ", "holding", " ", "self", ".", "lock", "\\", "10", ";", " ", " ", " ", " ", "handle", "s", " ", "client", "request", " ", "message", " ", "receive", "d", " ", "according", " ", "to", " ", "replica", "'", "s", " ", "state", "\\", "10", ";", " ", " ", " ", " ", "-", " ", "if", " ", "not", " ", "leader", ":", " ", "reject", "\\", "10", ";", " ", " ", " ", " ", "-", " ", "if", " ", "leader", ":", " ", "add", " ", "connecti", "on", " ", "to", " ", "client", " ", "connections", " ", "and", " ", "handle", " ", "request", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "len_", "(_", "self_", "._", "replicas_", ")_", "==_", "0_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "self_", "._", "debug_", ":_", "self_", "._", "logger_", "._", "write_", "(_", "\"", "State", "\"_", ",_", "\"", "Add", "ing", " ", "SELF", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Agr", "ee", " ", "on", " ", "addin", "g", " ", "self", " ", "and", " ", "the", " ", "first", " ", "replica", ":_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "bec", "ome", "\\u", "leader_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Add", " ", "self_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "replicas_", "[_", "self_", "._", "me_", "]_", "=_", "0_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "addc", "ommand", "_", "=_", "self_", "._", "create", "\\u", "add", "\\u", "command_", "(_", "self_", "._", "me_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "pick", "\\u", "command", "number", "\\u", "add", "\\u", "to", "\\u", "pending_", "(_", "addc", "ommand", "_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "i_", "in_", "range_", "(_", "WINDOW_", "+_", "3_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "noop", "command_", "=_", "self_", "._", "create", "\\u", "noop", "\\u", "command_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "pick", "\\u", "command", "number", "\\u", "add", "\\u", "to", "\\u", "pending_", "(_", "noop", "command_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "issue", "\\u", "pend", "ing", "\\u", "commands_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "not_", "self_", "._", "state", "upto", "date_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "self_", "._", "isl", "eader", "_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "if", " ", "leader", ",", " ", "handle", " ", "the", " ", "client", "request_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "self_", "._", "token_", "and_", "msg_", "._", "token_", "!=_", "self_", "._", "token_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "self_", "._", "debug_", ":_", "self_", "._", "logger_", "._", "write_", "(_", "\"", "Error", "\"_", ",_", "\"", "Secur", "it", "y", " ", "Token", " ", "mism", "atch", ".\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "send", "\\u", "reject", "\\u", "to", "\\u", "client_", "(_", "conn_", ",_", "msg_", "._", "command_", "._", "client", "command", "number_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "self_", "._", "debug_", ":_", "self_", "._", "logger_", "._", "write_", "(_", "\"", "State", "\"_", ",_", "\"", "I", "'", "m", " ", "the", " ", "leader", ",", " ", "handling", " ", "the", " ", "request", ".\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "handle", "\\u", "client", "\\u", "command_", "(_", "msg_", "._", "command_", ",_", "msg_", "._", "send", "count_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "prepare_", "=_", "self_", "._", "leader", "\\u", "initiali", "zin", "g_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "leader", "alive_", ",_", "leader_", "=_", "self_", "._", "leader", "\\u", "is", "\\u", "alive_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "leader", "alive_", "and_", "leader_", "!=_", "self_", "._", "me_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "self_", "._", "debug_", ":_", "self_", "._", "logger_", "._", "write_", "(_", "\"", "State", "\"_", ",_", "\"", "Not", " ", "Leader", ":", " ", "Reject", "ing", " ", "CLIENT", "REQUEST", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "send", "\\u", "reject", "\\u", "to", "\\u", "client_", "(_", "conn_", ",_", "msg_", "._", "command_", "._", "client", "command", "number_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "leader_", "==_", "self_", "._", "me_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "check", " ", "if", " ", "shou", "ld", " ", "bec", "ome", " ", "leader_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "bec", "ome", "\\u", "leader_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "self_", "._", "token_", "and_", "msg_", "._", "token_", "!=_", "self_", "._", "token_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "if_", "self_", "._", "debug_", ":_", "self_", "._", "logger_", "._", "write_", "(_", "\"", "Error", "\"_", ",_", "\"", "Secur", "it", "y", " ", "Token", " ", "mism", "atch", ".\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "send", "\\u", "reject", "\\u", "to", "\\u", "client_", "(_", "conn_", ",_", "msg_", "._", "command_", "._", "client", "command", "number_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "self_", "._", "handle", "\\u", "client", "\\u", "command_", "(_", "msg_", "._", "command_", ",_", "msg_", "._", "send", "count_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "prepare_", "=_", "self_", "._", "leader", "\\u", "initiali", "zin", "g_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "not_", "leader", "alive_", "and_", "self_", "._", "find", "\\u", "leader_", "(_", ")_", "==_", "self_", "._", "me_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "check", " ", "if", " ", "shou", "ld", " ", "bec", "ome", " ", "leader_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "bec", "ome", "\\u", "leader_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "leader_", "not_", "in_", "self_", "._", "nodes", "bei", "ng", "deleted_", "and_", "leader_", "in_", "self_", "._", "replicas_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "if", " ", "leader", " ", "is", " ", "not", " ", "alr", "ead", "y", " ", "(", "bei", "ng", ")", " ", "deleted_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "take", " ", "old", " ", "leader", " ", "out", " ", "of", " ", "the", " ", "configuration_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "if_", "self_", "._", "debug_", ":_", "self_", "._", "logger_", "._", "write_", "(_", "\"", "State", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "Tak", "ing", " ", "old", " ", "leader", " ", "out", " ", "of", " ", "the", " ", "configura", "tion", ".\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "nodes", "bei", "ng", "deleted_", "._", "add_", "(_", "leader_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "del", "command_", "=_", "self_", "._", "create", "\\u", "delete", "\\u", "command_", "(_", "leader_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "pick", "\\u", "command", "number", "\\u", "add", "\\u", "to", "\\u", "pending_", "(_", "del", "command_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "i_", "in_", "range_", "(_", "WINDOW_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "noop", "command_", "=_", "self_", "._", "create", "\\u", "noop", "\\u", "command_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "pick", "\\u", "command", "number", "\\u", "add", "\\u", "to", "\\u", "pending_", "(_", "noop", "command_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "issue", "\\u", "pend", "ing", "\\u", "commands_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Check", " ", "token", " ", "and", " ", "answer", " ", "to", " ", "client_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "self_", "._", "token_", "and_", "msg_", "._", "token_", "!=_", "self_", "._", "token_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "if_", "self_", "._", "debug_", ":_", "self_", "._", "logger_", "._", "write_", "(_", "\"", "Error", "\"_", ",_", "\"", "Secur", "it", "y", " ", "Token", " ", "mism", "atch", ".\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "send", "\\u", "reject", "\\u", "to", "\\u", "client_", "(_", "conn_", ",_", "msg_", "._", "command_", "._", "client", "command", "number_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "self_", "._", "handle", "\\u", "client", "\\u", "command_", "(_", "msg_", "._", "command_", ",_", "msg_", "._", "send", "count_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "prepare_", "=_", "self_", "._", "leader", "\\u", "initiali", "zin", "g_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Replica", "_", "(_", "Node_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "msg", "\\u", "client", "request", "\\u", "batch_", "(_", "self_", ",_", "msg", "conn", "list_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "call", "ed", " ", "holding", " ", "self", ".", "lock", "\\", "10", ";", " ", " ", " ", " ", "handle", "s", " ", "client", "request", " ", "message", "s", " ", "tha", "t", " ", "are", " ", "batched", " ", "tog", "ether", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "len_", "(_", "self_", "._", "replicas_", ")_", "==_", "0_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "self_", "._", "debug_", ":_", "self_", "._", "logger_", "._", "write_", "(_", "\"", "State", "\"_", ",_", "\"", "Add", "ing", " ", "SELF", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Agr", "ee", " ", "on", " ", "addin", "g", " ", "self", " ", "and", " ", "the", " ", "first", " ", "replica", ":_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "bec", "ome", "\\u", "leader_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Add", " ", "self_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "replicas_", "[_", "self_", "._", "me_", "]_", "=_", "0_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "addc", "ommand", "_", "=_", "self_", "._", "create", "\\u", "add", "\\u", "command_", "(_", "self_", "._", "me_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "pick", "\\u", "command", "number", "\\u", "add", "\\u", "to", "\\u", "pending_", "(_", "addc", "ommand", "_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "i_", "in_", "range_", "(_", "WINDOW_", "+_", "3_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "noop", "command_", "=_", "self_", "._", "create", "\\u", "noop", "\\u", "command_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "pick", "\\u", "command", "number", "\\u", "add", "\\u", "to", "\\u", "pending_", "(_", "noop", "command_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "issue", "\\u", "pend", "ing", "\\u", "commands_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "not_", "self_", "._", "state", "upto", "date_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "self_", "._", "isl", "eader", "_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "if", " ", "leader", ",", " ", "handle", " ", "the", " ", "client", "request_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "for_", "(_", "msg_", ",_", "conn_", ")_", "in_", "msg", "conn", "list_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "self_", "._", "token_", "and_", "msg_", "._", "token_", "!=_", "self_", "._", "token_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "if_", "self_", "._", "debug_", ":_", "self_", "._", "logger_", "._", "write_", "(_", "\"", "Error", "\"_", ",_", "\"", "Secur", "it", "y", " ", "Token", " ", "mism", "atch", ".\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "send", "\\u", "reject", "\\u", "to", "\\u", "client_", "(_", "conn_", ",_", "msg_", "._", "command_", "._", "client", "command", "number_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "msg", "conn", "list_", "._", "remove_", "(_", "(_", "msg_", ",_", "conn_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "handle", "\\u", "client", "\\u", "command", "\\u", "batch_", "(_", "msg", "conn", "list_", ",_", "prepare_", "=_", "self_", "._", "leader", "\\u", "initiali", "zin", "g_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "leader", "alive_", ",_", "leader_", "=_", "self_", "._", "leader", "\\u", "is", "\\u", "alive_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "leader", "alive_", "and_", "leader_", "!=_", "self_", "._", "me_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "self_", "._", "debug_", ":_", "self_", "._", "logger_", "._", "write_", "(_", "\"", "State", "\"_", ",_", "\"", "Not", " ", "Leader", ":", " ", "Reject", "ing", " ", "all", " ", "CLIENT", "REQUEST", "S", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "(_", "msg_", ",_", "conn_", ")_", "in_", "msg", "conn", "list_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "self_", "._", "send", "\\u", "reject", "\\u", "to", "\\u", "client_", "(_", "conn_", ",_", "msg_", "._", "command_", "._", "client", "command", "number_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "leader_", "==_", "self_", "._", "me_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "check", " ", "if", " ", "shou", "ld", " ", "bec", "ome", " ", "leader_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "bec", "ome", "\\u", "leader_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "(_", "msg_", ",_", "conn_", ")_", "in_", "msg", "conn", "list_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "if_", "self_", "._", "token_", "and_", "msg_", "._", "token_", "!=_", "self_", "._", "token_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "if_", "self_", "._", "debug_", ":_", "self_", "._", "logger_", "._", "write_", "(_", "\"", "Error", "\"_", ",_", "\"", "Secur", "it", "y", " ", "Token", " ", "mism", "atch", ".\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "send", "\\u", "reject", "\\u", "to", "\\u", "client_", "(_", "conn_", ",_", "msg_", "._", "command_", "._", "client", "command", "number_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "msg", "conn", "list_", "._", "remove_", "(_", "(_", "msg_", ",_", "conn_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "handle", "\\u", "client", "\\u", "command", "\\u", "batch_", "(_", "msg", "conn", "list_", ",_", "prepare_", "=_", "self_", "._", "leader", "\\u", "initiali", "zin", "g_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "not_", "leader", "alive_", "and_", "self_", "._", "find", "\\u", "leader_", "(_", ")_", "==_", "self_", "._", "me_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "bec", "ome", "\\u", "leader_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "leader_", "not_", "in_", "self_", "._", "nodes", "bei", "ng", "deleted_", "and_", "leader_", "in_", "self_", "._", "replicas_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "if", " ", "leader", " ", "is", " ", "not", " ", "alr", "ead", "y", " ", "(", "bei", "ng", ")", " ", "deleted_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "take", " ", "old", " ", "leader", " ", "out", " ", "of", " ", "the", " ", "configuration_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "if_", "self_", "._", "debug_", ":_", "self_", "._", "logger_", "._", "write_", "(_", "\"", "State", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "Tak", "ing", " ", "old", " ", "leader", " ", "out", " ", "of", " ", "the", " ", "configura", "tion", ".\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "nodes", "bei", "ng", "deleted_", "._", "add_", "(_", "leader_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "del", "command_", "=_", "self_", "._", "create", "\\u", "delete", "\\u", "command_", "(_", "leader_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "pick", "\\u", "command", "number", "\\u", "add", "\\u", "to", "\\u", "pending_", "(_", "del", "command_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "i_", "in_", "range_", "(_", "WINDOW_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "noop", "command_", "=_", "self_", "._", "create", "\\u", "noop", "\\u", "command_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "pick", "\\u", "command", "number", "\\u", "add", "\\u", "to", "\\u", "pending_", "(_", "noop", "command_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Check", " ", "token", " ", "and", " ", "answer", " ", "to", " ", "client_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "for_", "(_", "msg_", ",_", "conn_", ")_", "in_", "msg", "conn", "list_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "if_", "self_", "._", "token_", "and_", "msg_", "._", "token_", "!=_", "self_", "._", "token_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "if_", "self_", "._", "debug_", ":_", "self_", "._", "logger_", "._", "write_", "(_", "\"", "Error", "\"_", ",_", "\"", "Secur", "it", "y", " ", "Token", " ", "mism", "atch", ".\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "send", "\\u", "reject", "\\u", "to", "\\u", "client_", "(_", "conn_", ",_", "msg_", "._", "command_", "._", "client", "command", "number_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "msg", "conn", "list_", "._", "remove_", "(_", "(_", "msg_", ",_", "conn_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "handle", "\\u", "client", "\\u", "command", "\\u", "batch_", "(_", "msg", "conn", "list_", ",_", "prepare_", "=_", "self_", "._", "leader", "\\u", "initiali", "zin", "g_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Replica", "_", "(_", "Node_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "msg", "\\u", "client", "reply_", "(_", "self_", ",_", "conn_", ",_", "msg_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "this", " ", "only", " ", "occur", "s", " ", "in", " ", "response", " ", "to", " ", "command", "s", " ", "initiate", "d", " ", "by", " ", "the", " ", "shell", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Replica", "_", "(_", "Node_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "do", "\\u", "command", "\\u", "propos", "e\\u", "from", "\\u", "pending_", "(_", "self_", ",_", "give", "ncom", "mand", "number_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "Initiat", "es", " ", "give", "ncom", "mand", "number", " ", "from", " ", "pend", "ing", "command", "s", " ", "list", ".", "\\", "10", ";", " ", " ", " ", " ", "Stage", " ", "p2", "a", ".", "\\", "10", ";", " ", " ", " ", " ", "-", " ", "Remove", " ", "command", " ", "from", " ", "pend", "ing", " ", "and", " ", "transfer", " ", "it", " ", "to", " ", "proposals", "\\", "10", ";", " ", " ", " ", " ", "-", " ", "If", " ", "no", " ", "Replica", "s", ",", " ", "retr", "eat", " ", "and", " ", "return", "\\", "10", ";", " ", " ", " ", " ", "-", " ", "Else", " ", "start", " ", "from", " ", "the", " ", "PROP", "OSE", " ", "STAGE", ":", "\\", "10", ";", " ", " ", " ", " ", "--", " ", "create", " ", "MS", "G", "\\u", "PROP", "OSE", ":", " ", "message", " ", "carri", "es", " ", "ballot", "number", ",", " ", "command", "number", ",", " ", "propos", "al", "\\", "10", ";", " ", " ", " ", " ", "--", " ", "create", " ", "Respons", "e", "Collect", "or", " ", "object", " ", "for", " ", "PROP", "OSE", " ", "STAGE", ":", "\\", "10", ";", " ", " ", " ", " ", "Respons", "e", "Collect", "or", " ", "keep", "s", " ", "the", " ", "state", " ", "relate", "d", " ", "to", " ", "MS", "G", "\\u", "PROP", "OSE", "\\", "10", ";", " ", " ", " ", " ", "--", " ", "add", " ", "the", " ", "Respons", "e", "Collect", "or", " ", "to", " ", "the", " ", "outstanding", " ", "propos", "e", " ", "set", "\\", "10", ";", " ", " ", " ", " ", "--", " ", "send", " ", "MS", "G", "\\u", "PROP", "OSE", " ", "to", " ", "Replica", " ", "nodes", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "give", "npr", "opo", "sal", "_", "=_", "self_", "._", "pend", "ing", "commands_", "[_", "give", "ncom", "mand", "number_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "remove", "\\u", "from", "\\u", "pend", "ing", "commands_", "(_", "give", "ncom", "mand", "number_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "add", "\\u", "to", "\\u", "proposals", "_", "(_", "give", "ncom", "mand", "number_", ",_", "give", "npr", "opo", "sal", "_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "recent", "ballot", "number_", "=_", "self_", "._", "ballot", "number_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "self_", "._", "debug_", ":_", "self_", "._", "logger_", "._", "write_", "(_", "\"", "State", "\"_", ",_", "\"", "Propos", "ing", " ", "command", ":", " ", "%", "d", ":", "%", "s", " ", "with", " ", "ballot", "number", " ", "%", "s", "\"_", "\\u\\u\\uNL\\u\\u\\u_", "%_", "(_", "give", "ncom", "mand", "number_", ",_", "give", "npr", "opo", "sal", "_", ",_", "str_", "(_", "recent", "ballot", "number_", ")_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Sin", "ce", " ", "we", " ", "neve", "r", " ", "propos", "e", " ", "a", " ", "command", "number", " ", "tha", "t", " ", "is", " ", "be", "yon", "d", " ", "the", " ", "window", ",_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "we", " ", "can", " ", "simp", "ly", " ", "use", " ", "the", " ", "current", " ", "replica", " ", "set", " ", "here_", "\\u\\u\\uNL\\u\\u\\u_", "prc", "_", "=_", "Respons", "e", "Collector_", "(_", "self_", "._", "replicas_", ",_", "recent", "ballot", "number_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "give", "ncom", "mand", "number_", ",_", "give", "npr", "opo", "sal", "_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "len_", "(_", "prc", "_", "._", "quorum", "_", ")_", "==_", "0_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "self_", "._", "debug_", ":_", "self_", "._", "logger_", "._", "write_", "(_", "\"", "Error", "\"_", ",_", "\"", "There", " ", "are", " ", "no", " ", "Replica", "s", ",", " ", "return", "ing", "!\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "remove", "\\u", "from", "\\u", "proposals", "_", "(_", "give", "ncom", "mand", "number_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "pick", "\\u", "command", "number", "\\u", "add", "\\u", "to", "\\u", "pending_", "(_", "give", "npr", "opo", "sal", "_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "outstanding", "propos", "es_", "[_", "give", "ncom", "mand", "number_", "]_", "=_", "prc", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "propos", "e_", "=_", "create", "\\u", "message_", "(_", "MS", "G", "\\u", "PROP", "OSE", "_", ",_", "self_", "._", "me_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "{_", "FL", "D", "\\u", "BAL", "LOT", "NUMBER_", ":_", "recent", "ballot", "number_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "FL", "D", "\\u", "COMMA", "ND", "NUMBER_", ":_", "give", "ncom", "mand", "number_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "FL", "D", "\\u", "PROP", "OS", "AL_", ":_", "give", "npr", "opo", "sal", "_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "FL", "D", "\\u", "SERVER", "BATCH", "_", ":_", "isinstance_", "(_", "give", "npr", "opo", "sal", "_", ",_", "Propos", "al", "Server", "Batch_", ")_", "}_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "send_", "(_", "propos", "e_", ",_", "group_", "=_", "prc", "_", "._", "quorum", "_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Replica", "_", "(_", "Node_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "do", "\\u", "command", "\\u", "prepar", "e\\u", "from", "\\u", "pending_", "(_", "self_", ",_", "give", "ncom", "mand", "number_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "Initiat", "es", " ", "give", "ncom", "mand", "number", " ", "from", " ", "pend", "ing", "command", "s", " ", "list", ".", "\\", "10", ";", " ", " ", " ", " ", "Stage", " ", "p1", "a", ".", "\\", "10", ";", " ", " ", " ", " ", "-", " ", "Remove", " ", "command", " ", "from", " ", "pend", "ing", " ", "and", " ", "transfer", " ", "it", " ", "to", " ", "proposals", "\\", "10", ";", " ", " ", " ", " ", "-", " ", "If", " ", "no", " ", "Replica", "s", ",", " ", "retr", "eat", " ", "and", " ", "return", "\\", "10", ";", " ", " ", " ", " ", "-", " ", "Else", " ", "start", " ", "from", " ", "the", " ", "PREP", "ARE", " ", "STAGE", ":", "\\", "10", ";", " ", " ", " ", " ", "--", " ", "create", " ", "MS", "G", "\\u", "PREP", "ARE", ":", " ", "message", " ", "carri", "es", " ", "the", " ", "correspond", "ing", " ", "ballot", "number", "\\", "10", ";", " ", " ", " ", " ", "--", " ", "create", " ", "Respons", "e", "Collect", "or", " ", "object", " ", "for", " ", "PREP", "ARE", " ", "STAGE", ":", "\\", "10", ";", " ", " ", " ", " ", "Respons", "e", "Collect", "or", " ", "keep", "s", " ", "the", " ", "state", " ", "relate", "d", " ", "to", " ", "MS", "G", "\\u", "PREP", "ARE", "\\", "10", ";", " ", " ", " ", " ", "--", " ", "add", " ", "the", " ", "Respons", "e", "Collect", "or", " ", "to", " ", "the", " ", "outstanding", " ", "prepar", "e", " ", "set", "\\", "10", ";", " ", " ", " ", " ", "--", " ", "send", " ", "MS", "G", "\\u", "PREP", "ARE", " ", "to", " ", "Replica", " ", "nodes", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "give", "npr", "opo", "sal", "_", "=_", "self_", "._", "pend", "ing", "commands_", "[_", "give", "ncom", "mand", "number_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "remove", "\\u", "from", "\\u", "pend", "ing", "commands_", "(_", "give", "ncom", "mand", "number_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "add", "\\u", "to", "\\u", "proposals", "_", "(_", "give", "ncom", "mand", "number_", ",_", "give", "npr", "opo", "sal", "_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "newb", "allo", "tn", "umber_", "=_", "self_", "._", "ballot", "number_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "self_", "._", "debug_", ":_", "self_", "._", "logger_", "._", "write_", "(_", "\"", "State", "\"_", ",_", "\"", "Prepar", "ing", " ", "command", ":", " ", "%", "d", ":", "%", "s", " ", "with", " ", "ballot", "number", " ", "%", "s", "\"_", "\\u\\u\\uNL\\u\\u\\u_", "%_", "(_", "give", "ncom", "mand", "number_", ",_", "give", "npr", "opo", "sal", "_", ",_", "str_", "(_", "newb", "allo", "tn", "umber_", ")_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "prc", "_", "=_", "Respons", "e", "Collector_", "(_", "self_", "._", "replicas_", ",_", "newb", "allo", "tn", "umber_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "give", "ncom", "mand", "number_", ",_", "give", "npr", "opo", "sal", "_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "len_", "(_", "prc", "_", "._", "quorum", "_", ")_", "==_", "0_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "self_", "._", "debug_", ":_", "self_", "._", "logger_", "._", "write_", "(_", "\"", "Error", "\"_", ",_", "\"", "There", " ", "are", " ", "no", " ", "Replica", "s", ",", " ", "return", "ing", "!\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "remove", "\\u", "from", "\\u", "proposals", "_", "(_", "give", "ncom", "mand", "number_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "pick", "\\u", "command", "number", "\\u", "add", "\\u", "to", "\\u", "pending_", "(_", "give", "npr", "opo", "sal", "_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "outstanding", "prepar", "es_", "[_", "newb", "allo", "tn", "umber_", "]_", "=_", "prc", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "prepare_", "=_", "create", "\\u", "message_", "(_", "MS", "G", "\\u", "PREP", "ARE", "_", ",_", "self_", "._", "me_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "{_", "FL", "D", "\\u", "BAL", "LOT", "NUMBER_", ":_", "newb", "allo", "tn", "umber_", "}_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "send_", "(_", "prepare_", ",_", "group_", "=_", "prc", "_", "._", "quorum", "_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Replica", "_", "(_", "Node_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "msg", "\\u", "prepare_", "(_", "self_", ",_", "conn_", ",_", "msg_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "MS", "G", "\\u", "PREP", "ARE", " ", "is", " ", "accept", "ed", " ", "only", " ", "if", " ", "it", " ", "carri", "es", " ", "a", " ", "ballot", "number", " ", "great", "er", "\\", "10", ";", " ", " ", " ", " ", "than", " ", "the", " ", "high", "est", " ", "ballot", "number", " ", "Replica", " ", "has", " ", "ever", " ", "receive", "d", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "Repl", "ies", ":", "\\", "10", ";", " ", " ", " ", " ", "-", " ", "MS", "G", "\\u", "PREP", "ARE", "\\u", "ADO", "PTE", "D", " ", "carri", "es", " ", "the", " ", "ballot", "number", " ", "tha", "t", " ", "is", " ", "receive", "d", " ", "and", "\\", "10", ";", " ", " ", " ", " ", "all", " ", "pvalue", "s", " ", "accept", "ed", " ", "thu", "s", " ", "far", ".", "\\", "10", ";", " ", " ", " ", " ", "-", " ", "MS", "G", "\\u", "PREP", "ARE", "\\u", "PRE", "EMP", "TED", " ", "carri", "es", " ", "the", " ", "high", "est", " ", "ballot", "number", " ", "Replica", "\\", "10", ";", " ", " ", " ", " ", "has", " ", "see", "n", " ", "and", " ", "all", " ", "pvalue", "s", " ", "accept", "ed", " ", "thu", "s", " ", "far", ".", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "this", " ", "ballot", " ", "shou", "ld", " ", "be", " ", "strict", "ly", " ", "higher", " ", "than", " ", "previ", "ously", " ", "accept", "ed", " ", "ballot", "s_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "msg_", "._", "ballot", "number_", ">=_", "self_", "._", "quorum", "ballot", "number_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "self_", "._", "debug_", ":_", "self_", "._", "logger_", "._", "write_", "(_", "\"", "Pa", "xo", "s", " ", "State", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "prepar", "e", " ", "receive", "d", " ", "with", " ", "acceptabl", "e", " ", "ballot", "number", " ", "%", "s", "\"_", "\\u\\u\\uNL\\u\\u\\u_", "%_", "str_", "(_", "msg_", "._", "ballot", "number_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "quorum", "ballot", "number_", "=_", "msg_", "._", "ballot", "number_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "last", "\\u", "accept", "\\u", "msg", "\\u", "id_", "=_", "msg_", "._", "id_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "repl", "ym", "sg_", "=_", "create", "\\u", "message_", "(_", "MS", "G", "\\u", "PREP", "ARE", "\\u", "ADO", "PTE", "D_", ",_", "self_", "._", "me_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "{_", "FL", "D", "\\u", "BAL", "LOT", "NUMBER_", ":_", "self_", "._", "quorum", "ballot", "number_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "FL", "D", "\\u", "IN", "RESPONSE", "TO_", ":_", "msg_", "._", "ballot", "number_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "FL", "D", "\\u", "PV", "AL", "UE", "SET_", ":_", "self_", "._", "quorum", "accepted_", "._", "pvalue", "s_", "}_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "st_", "=_", "'", "ADO", "PTE", "D", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "or", " ", "else", " ", "it", " ", "shou", "ld", " ", "be", " ", "a", " ", "precise", " ", "duplicat", "e", " ", "of", " ", "the", " ", "last", " ", "request_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "in", " ", "this", " ", "case", " ", "we", " ", "do", " ", "nothing_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "msg_", "._", "ballot", "number_", "==_", "self_", "._", "quorum", "ballot", "number_", "and_", "msg_", "._", "id_", "==_", "self_", "._", "last", "\\u", "accept", "\\u", "msg", "\\u", "id_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "self_", "._", "debug_", ":_", "self_", "._", "logger_", "._", "write_", "(_", "\"", "Pa", "xo", "s", " ", "State", "\"_", ",_", "\"", "message", " ", "receive", "d", " ", "bef", "ore", ":", " ", "%", "s", "\"_", "%_", "msg_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "self_", "._", "debug_", ":_", "self_", "._", "logger_", "._", "write_", "(_", "\"", "Pa", "xo", "s", " ", "State", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "\"", "prepar", "e", " ", "receive", "d", " ", "with", " ", "non", "-", "acceptabl", "e", " ", "\"_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "ballot", "number", " ", "%", "s", " ", "\"_", ")_", "%_", "(_", "str_", "(_", "msg_", "._", "ballot", "number_", ")_", ",_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "last", "\\u", "accept", "\\u", "msg", "\\u", "id_", "=_", "msg_", "._", "id_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "repl", "ym", "sg_", "=_", "create", "\\u", "message_", "(_", "MS", "G", "\\u", "PREP", "ARE", "\\u", "PRE", "EMP", "TED_", ",_", "self_", "._", "me_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "{_", "FL", "D", "\\u", "BAL", "LOT", "NUMBER_", ":_", "self_", "._", "quorum", "ballot", "number_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "FL", "D", "\\u", "IN", "RESPONSE", "TO_", ":_", "msg_", "._", "ballot", "number_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "FL", "D", "\\u", "PV", "AL", "UE", "SET_", ":_", "self_", "._", "quorum", "accepted_", "._", "pvalue", "s_", "}_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "st_", "=_", "'", "PRE", "EMP", "TED", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "self_", "._", "debug_", ":_", "self_", "._", "logger_", "._", "write_", "(_", "\"", "Pa", "xo", "s", " ", "State", "\"_", ",_", "\"", "Prepare", " ", "respond", "ing", " ", "%", "s", " ", "with", " ", "%", "s", " ", "to", " ", "%", "s", "\"_", "\\u\\u\\uNL\\u\\u\\u_", "%_", "(_", "st_", ",_", "str_", "(_", "self_", "._", "quorum", "ballot", "number_", ")_", ",_", "str_", "(_", "msg_", "._", "ballot", "number_", ")_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "conn_", "._", "send_", "(_", "repl", "ym", "sg_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Replica", "_", "(_", "Node_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "msg", "\\u", "propos", "e_", "(_", "self_", ",_", "conn_", ",_", "msg_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "MS", "G", "\\u", "PROP", "OSE", " ", "is", " ", "accept", "ed", " ", "only", " ", "if", " ", "it", " ", "carri", "es", " ", "a", " ", "ballot", "number", " ", "great", "er", "\\", "10", ";", " ", " ", " ", " ", "than", " ", "the", " ", "high", "est", " ", "ballot", "number", " ", "Replica", " ", "has", " ", "receive", "d", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "Repl", "ies", ":", "\\", "10", ";", " ", " ", " ", " ", "-", " ", "MS", "G", "\\u", "PROP", "OSE", "\\u", "ACCEPT", " ", "carri", "es", " ", "ballot", "number", " ", "and", " ", "command", "number", " ", "receive", "d", ".", "\\", "10", ";", " ", " ", " ", " ", "-", " ", "MS", "G", "\\u", "PROP", "OSE", "\\u", "REJECT", " ", "carri", "es", " ", "the", " ", "high", "est", " ", "ballot", "number", " ", "Replica", " ", "has", "\\", "10", ";", " ", " ", " ", " ", "see", "n", " ", "and", " ", "the", " ", "command", "number", " ", "tha", "t", " ", "is", " ", "receive", "d", ".", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "msg_", "._", "ballot", "number_", ">=_", "self_", "._", "quorum", "ballot", "number_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "self_", "._", "debug_", ":_", "self_", "._", "logger_", "._", "write_", "(_", "\"", "Pa", "xo", "s", " ", "State", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "propos", "e", " ", "receive", "d", " ", "with", " ", "acceptabl", "e", " ", "ballot", "number", " ", "%", "s", "\"_", "\\u\\u\\uNL\\u\\u\\u_", "%_", "str_", "(_", "msg_", "._", "ballot", "number_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "quorum", "ballot", "number_", "=_", "msg_", "._", "ballot", "number_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "newp", "value_", "=_", "PV", "alue_", "(_", "msg_", "._", "ballot", "number_", ",_", "msg_", "._", "command", "number_", ",_", "msg_", "._", "proposal_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "quorum", "accepted_", "._", "add_", "(_", "newp", "value_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "repl", "ym", "sg_", "=_", "create", "\\u", "message_", "(_", "MS", "G", "\\u", "PROP", "OSE", "\\u", "ACCEPT", "_", ",_", "self_", "._", "me_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "{_", "FL", "D", "\\u", "BAL", "LOT", "NUMBER_", ":_", "self_", "._", "quorum", "ballot", "number_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "FL", "D", "\\u", "IN", "RESPONSE", "TO_", ":_", "msg_", "._", "ballot", "number_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "FL", "D", "\\u", "COMMA", "ND", "NUMBER_", ":_", "msg_", "._", "command", "number_", "}_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "conn_", "._", "send_", "(_", "repl", "ym", "sg_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "self_", "._", "durab", "le_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "file_", "._", "write_", "(_", "str_", "(_", "newp", "value_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "os_", "._", "fs", "ync_", "(_", "self_", "._", "file_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "self_", "._", "debug_", ":_", "self_", "._", "logger_", "._", "write_", "(_", "\"", "Pa", "xo", "s", " ", "State", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "propos", "e", " ", "receive", "d", " ", "with", " ", "non", "-", "acceptabl", "e", " ", "ballot", "number", " ", "%", "s", "\"_", "\\u\\u\\uNL\\u\\u\\u_", "%_", "str_", "(_", "msg_", "._", "ballot", "number_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "repl", "ym", "sg_", "=_", "create", "\\u", "message_", "(_", "MS", "G", "\\u", "PROP", "OSE", "\\u", "REJECT", "_", ",_", "self_", "._", "me_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "{_", "FL", "D", "\\u", "BAL", "LOT", "NUMBER_", ":_", "self_", "._", "quorum", "ballot", "number_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "FL", "D", "\\u", "IN", "RESPONSE", "TO_", ":_", "msg_", "._", "ballot", "number_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "FL", "D", "\\u", "COMMA", "ND", "NUMBER_", ":_", "msg_", "._", "command", "number_", "}_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "conn_", "._", "send_", "(_", "repl", "ym", "sg_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Replica", "_", "(_", "Node_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "msg", "\\u", "gar", "bage", "collect_", "(_", "self_", ",_", "conn_", ",_", "msg_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "self_", "._", "debug_", ":_", "self_", "._", "logger_", "._", "write_", "(_", "\"", "Pa", "xo", "s", " ", "State", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "Do", "ing", " ", "gar", "bage", " ", "collection", " ", "upto", " ", "%", "d", "\"_", "%_", "msg_", "._", "command", "number_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "success_", "=_", "self_", "._", "quorum", "accepted_", "._", "truncat", "eto", "_", "(_", "msg_", "._", "command", "number_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "success_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "object", "snapshot_", "=_", "(_", "msg_", "._", "command", "number_", ",_", "pickle_", "._", "loads_", "(_", "msg_", "._", "snapshot_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "self_", "._", "debug_", ":_", "self_", "._", "logger_", "._", "write_", "(_", "\"", "Gar", "bage", " ", "Collecti", "on", " ", "Error", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "Gar", "beg", "e", " ", "Collecti", "on", " ", "fail", "ed", ".\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Replica", "_", "(_", "Node_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "msg", "\\u", "prepar", "e\\u", "adopt", "ed_", "(_", "self_", ",_", "conn_", ",_", "msg_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "MS", "G", "\\u", "PREP", "ARE", "\\u", "ADO", "PTE", "D", " ", "is", " ", "handle", "d", " ", "only", " ", "if", " ", "it", " ", "belo", "ngs", " ", "to", " ", "an", " ", "outstanding", " ", "MS", "G", "\\u", "PREP", "ARE", ",", "\\", "10", ";", " ", " ", " ", " ", "other", "wis", "e", " ", "it", " ", "is", " ", "discard", "ed", ".", "\\", "10", ";", " ", " ", " ", " ", "Whe", "n", " ", "MS", "G", "\\u", "PREP", "ARE", "\\u", "ADO", "PTE", "D", " ", "is", " ", "receive", "d", ",", " ", "the", " ", "correspond", "ing", " ", "Respons", "e", "Collect", "or", " ", "is", " ", "retrieved", "\\", "10", ";", " ", " ", " ", " ", "and", " ", "its", " ", "state", " ", "is", " ", "update", "d", " ", "according", "ly", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "State", " ", "Update", "s", ":", "\\", "10", ";", " ", " ", " ", " ", "-", " ", "message", " ", "is", " ", "adde", "d", " ", "to", " ", "the", " ", "receive", "d", " ", "dictionar", "y", "\\", "10", ";", " ", " ", " ", " ", "-", " ", "the", " ", "pvalue", " ", "with", " ", "the", " ", "Respons", "e", "Collect", "or", "'", "s", " ", "command", "number", " ", "is", " ", "adde", "d", " ", "to", " ", "the", " ", "possib", "lep", "values", "et", "\\", "10", ";", " ", " ", " ", " ", "-", " ", "if", " ", "nacc", "ept", "s", " ", "is", " ", "great", "er", " ", "than", " ", "the", " ", "quorum", " ", "size", " ", "PREP", "ARE", " ", "STAGE", " ", "is", " ", "success", "ful", ".", "\\", "10", ";", " ", " ", " ", " ", "--", " ", "Start", " ", "the", " ", "PROP", "OSE", " ", "STAGE", ":", "\\", "10", ";", " ", " ", " ", " ", "---", " ", "create", " ", "the", " ", "pvalue", "set", " ", "with", " ", "high", "est", " ", "ballot", "numbers", " ", "for", " ", "distinct", "ive", " ", "command", "numbers", "\\", "10", ";", " ", " ", " ", " ", "---", " ", "update", " ", "own", " ", "proposals", " ", "dictionar", "y", " ", "according", " ", "to", " ", "pma", "x", " ", "dictionar", "y", "\\", "10", ";", " ", " ", " ", " ", "---", " ", "remove", " ", "the", " ", "old", " ", "Respons", "e", "Collect", "or", " ", "from", " ", "the", " ", "outstanding", " ", "prepar", "e", " ", "set", "\\", "10", ";", " ", " ", " ", " ", "---", " ", "run", " ", "the", " ", "PROP", "OSE", " ", "STAGE", " ", "for", " ", "each", " ", "pvalue", " ", "in", " ", "proposals", " ", "dictionar", "y", "\\", "10", ";", " ", " ", " ", " ", "----", " ", "create", " ", "Respons", "e", "Collect", "or", " ", "object", " ", "for", " ", "PROP", "OSE", " ", "STAGE", ":", " ", "Respons", "e", "Collect", "or", " ", "keep", "s", "\\", "10", ";", " ", " ", " ", " ", "the", " ", "state", " ", "relate", "d", " ", "to", " ", "MS", "G", "\\u", "PROP", "OSE", "\\", "10", ";", " ", " ", " ", " ", "----", " ", "add", " ", "the", " ", "new", " ", "Respons", "e", "Collect", "or", " ", "to", " ", "the", " ", "outstanding", " ", "propos", "e", " ", "set", "\\", "10", ";", " ", " ", " ", " ", "----", " ", "create", " ", "MS", "G", "\\u", "PROP", "OSE", ":", " ", "message", " ", "carri", "es", " ", "the", " ", "correspond", "ing", " ", "ballot", "number", ",", " ", "command", "number", " ", "and", " ", "the", " ", "propos", "al", "\\", "10", ";", " ", " ", " ", " ", "----", " ", "send", " ", "MS", "G", "\\u", "PROP", "OSE", " ", "to", " ", "the", " ", "same", " ", "Replica", " ", "nodes", " ", "from", " ", "the", " ", "PREP", "ARE", " ", "STAGE", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "msg_", "._", "inr", "esp", "onset", "o_", "in_", "self_", "._", "outstanding", "prepar", "es_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "prc", "_", "=_", "self_", "._", "outstanding", "prepar", "es_", "[_", "msg_", "._", "inr", "esp", "onset", "o_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "prc", "_", "._", "receive", "dco", "unt_", "+=_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "prc", "_", "._", "receive", "dfr", "om_", "._", "add_", "(_", "conn_", "._", "peer", "id_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "self_", "._", "debug_", ":_", "self_", "._", "logger_", "._", "write_", "(_", "\"", "Pa", "xo", "s", " ", "State", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "got", " ", "an", " ", "accept", " ", "for", " ", "ballot", "no", " ", "%", "s", " ", "\"_", "\"", "command", "no", " ", "%", "s", " ", "propos", "al", " ", "%", "s", " ", "with", " ", "%", "d", "/", "%", "d", "\"_", "%_", "(_", "prc", "_", "._", "ballot", "number_", ",_", "prc", "_", "._", "command", "number_", ",_", "prc", "_", "._", "proposal_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "prc", "_", "._", "receive", "dco", "unt_", ",_", "prc", "_", "._", "nto", "tal_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "assert_", "msg_", "._", "ballot", "number_", "==_", "prc", "_", "._", "ballot", "number_", ",_", "\"[", "%", "s", "]", " ", "MS", "G", "\\u", "PREP", "ARE", "\\u", "ADO", "PTE", "D", " ", "cann", "ot", " ", "have", " ", "non", "-", "matchi", "ng", " ", "ballot", "number", "\"_", "%_", "self_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "add", " ", "all", " ", "the", " ", "p", "-", "values", " ", "from", " ", "the", " ", "response", " ", "to", " ", "the", " ", "possib", "lep", "values", "et_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "msg_", "._", "pvalue", "set_", "is_", "not_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "prc", "_", "._", "possib", "lep", "values", "et_", "._", "union_", "(_", "msg_", "._", "pvalue", "set_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "prc", "_", "._", "receive", "dco", "unt_", ">=_", "prc", "_", "._", "nq", "uo", "rum", "_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "self_", "._", "debug_", ":_", "self_", "._", "logger_", "._", "write_", "(_", "\"", "Pa", "xo", "s", " ", "State", "\"_", ",_", "\"", "suff", "ient", "ly", " ", "many", " ", "accepts", " ", "on", " ", "prepar", "e", "!\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "take", " ", "this", " ", "response", " ", "collect", "or", " ", "out", " ", "of", " ", "the", " ", "outstanding", " ", "prepar", "e", " ", "set_", "\\u\\u\\uNL\\u\\u\\u_", "del_", "self_", "._", "outstanding", "prepar", "es_", "[_", "msg_", "._", "inr", "esp", "onset", "o_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "choose", " ", "pvalue", "s", " ", "with", " ", "distinct", "ive", " ", "command", "numbers", " ", "and", " ", "high", "est", " ", "ballot", "numbers_", "\\u\\u\\uNL\\u\\u\\u_", "pma", "xse", "t_", "=_", "prc", "_", "._", "possib", "lep", "values", "et_", "._", "pma", "x_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "command", "number_", ",_", "proposal_", "in_", "pma", "xse", "t_", "._", "iteritems_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "self_", "._", "add", "\\u", "to", "\\u", "proposals", "_", "(_", "command", "number_", ",_", "proposal_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "If", " ", "the", " ", "command", "number", " ", "we", " ", "wer", "e", " ", "planning", " ", "to", " ", "use", " ", "is", " ", "overwrit", "ten_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "we", " ", "shou", "ld", " ", "try", " ", "propos", "ing", " ", "with", " ", "a", " ", "new", " ", "command", "number_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "self_", "._", "proposals", "_", "[_", "prc", "_", "._", "command", "number_", "]_", "!=_", "prc", "_", "._", "proposal_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "self_", "._", "pick", "\\u", "command", "number", "\\u", "add", "\\u", "to", "\\u", "pending_", "(_", "prc", "_", "._", "proposal_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "issue", "\\u", "pend", "ing", "\\u", "commands_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "for_", "chosen", "command", "number_", ",_", "chosen", "proposal_", "in_", "self_", "._", "proposals", "_", "._", "iteritems_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "send", " ", "proposals", " ", "for", " ", "every", " ", "outstanding", " ", "propos", "al", " ", "tha", "t", " ", "is", " ", "collected", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "if_", "self_", "._", "debug_", ":_", "self_", "._", "logger_", "._", "write_", "(_", "\"", "Pa", "xo", "s", " ", "State", "\"_", ",_", "\"", "Sen", "ding", " ", "PROP", "OSE", " ", "for", " ", "%", "d", ",", " ", "%", "s", "\"_", "\\u\\u\\uNL\\u\\u\\u_", "%_", "(_", "chosen", "command", "number_", ",_", "chosen", "proposal_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "newp", "rc_", "=_", "Respons", "e", "Collector_", "(_", "prc", "_", "._", "quorum", "_", ",_", "prc", "_", "._", "ballot", "number_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "chosen", "command", "number_", ",_", "chosen", "proposal_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "outstanding", "propos", "es_", "[_", "chosen", "command", "number_", "]_", "=_", "newp", "rc_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "propos", "e_", "=_", "create", "\\u", "message_", "(_", "MS", "G", "\\u", "PROP", "OSE", "_", ",_", "self_", "._", "me_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "{_", "FL", "D", "\\u", "BAL", "LOT", "NUMBER_", ":_", "prc", "_", "._", "ballot", "number_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "FL", "D", "\\u", "COMMA", "ND", "NUMBER_", ":_", "chosen", "command", "number_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "FL", "D", "\\u", "PROP", "OS", "AL_", ":_", "chosen", "proposal_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "FL", "D", "\\u", "SERVER", "BATCH", "_", ":_", "isinstance_", "(_", "chosen", "proposal_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "Propos", "al", "Server", "Batch_", ")_", "}_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "send_", "(_", "propos", "e_", ",_", "group_", "=_", "newp", "rc_", "._", "quorum", "_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "As", " ", "leader", " ", "collected", " ", "all", " ", "proposals", " ", "its", " ", "state", " ", "is", " ", "up", "-", "to", "-", "date_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "and", " ", "it", " ", "is", " ", "don", "e", " ", "initiali", "zin", "g_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "leader", "\\u", "initiali", "zin", "g_", "=_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "state", "upto", "date_", "=_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "bec", "ome", " ", "active_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "active_", "=_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Replica", "_", "(_", "Node_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "msg", "\\u", "prepar", "e\\u", "pree", "mpte", "d_", "(_", "self_", ",_", "conn_", ",_", "msg_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "MS", "G", "\\u", "PREP", "ARE", "\\u", "PRE", "EMP", "TED", " ", "is", " ", "handle", "d", " ", "only", " ", "if", " ", "it", " ", "belo", "ngs", " ", "to", " ", "an", " ", "outstanding", " ", "MS", "G", "\\u", "PREP", "ARE", ",", "\\", "10", ";", " ", " ", " ", " ", "other", "wis", "e", " ", "it", " ", "is", " ", "discard", "ed", ".", "\\", "10", ";", " ", " ", " ", " ", "A", " ", "MS", "G", "\\u", "PREP", "ARE", "\\u", "PRE", "EMP", "TED", " ", "caus", "es", " ", "the", " ", "PREP", "ARE", " ", "STAGE", " ", "to", " ", "be", " ", "unsuc", "cess", "ful", ",", " ", "hen", "ce", " ", "the", " ", "current", "\\", "10", ";", " ", " ", " ", " ", "state", " ", "is", " ", "delete", "d", " ", "and", " ", "a", " ", "ne", " ", "PREP", "ARE", " ", "STAGE", " ", "is", " ", "initialize", "d", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "State", " ", "Update", "s", ":", "\\", "10", ";", " ", " ", " ", " ", "-", " ", "kill", " ", "the", " ", "PREP", "ARE", " ", "STAGE", " ", "tha", "t", " ", "receive", "d", " ", "a", " ", "MS", "G", "\\u", "PREP", "ARE", "\\u", "PRE", "EMP", "TED", "\\", "10", ";", " ", " ", " ", " ", "--", " ", "remove", " ", "the", " ", "old", " ", "Respons", "e", "Collect", "or", " ", "from", " ", "the", " ", "outstanding", " ", "prepar", "e", " ", "set", "\\", "10", ";", " ", " ", " ", " ", "-", " ", "remove", " ", "the", " ", "command", " ", "from", " ", "proposals", ",", " ", "add", " ", "it", " ", "to", " ", "pend", "ing", "command", "s", "\\", "10", ";", " ", " ", " ", " ", "-", " ", "update", " ", "the", " ", "ballot", "number", "\\", "10", ";", " ", " ", " ", " ", "-", " ", "initiate", " ", "command", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "msg_", "._", "inr", "esp", "onset", "o_", "in_", "self_", "._", "outstanding", "prepar", "es_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "prc", "_", "=_", "self_", "._", "outstanding", "prepar", "es_", "[_", "msg_", "._", "inr", "esp", "onset", "o_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "self_", "._", "debug_", ":_", "self_", "._", "logger_", "._", "write_", "(_", "\"", "Pa", "xo", "s", " ", "State", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "got", " ", "a", " ", "reject", " ", "for", " ", "ballot", "no", " ", "%", "s", " ", "propos", "al", " ", "%", "s", " ", "with", " ", "%", "d", "/", "%", "d", "\"_", "\\u\\u\\uNL\\u\\u\\u_", "%_", "(_", "prc", "_", "._", "ballot", "number_", ",_", "prc", "_", "._", "proposal_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "prc", "_", "._", "receive", "dco", "unt_", ",_", "prc", "_", "._", "nto", "tal_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "take", " ", "this", " ", "response", " ", "collect", "or", " ", "out", " ", "of", " ", "the", " ", "outstanding", " ", "prepar", "e", " ", "set_", "\\u\\u\\uNL\\u\\u\\u_", "del_", "self_", "._", "outstanding", "prepar", "es_", "[_", "msg_", "._", "inr", "esp", "onset", "o_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "bec", "ome", " ", "inactive_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "active_", "=_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "handle", " ", "reject_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "\\u", "handler", "ejec", "t_", "(_", "msg_", ",_", "prc", "_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Replica", "_", "(_", "Node_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "msg", "\\u", "propos", "e\\u", "accept_", "(_", "self_", ",_", "conn_", ",_", "msg_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "MS", "G", "\\u", "PROP", "OSE", "\\u", "ACCEPT", " ", "is", " ", "handle", "d", " ", "only", " ", "if", " ", "it", " ", "belo", "ngs", " ", "to", " ", "an", " ", "outstanding", " ", "MS", "G", "\\u", "PREP", "ARE", ",", "\\", "10", ";", " ", " ", " ", " ", "other", "wis", "e", " ", "it", " ", "is", " ", "discard", "ed", ".", "\\", "10", ";", " ", " ", " ", " ", "Whe", "n", " ", "MS", "G", "\\u", "PROP", "OSE", "\\u", "ACCEPT", " ", "is", " ", "receive", "d", ",", " ", "the", " ", "correspond", "ing", " ", "Respons", "e", "Collect", "or", " ", "is", " ", "retrieved", "\\", "10", ";", " ", " ", " ", " ", "and", " ", "its", " ", "state", " ", "is", " ", "update", "d", " ", "according", "ly", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "State", " ", "Update", "s", ":", "\\", "10", ";", " ", " ", " ", " ", "-", " ", "increment", " ", "receive", "dco", "unt", "\\", "10", ";", " ", " ", " ", " ", "-", " ", "if", " ", "receive", "dco", "unt", " ", "is", " ", "great", "er", " ", "than", " ", "the", " ", "quorum", " ", "size", ",", " ", "PROP", "OSE", " ", "STAGE", " ", "is", " ", "success", "ful", ".", "\\", "10", ";", " ", " ", " ", " ", "--", " ", "remove", " ", "the", " ", "old", " ", "Respons", "e", "Collect", "or", " ", "from", " ", "the", " ", "outstanding", " ", "prepar", "e", " ", "set", "\\", "10", ";", " ", " ", " ", " ", "--", " ", "create", " ", "MS", "G", "\\u", "PERF", "ORM", ":", " ", "message", " ", "carri", "es", " ", "the", " ", "chosen", " ", "command", "number", " ", "and", " ", "propos", "al", ".", "\\", "10", ";", " ", " ", " ", " ", "--", " ", "send", " ", "MS", "G", "\\u", "PERF", "ORM", " ", "to", " ", "all", " ", "Replica", "s", " ", "and", " ", "Leader", "s", "\\", "10", ";", " ", " ", " ", " ", "--", " ", "execute", " ", "the", " ", "command", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "msg_", "._", "command", "number_", "in_", "self_", "._", "outstanding", "propos", "es_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "prc", "_", "=_", "self_", "._", "outstanding", "propos", "es_", "[_", "msg_", "._", "command", "number_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "msg_", "._", "inr", "esp", "onset", "o_", "==_", "prc", "_", "._", "ballot", "number_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "prc", "_", "._", "receive", "dco", "unt_", "+=_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "prc", "_", "._", "receive", "dfr", "om_", "._", "add_", "(_", "conn_", "._", "peer", "id_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "self_", "._", "debug_", ":_", "self_", "._", "logger_", "._", "write_", "(_", "\"", "Pa", "xo", "s", " ", "State", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "got", " ", "an", " ", "accept", " ", "for", " ", "propos", "al", " ", "ballot", "no", " ", "%", "s", " ", "\"_", "\"", "command", "no", " ", "%", "s", " ", "propos", "al", " ", "%", "s", " ", "mak", "ing", " ", "%", "d", "/", "%", "d", " ", "accepts", "\"_", "%_", "(_", "prc", "_", "._", "ballot", "number_", ",_", "prc", "_", "._", "command", "number_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "prc", "_", "._", "proposal_", ",_", "prc", "_", "._", "receive", "dco", "unt_", ",_", "prc", "_", "._", "nto", "tal_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "prc", "_", "._", "receive", "dco", "unt_", ">=_", "prc", "_", "._", "nq", "uo", "rum", "_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "if_", "self_", "._", "debug_", ":_", "self_", "._", "logger_", "._", "write_", "(_", "\"", "Pa", "xo", "s", " ", "State", "\"_", ",_", "\"", "Agr", "eed", " ", "on", " ", "%", "s", "\"_", "%_", "str_", "(_", "prc", "_", "._", "proposal_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "take", " ", "this", " ", "response", " ", "collect", "or", " ", "out", " ", "of", " ", "the", " ", "outstanding", " ", "propos", "e", " ", "set_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "add", "\\u", "to", "\\u", "proposals", "_", "(_", "prc", "_", "._", "command", "number_", ",_", "prc", "_", "._", "proposal_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "delete", " ", "outstanding", " ", "message", "s", " ", "tha", "t", " ", "caller", " ", "doe", "s", " ", "not", " ", "need", " ", "to", " ", "check", " ", "for", " ", "any", "more_", "\\u\\u\\uNL\\u\\u\\u_", "del_", "self_", "._", "outstanding", "propos", "es_", "[_", "msg_", "._", "command", "number_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "now", " ", "we", " ", "can", " ", "perform", " ", "this", " ", "action", " ", "on", " ", "the", " ", "replicas_", "\\u\\u\\uNL\\u\\u\\u_", "perform", "message_", "=_", "create", "\\u", "message_", "(_", "MS", "G", "\\u", "PERF", "ORM", "_", ",_", "self_", "._", "me_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "{_", "FL", "D", "\\u", "COMMA", "ND", "NUMBER_", ":_", "prc", "_", "._", "command", "number_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "FL", "D", "\\u", "PROP", "OS", "AL_", ":_", "prc", "_", "._", "proposal_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "FL", "D", "\\u", "SERVER", "BATCH", "_", ":_", "isinstance_", "(_", "prc", "_", "._", "proposal_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "Propos", "al", "Server", "Batch_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "FL", "D", "\\u", "CLIENT", "BATCH", "_", ":_", "isinstance_", "(_", "prc", "_", "._", "proposal_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "Propos", "al", "Client", "Batch_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "FL", "D", "\\u", "DEC", "ISI", "ON", "BAL", "LOT", "NUMBER_", ":_", "prc", "_", "._", "ballot", "number_", "}_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "self_", "._", "debug_", ":_", "self_", "._", "logger_", "._", "write_", "(_", "\"", "Pa", "xo", "s", " ", "State", "\"_", ",_", "\"", "Sen", "ding", " ", "PERF", "ORM", "!\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "len_", "(_", "self_", "._", "replicas_", ")_", ">_", "0_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "self_", "._", "send_", "(_", "perform", "message_", ",_", "group_", "=_", "self_", "._", "replicas_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "perform_", "(_", "parse", "\\u", "message_", "(_", "perform", "message_", ")_", ",_", "designate", "d_", "=_", "True_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "self_", "._", "debug_", ":_", "self_", "._", "logger_", "._", "write_", "(_", "\"", "State", "\"_", ",_", "\"", "return", "ing", " ", "from", " ", "msg", "\\u", "propos", "e\\u", "accept", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Replica", "_", "(_", "Node_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "msg", "\\u", "propos", "e\\u", "reject_", "(_", "self_", ",_", "conn_", ",_", "msg_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "MS", "G", "\\u", "PROP", "OSE", "\\u", "REJECT", " ", "is", " ", "handle", "d", " ", "only", " ", "if", " ", "it", " ", "belo", "ngs", " ", "to", " ", "an", " ", "outstanding", " ", "MS", "G", "\\u", "PROP", "OSE", ",", "\\", "10", ";", " ", " ", " ", " ", "other", "wis", "e", " ", "it", " ", "is", " ", "discard", "ed", ".", "\\", "10", ";", " ", " ", " ", " ", "A", " ", "MS", "G", "\\u", "PROP", "OSE", "\\u", "REJECT", " ", "caus", "es", " ", "the", " ", "PROP", "OSE", " ", "STAGE", " ", "to", " ", "be", " ", "unsuc", "cess", "ful", ",", " ", "hen", "ce", " ", "the", " ", "current", "\\", "10", ";", " ", " ", " ", " ", "state", " ", "is", " ", "delete", "d", " ", "and", " ", "a", " ", "new", " ", "PREP", "ARE", " ", "STAGE", " ", "is", " ", "initialize", "d", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "State", " ", "Update", "s", ":", "\\", "10", ";", " ", " ", " ", " ", "-", " ", "kill", " ", "the", " ", "PROP", "OSE", " ", "STAGE", " ", "tha", "t", " ", "receive", "d", " ", "a", " ", "MS", "G", "\\u", "PROP", "OSE", "\\u", "REJECT", "\\", "10", ";", " ", " ", " ", " ", "--", " ", "remove", " ", "the", " ", "old", " ", "Respons", "e", "Collect", "or", " ", "from", " ", "the", " ", "outstanding", " ", "prepar", "e", " ", "set", "\\", "10", ";", " ", " ", " ", " ", "-", " ", "remove", " ", "the", " ", "command", " ", "from", " ", "proposals", ",", " ", "add", " ", "it", " ", "to", " ", "pend", "ing", "command", "s", "\\", "10", ";", " ", " ", " ", " ", "-", " ", "update", " ", "the", " ", "ballot", "number", "\\", "10", ";", " ", " ", " ", " ", "-", " ", "initiate", " ", "command", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "msg_", "._", "command", "number_", "in_", "self_", "._", "outstanding", "propos", "es_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "prc", "_", "=_", "self_", "._", "outstanding", "propos", "es_", "[_", "msg_", "._", "command", "number_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "msg_", "._", "inr", "esp", "onset", "o_", "==_", "prc", "_", "._", "ballot", "number_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "self_", "._", "debug_", ":_", "self_", "._", "logger_", "._", "write_", "(_", "\"", "Pa", "xo", "s", " ", "State", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "got", " ", "a", " ", "reject", " ", "for", " ", "propos", "al", " ", "ballot", "no", " ", "%", "s", " ", "\"_", "\"", "command", "no", " ", "%", "s", " ", "propos", "al", " ", "%", "s", " ", "still", " ", "%", "d", " ", "\"_", "\"", "out", " ", "of", " ", "%", "d", " ", "accepts", "\"_", "%_", "(_", "prc", "_", "._", "ballot", "number_", ",_", "prc", "_", "._", "command", "number_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "prc", "_", "._", "proposal_", ",_", "prc", "_", "._", "receive", "dco", "unt_", ",_", "prc", "_", "._", "nto", "tal_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "take", " ", "this", " ", "response", " ", "collect", "or", " ", "out", " ", "of", " ", "the", " ", "outstanding", " ", "propos", "e", " ", "set_", "\\u\\u\\uNL\\u\\u\\u_", "del_", "self_", "._", "outstanding", "propos", "es_", "[_", "msg_", "._", "command", "number_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "bec", "ome", " ", "inactive_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "active_", "=_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "handle", " ", "reject_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "\\u", "handler", "ejec", "t_", "(_", "msg_", ",_", "prc", "_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Replica", "_", "(_", "Node_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "\\u", "handler", "ejec", "t_", "(_", "self_", ",_", "msg_", ",_", "prc", "_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "self_", "._", "debug_", ":_", "self_", "._", "logger_", "._", "write_", "(_", "\"", "State", "\"_", ",_", "\"", "Hand", "ling", " ", "the", " ", "reject", ".\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "msg_", "._", "ballot", "number_", "[_", "BAL", "LOT", "EPOCH", "_", "]_", "==_", "self_", "._", "ballot", "number_", "[_", "BAL", "LOT", "EPOCH", "_", "]_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "self_", "._", "debug_", ":_", "self_", "._", "logger_", "._", "write_", "(_", "\"", "State", "\"_", ",_", "\"", "Up", "dati", "ng", " ", "ballot", "number", " ", "and", " ", "retrying", ".\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "update", " ", "the", " ", "ballot", " ", "number_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "update", "\\u", "ballot", "number_", "(_", "msg_", "._", "ballot", "number_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "remove", " ", "the", " ", "propos", "al", " ", "from", " ", "proposals", "_", "\\u\\u\\uNL\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "remove", "\\u", "from", "\\u", "proposals", "_", "(_", "prc", "_", "._", "command", "number_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "Key", "Error_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "self_", "._", "debug_", ":_", "self_", "._", "logger_", "._", "write_", "(_", "\"", "State", "\"_", ",_", "\"", "Propos", "al", " ", "alr", "ead", "y", " ", "remove", "d", ".\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "pick", "\\u", "command", "number", "\\u", "add", "\\u", "to", "\\u", "pending_", "(_", "prc", "_", "._", "proposal_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "leader", "\\u", "caus", "ing", "\\u", "reject_", "=_", "self_", "._", "detect", "\\u", "colli", "ding", "\\u", "leader_", "(_", "msg_", "._", "ballot", "number_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "leader", "\\u", "caus", "ing", "\\u", "reject_", "<_", "self_", "._", "me_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "if", " ", "caller", " ", "lost", " ", "to", " ", "a", " ", "replica", " ", "who", "se", " ", "name", " ", "prece", "des", " ", "its", ",", " ", "back", " ", "off", " ", "more_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "backoff_", "+=_", "BACK", "OFF", "INC", "REA", "SE_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "self_", "._", "debug_", ":_", "self_", "._", "logger_", "._", "write_", "(_", "\"", "Pa", "xo", "s", " ", "State", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "There", " ", "is", " ", "anot", "her", " ", "leader", ":", " ", "%", "s", "\"_", "%_", "str_", "(_", "leader", "\\u", "caus", "ing", "\\u", "reject_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "time_", "._", "sleep_", "(_", "self_", "._", "backoff_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "issue", "\\u", "pend", "ing", "\\u", "commands_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "if", " ", "the", " ", "epoch", " ", "is", " ", "wrong", ",", " ", "shou", "ld", " ", "collect", " ", "the", " ", "state", " ", "and", " ", "start", " ", "from", " ", "beginn", "ing_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "self_", "._", "debug_", ":_", "self_", "._", "logger_", "._", "write_", "(_", "\"", "State", "\"_", ",_", "\"", "In", " ", "wrong", " ", "EPOCH", ".\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "\\u", "rej", "oin", "_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Replica", "_", "(_", "Node_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "\\u", "rej", "oin", "_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "not_", "self_", "._", "state", "upto", "date_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "self_", "._", "debug_", ":_", "self_", "._", "logger_", "._", "write_", "(_", "\"", "State", "\"_", ",_", "\"", "Re", "join", "ing", ".\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "leader", "ship", " ", "state_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "isl", "eader", "_", "=_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "leader", "\\u", "initiali", "zin", "g_", "=_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "state", "upto", "date_", "=_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "command", "s", " ", "tha", "t", " ", "are", " ", "proposed", ":", " ", "<", "command", "number", ":", "command", ">_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "proposals", "_", "=_", "{_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "proposals", "et_", "=_", "set_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "command", "s", " ", "tha", "t", " ", "are", " ", "receive", "d", ",", " ", "not", " ", "ye", "t", " ", "proposed", ":", " ", "<", "command", "number", ":", "command", ">_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "pend", "ing", "commands_", "=_", "{_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "pend", "ing", "command", "set_", "=_", "set_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "nodes", " ", "bei", "ng", " ", "adde", "d", "/", "deleted_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "nodes", "bei", "ng", "deleted_", "=_", "set_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "keep", " ", "nodes", " ", "tha", "t", " ", "are", " ", "recent", "ly", " ", "updated_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "recent", "ly", "update", "dp", "eer", "slo", "ck_", "=_", "Lock_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "recent", "ly", "update", "dp", "eer", "s_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "send", " ", "msg", "\\u", "hel", "o", " ", "to", " ", "the", " ", "replica", "s", " ", "in", " ", "the", " ", "view_", "\\u\\u\\uNL\\u\\u\\u_", "for_", "replica", "peer_", "in_", "self_", "._", "replicas_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "replica", "peer_", "!=_", "self_", "._", "me_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "self_", "._", "debug_", ":_", "self_", "._", "logger_", "._", "write_", "(_", "\"", "State", "\"_", ",_", "\"", "Sen", "ding", " ", "HE", "LO", " ", "to", " ", "%", "s", "\"_", "%_", "\\u\\u\\uNL\\u\\u\\u_", "str_", "(_", "replica", "peer_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "hel", "ome", "ssa", "ge_", "=_", "create", "\\u", "message_", "(_", "MS", "G", "\\u", "HE", "LO", "_", ",_", "self_", "._", "me_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "success", "id_", "=_", "self_", "._", "send_", "(_", "hel", "ome", "ssa", "ge_", ",_", "peer_", "=_", "replica", "peer_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Replica", "_", "(_", "Node_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "ping", "\\u", "neighbor_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "used", " ", "to", " ", "ping", " ", "neighbor", "s", " ", "periodic", "ally", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "while_", "True_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Go", " ", "through", " ", "all", " ", "peer", "s", " ", "in", " ", "the", " ", "view_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "for_", "peer_", "in_", "self_", "._", "replicas_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "success", "id_", "=_", "0_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "peer_", "==_", "self_", "._", "me_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "continue_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Check", " ", "whe", "n", " ", "last", " ", "hear", "d", " ", "from", " ", "peer_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "peer_", "in_", "self_", "._", "nodel", "ive", "ness_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "nos", "ound_", "=_", "time_", "._", "time_", "(_", ")_", "-_", "self_", "._", "nodel", "ive", "ness_", "[_", "peer_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Thi", "s", " ", "peer", " ", "did", " ", "not", " ", "send", " ", "a", " ", "message", ",", " ", "send", " ", "a", " ", "PING", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "nos", "ound_", "=_", "LIVE", "NESS", "TIMEOUT_", "+_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "nos", "ound_", "<=_", "LIVE", "NESS", "TIMEOUT_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Peer", " ", "is", " ", "alive_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "self_", "._", "replicas_", "[_", "peer_", "]_", "=_", "0_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "continue_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "nos", "ound_", ">_", "LIVE", "NESS", "TIMEOUT_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Sen", "d", " ", "PING", " ", "to", " ", "peer_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "if_", "self_", "._", "debug_", ":_", "self_", "._", "logger_", "._", "write_", "(_", "\"", "State", "\"_", ",_", "\"", "Sen", "ding", " ", "PING", " ", "to", " ", "%", "s", "\"_", "%_", "str_", "(_", "peer_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "ping", "message_", "=_", "create", "\\u", "message_", "(_", "MS", "G", "\\u", "PING", "_", ",_", "self_", "._", "me_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "success", "id_", "=_", "self_", "._", "send_", "(_", "ping", "message_", ",_", "peer_", "=_", "peer_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "success", "id_", "<_", "0_", "or_", "nos", "ound_", ">_", "(_", "2_", "*_", "LIVE", "NESS", "TIMEOUT_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "The", " ", "neighbor", " ", "is", " ", "not", " ", "respond", "ing_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "if_", "self_", "._", "debug_", ":_", "self_", "._", "logger_", "._", "write_", "(_", "\"", "State", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "Neighbor", " ", "not", " ", "respond", "ing", " ", "%", "s", "\"_", "%_", "str_", "(_", "peer_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Mark", " ", "the", " ", "neighbor_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "replicas_", "[_", "peer_", "]_", "+=_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Check", " ", "leader", "ship_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "not_", "self_", "._", "isl", "eader", "_", "and_", "self_", "._", "find", "\\u", "leader_", "(_", ")_", "==_", "self_", "._", "me_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "if_", "self_", "._", "debug_", ":_", "self_", "._", "logger_", "._", "write_", "(_", "\"", "State", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "Be", "comi", "ng", " ", "leader", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "bec", "ome", "\\u", "leader_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "self_", "._", "isl", "eader", "_", "and_", "peer_", "not_", "in_", "self_", "._", "nodes", "bei", "ng", "deleted_", "and_", "peer_", "in_", "self_", "._", "replicas_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "if_", "self_", "._", "debug_", ":_", "self_", "._", "logger_", "._", "write_", "(_", "\"", "State", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "Del", "eti", "ng", " ", "node", " ", "%", "s", "\"_", "%_", "str_", "(_", "peer_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "nodes", "bei", "ng", "deleted_", "._", "add_", "(_", "peer_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "del", "command_", "=_", "self_", "._", "create", "\\u", "delete", "\\u", "command_", "(_", "peer_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "pick", "\\u", "command", "number", "\\u", "add", "\\u", "to", "\\u", "pending_", "(_", "del", "command_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "i_", "in_", "range_", "(_", "WINDOW_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "noop", "command_", "=_", "self_", "._", "create", "\\u", "noop", "\\u", "command_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "pick", "\\u", "command", "number", "\\u", "add", "\\u", "to", "\\u", "pending_", "(_", "noop", "command_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "issue", "msg_", "=_", "create", "\\u", "message_", "(_", "MS", "G", "\\u", "ISSUE", "_", ",_", "self_", "._", "me_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "send_", "(_", "issue", "msg_", ",_", "peer_", "=_", "self_", "._", "me_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "with_", "self_", "._", "recent", "ly", "update", "dp", "eer", "slo", "ck_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "recent", "ly", "update", "dp", "eer", "s_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "time_", "._", "sleep_", "(_", "LIVE", "NESS", "TIMEOUT_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Replica", "_", "(_", "Node_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "create", "\\u", "delete", "\\u", "command_", "(_", "self_", ",_", "node_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "include", " ", "the", " ", "ballot", "number", " ", "in", " ", "the", " ", "meta", "command_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "myn", "umber_", "=_", "self_", "._", "meta", "command", "number_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "meta", "command", "number_", "+=_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "nodename_", "=_", "node_", "._", "addr_", "+_", "\":\"_", "+_", "str_", "(_", "node_", "._", "port_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "operati", "ont", "uple_", "=_", "(_", "\"\\u", "del", "\\u", "node", "\"_", ",_", "node_", "._", "type_", ",_", "nodename_", ",_", "self_", "._", "ballot", "number_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "command_", "=_", "Propos", "al_", "(_", "self_", "._", "me_", ",_", "myn", "umber_", ",_", "operati", "ont", "uple_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "command_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Replica", "_", "(_", "Node_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "create", "\\u", "add", "\\u", "command_", "(_", "self_", ",_", "node_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "myn", "umber_", "=_", "self_", "._", "meta", "command", "number_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "meta", "command", "number_", "+=_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "nodename_", "=_", "node_", "._", "addr_", "+_", "\":\"_", "+_", "str_", "(_", "node_", "._", "port_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "operati", "ont", "uple_", "=_", "(_", "\"\\u", "add", "\\u", "node", "\"_", ",_", "node_", "._", "type_", ",_", "nodename_", ",_", "self_", "._", "ballot", "number_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "command_", "=_", "Propos", "al_", "(_", "self_", "._", "me_", ",_", "myn", "umber_", ",_", "operati", "ont", "uple_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "command_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Replica", "_", "(_", "Node_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "create", "\\u", "noop", "\\u", "command_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "myn", "umber_", "=_", "self_", "._", "meta", "command", "number_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "meta", "command", "number_", "+=_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "noop", "tuple_", "=_", "(_", "\"", "noop", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "command_", "=_", "Propos", "al_", "(_", "self_", "._", "me_", ",_", "myn", "umber_", ",_", "noop", "tuple_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "command_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Replica", "_", "(_", "Node_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "cmd", "\\u", "command_", "(_", "self_", ",_", "*_", "args_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "shell", " ", "command", " ", "[", "command", "]:", " ", "initiate", " ", "a", " ", "new", " ", "command", ".\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "cmd", "proposal_", "=_", "Propos", "al_", "(_", "self_", "._", "me_", ",_", "random_", "._", "randint_", "(_", "1_", ",_", "10000000", "_", ")_", ",_", "args_", "[_", "1_", ":_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "handle", "\\u", "client", "\\u", "command_", "(_", "cmd", "proposal_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "Index", "Error_", "as_", "e_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "print_", "\"", "command", " ", "expect", "s", " ", "only", " ", "one", " ", "command", ":", " ", "\"_", ",_", "str_", "(_", "e_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Replica", "_", "(_", "Node_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "cmd", "\\u", "gol", "eader", "_", "(_", "self_", ",_", "args_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "start", " ", "Leader", " ", "state", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "bec", "ome", "\\u", "leader_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Replica", "_", "(_", "Node_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "cmd", "\\u", "show", "object_", "(_", "self_", ",_", "args_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "print", " ", "replicate", "d", " ", "object", " ", "informati", "on", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "print_", "self_", "._", "object_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Replica", "_", "(_", "Node_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "cmd", "\\u", "info_", "(_", "self_", ",_", "args_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "print", " ", "next", " ", "command", "number", " ", "to", " ", "execute", " ", "and", " ", "executed", " ", "command", "s", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "print_", "str_", "(_", "self_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Replica", "_", "(_", "Node_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "cmd", "\\u", "proposals", "_", "(_", "self_", ",_", "args_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "print", "s", " ", "proposals", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "cmd", "num_", ",_", "command_", "in_", "self_", "._", "proposals", "_", "._", "iteritems_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "print_", "\"%", "d", ":", " ", "%", "s", "\"_", "%_", "(_", "cmd", "num_", ",_", "str_", "(_", "command_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Replica", "_", "(_", "Node_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "cmd", "\\u", "pending_", "(_", "self_", ",_", "args_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "print", "s", " ", "pend", "ing", " ", "command", "s", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "cmd", "num_", ",_", "command_", "in_", "self_", "._", "pend", "ing", "commands_", "._", "iteritems_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "print_", "\"%", "d", ":", " ", "%", "s", "\"_", "%_", "(_", "cmd", "num_", ",_", "str_", "(_", "command_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Replica", "_", "(_", "Node_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "terminate", "\\u", "handler_", "(_", "self_", ",_", "signal_", ",_", "frame_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "\\u", "grace", "exit_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Replica", "_", "(_", "Node_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "\\u", "grace", "exit_", "(_", "self_", ",_", "exitcode_", "=_", "0_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "sys_", "._", "stdout_", "._", "flush_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "sys_", "._", "stderr_", "._", "flush_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "hasattr_", "(_", "self_", ",_", "'", "logg", "er", "'_", ")_", ":_", "self_", "._", "logger_", "._", "close_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "os_", "._", "\\u", "exit_", "(_", "exitcode_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "main_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "replica", "node_", "=_", "Replica", "_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "replica", "node_", "._", "starts", "ervice", "_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "signal_", "._", "signal_", "(_", "signal_", "._", "SIGINT_", ",_", "replica", "node_", "._", "terminate", "\\u", "handler_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "signal_", "._", "signal_", "(_", "signal_", "._", "SIGTERM_", ",_", "replica", "node_", "._", "terminate", "\\u", "handler_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "signal_", "._", "pause_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_" ]
[ 4, 4, 4, 4, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 4, 2, 2, 2, 2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 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 ]
Nested loops with same variable
azoft-dev-team/imagrium/env/Lib/distutils/command/sdist.py
[ { "content": " def add_defaults (self):\n \"\"\"Add all the default files to self.filelist:\n - README or README.txt\n - setup.py\n - test/test*.py\n - all pure Python modules mentioned in setup script\n - all C sources listed as part of extensions or C libraries\n in the setup script (doesn't catch C headers!)\n Warns if (README or README.txt) or setup.py are missing; everything\n else is optional.\n \"\"\"\n\n standards = [('README', 'README.txt'), self.distribution.script_name]\n for fn in standards:\n if type(fn) is TupleType:\n alts = fn\n got_it = 0\n for fn in alts:\n if os.path.exists(fn):\n got_it = 1\n self.filelist.append(fn)\n break\n\n if not got_it:\n self.warn(\"standard file not found: should have one of \" +\n string.join(alts, ', '))\n else:\n if os.path.exists(fn):\n self.filelist.append(fn)\n else:\n self.warn(\"standard file '%s' not found\" % fn)\n\n optional = ['test/test*.py', 'setup.cfg']\n for pattern in optional:\n files = filter(os.path.isfile, glob(pattern))\n if files:\n self.filelist.extend(files)\n\n if self.distribution.has_pure_modules():\n build_py = self.get_finalized_command('build_py')\n self.filelist.extend(build_py.get_source_files())\n\n if self.distribution.has_ext_modules():\n build_ext = self.get_finalized_command('build_ext')\n self.filelist.extend(build_ext.get_source_files())\n\n if self.distribution.has_c_libraries():\n build_clib = self.get_finalized_command('build_clib')\n self.filelist.extend(build_clib.get_source_files())\n\n if self.distribution.has_scripts():\n build_scripts = self.get_finalized_command('build_scripts')\n self.filelist.extend(build_scripts.get_source_files())", "metadata": "root.sdist.add_defaults", "header": "['class', 'sdist', '(', 'Command', ')', ':', '___EOS___']", "index": 257 } ]
[ { "span": "for fn in alts:", "start_line": 274, "start_column": 16, "end_line": 274, "end_column": 31 } ]
[ { "span": "for fn in standards:", "start_line": 270, "start_column": 8, "end_line": 270, "end_column": 28 } ]
1
true
[ "[CLS]_", "Nest", "ed_", "loops_", "with_", "same_", "variable_", "[SEP]_", "class_", "sdist", "_", "(_", "Command_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "add", "\\u", "defaults_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "Add", " ", "all", " ", "the", " ", "default", " ", "files", " ", "to", " ", "self", ".", "filelist", ":", "\\", "10", ";", " ", " ", "-", " ", "READ", "ME", " ", "or", " ", "READ", "ME", ".", "txt", "\\", "10", ";", " ", " ", "-", " ", "setup", ".", "py", "\\", "10", ";", " ", " ", "-", " ", "test", "/", "test", "*.", "py", "\\", "10", ";", " ", " ", "-", " ", "all", " ", "pure", " ", "Pyth", "on", " ", "module", "s", " ", "mentioned", " ", "in", " ", "setup", " ", "script", "\\", "10", ";", " ", " ", "-", " ", "all", " ", "C", " ", "source", "s", " ", "liste", "d", " ", "as", " ", "part", " ", "of", " ", "extensi", "ons", " ", "or", " ", "C", " ", "librar", "ies", "\\", "10", ";", " ", " ", " ", " ", "in", " ", "the", " ", "setup", " ", "script", " ", "(", "doe", "sn", "'", "t", " ", "catch", " ", "C", " ", "header", "s", "!)", "\\", "10", ";", " ", " ", " ", " ", "Warn", "s", " ", "if", " ", "(", "READ", "ME", " ", "or", " ", "READ", "ME", ".", "txt", ")", " ", "or", " ", "setup", ".", "py", " ", "are", " ", "missi", "ng", ";", " ", "every", "thing", "\\", "10", ";", " ", " ", " ", " ", "else", " ", "is", " ", "option", "al", ".", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "standard", "s_", "=_", "[_", "(_", "'", "READ", "ME", "'_", ",_", "'", "READ", "ME", ".", "txt", "'_", ")_", ",_", "self_", "._", "distribution_", "._", "script", "\\u", "name_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "fn_", "in_", "standard", "s_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "type_", "(_", "fn_", ")_", "is_", "Tup", "le", "Type_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "alts", "_", "=_", "fn_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "got", "\\u", "it_", "=_", "0_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "fn_", "in_", "alts", "_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "if_", "os_", "._", "path_", "._", "exists_", "(_", "fn_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "got", "\\u", "it_", "=_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "filelist_", "._", "append_", "(_", "fn_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "break_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "not_", "got", "\\u", "it_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "self_", "._", "warn_", "(_", "\"", "standard", " ", "file", " ", "not", " ", "found", ":", " ", "shou", "ld", " ", "have", " ", "one", " ", "of", " ", "\"_", "+_", "\\u\\u\\uNL\\u\\u\\u_", "string_", "._", "join_", "(_", "alts", "_", ",_", "',", " ", "'_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "os_", "._", "path_", "._", "exists_", "(_", "fn_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "self_", "._", "filelist_", "._", "append_", "(_", "fn_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "self_", "._", "warn_", "(_", "\"", "standard", " ", "file", " ", "'%", "s", "'", " ", "not", " ", "found", "\"_", "%_", "fn_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "optional_", "=_", "[_", "'", "test", "/", "test", "*.", "py", "'_", ",_", "'", "setup", ".", "cfg", "'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "pattern_", "in_", "optional_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "files_", "=_", "filter_", "(_", "os_", "._", "path_", "._", "isfile_", ",_", "glob_", "(_", "pattern_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "files_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "filelist_", "._", "extend_", "(_", "files_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "self_", "._", "distribution_", "._", "has", "\\u", "pure", "\\u", "modules_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "build", "\\u", "py_", "=_", "self_", "._", "get", "\\u", "finalize", "d\\u", "command_", "(_", "'", "build", "\\u", "py", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "filelist_", "._", "extend_", "(_", "build", "\\u", "py_", "._", "get", "\\u", "source", "\\u", "files_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "self_", "._", "distribution_", "._", "has", "\\u", "ext", "\\u", "modules_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "build", "\\u", "ext_", "=_", "self_", "._", "get", "\\u", "finalize", "d\\u", "command_", "(_", "'", "build", "\\u", "ext", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "filelist_", "._", "extend_", "(_", "build", "\\u", "ext_", "._", "get", "\\u", "source", "\\u", "files_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "self_", "._", "distribution_", "._", "has", "\\u", "c\\u", "libraries_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "build", "\\u", "clib", "_", "=_", "self_", "._", "get", "\\u", "finalize", "d\\u", "command_", "(_", "'", "build", "\\u", "clib", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "filelist_", "._", "extend_", "(_", "build", "\\u", "clib", "_", "._", "get", "\\u", "source", "\\u", "files_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "self_", "._", "distribution_", "._", "has", "\\u", "scripts_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "build", "\\u", "scripts_", "=_", "self_", "._", "get", "\\u", "finalize", "d\\u", "command_", "(_", "'", "build", "\\u", "scripts", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "filelist_", "._", "extend_", "(_", "build", "\\u", "scripts_", "._", "get", "\\u", "source", "\\u", "files_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_" ]
[ 4, 4, 4, 4, 4, 4, 4, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 ]
Except block handles 'BaseException'
CollabQ/CollabQ/vendor/django/test/testcases.py
[ { "content": " def check_output_xml(self, want, got, optionsflags):\n \"\"\"Tries to do a 'xml-comparision' of want and got. Plain string\n comparision doesn't always work because, for example, attribute\n ordering should not be important.\n\n Based on http://codespeak.net/svn/lxml/trunk/src/lxml/doctestcompare.py\n \"\"\"\n _norm_whitespace_re = re.compile(r'[ \\t\\n][ \\t\\n]+')\n def norm_whitespace(v):\n return _norm_whitespace_re.sub(' ', v)\n\n def child_text(element):\n return ''.join([c.data for c in element.childNodes\n if c.nodeType == Node.TEXT_NODE])\n\n def children(element):\n return [c for c in element.childNodes\n if c.nodeType == Node.ELEMENT_NODE]\n\n def norm_child_text(element):\n return norm_whitespace(child_text(element))\n\n def attrs_dict(element):\n return dict(element.attributes.items())\n\n def check_element(want_element, got_element):\n if want_element.tagName != got_element.tagName:\n return False\n if norm_child_text(want_element) != norm_child_text(got_element):\n return False\n if attrs_dict(want_element) != attrs_dict(got_element):\n return False\n want_children = children(want_element)\n got_children = children(got_element)\n if len(want_children) != len(got_children):\n return False\n for want, got in zip(want_children, got_children):\n if not check_element(want, got):\n return False\n return True\n\n want, got = self._strip_quotes(want, got)\n want = want.replace('\\\\n','\\n')\n got = got.replace('\\\\n','\\n')\n\n # If the string is not a complete xml document, we may need to add a\n # root element. This allow us to compare fragments, like \"<foo/><bar/>\"\n if not want.startswith('<?xml'):\n wrapper = '<root>%s</root>'\n want = wrapper % want\n got = wrapper % got\n\n # Parse the want and got strings, and compare the parsings.\n try:\n want_root = parseString(want).firstChild\n got_root = parseString(got).firstChild\n except:\n return False\n return check_element(want_root, got_root)", "metadata": "root.OutputChecker.check_output_xml", "header": "['class', 'OutputChecker', '(', 'doctest', '.', 'OutputChecker', ')', ':', '___EOS___']", "index": 87 }, { "content": " def check_output_json(self, want, got, optionsflags):\n \"Tries to compare want and got as if they were JSON-encoded data\"\n want, got = self._strip_quotes(want, got)\n try:\n want_json = simplejson.loads(want)\n got_json = simplejson.loads(got)\n except:\n return False\n return want_json == got_json", "metadata": "root.OutputChecker.check_output_json", "header": "['class', 'OutputChecker', '(', 'doctest', '.', 'OutputChecker', ')', ':', '___EOS___']", "index": 147 } ]
[ { "span": "except:", "start_line": 143, "start_column": 8, "end_line": 143, "end_column": 15 }, { "span": "except:", "start_line": 153, "start_column": 8, "end_line": 153, "end_column": 15 } ]
[]
1
true
[ "[CLS]_", "Except", "_", "block_", "handles_", "'", "Base", "Except", "ion", "'_", "[SEP]_", "class_", "Output", "Checker_", "(_", "doctest_", "._", "Output", "Checker_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "check", "\\u", "output", "\\u", "xml_", "(_", "self_", ",_", "want_", ",_", "got_", ",_", "options", "flags_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "Trie", "s", " ", "to", " ", "do", " ", "a", " ", "'", "xml", "-", "compa", "ris", "ion", "'", " ", "of", " ", "want", " ", "and", " ", "got", ".", " ", " ", "Plai", "n", " ", "string", "\\", "10", ";", " ", " ", " ", " ", "compa", "ris", "ion", " ", "doe", "sn", "'", "t", " ", "alw", "ay", "s", " ", "work", " ", "bec", "aus", "e", ",", " ", "for", " ", "example", ",", " ", "attribute", "\\", "10", ";", " ", " ", " ", " ", "orderi", "ng", " ", "shou", "ld", " ", "not", " ", "be", " ", "importa", "nt", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "Base", "d", " ", "on", " ", "http", "://", "codes", "peak", ".", "net", "/", "svn", "/", "lx", "ml", "/", "trunk", "/", "src", "/", "lx", "ml", "/", "docte", "stc", "omp", "are", ".", "py", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u", "norm", "\\u", "whitespace", "\\u", "re_", "=_", "re_", "._", "compile_", "(_", "r", "'[", " ", "\\\\", "t", "\\\\", "n", "][", " ", "\\\\", "t", "\\\\", "n", "]+'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "norm", "\\u", "whitespace_", "(_", "v_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "\\u", "norm", "\\u", "whitespace", "\\u", "re_", "._", "sub_", "(_", "'", " ", "'_", ",_", "v_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "child", "\\u", "text_", "(_", "element_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "''_", "._", "join_", "(_", "[_", "c_", "._", "data_", "for_", "c_", "in_", "element_", "._", "child", "Nodes_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "c_", "._", "node", "Type_", "==_", "Node_", "._", "TEXT", "\\u", "NODE_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "children_", "(_", "element_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "[_", "c_", "for_", "c_", "in_", "element_", "._", "child", "Nodes_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "c_", "._", "node", "Type_", "==_", "Node_", "._", "ELEMENT", "\\u", "NODE_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "norm", "\\u", "child", "\\u", "text_", "(_", "element_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "norm", "\\u", "whitespace_", "(_", "child", "\\u", "text_", "(_", "element_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "attr", "s", "\\u", "dict_", "(_", "element_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "dict_", "(_", "element_", "._", "attributes_", "._", "items_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "check", "\\u", "element_", "(_", "want", "\\u", "element_", ",_", "got", "\\u", "element_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "want", "\\u", "element_", "._", "tag", "Name_", "!=_", "got", "\\u", "element_", "._", "tag", "Name_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "norm", "\\u", "child", "\\u", "text_", "(_", "want", "\\u", "element_", ")_", "!=_", "norm", "\\u", "child", "\\u", "text_", "(_", "got", "\\u", "element_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "attr", "s", "\\u", "dict_", "(_", "want", "\\u", "element_", ")_", "!=_", "attr", "s", "\\u", "dict_", "(_", "got", "\\u", "element_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "want", "\\u", "children_", "=_", "children_", "(_", "want", "\\u", "element_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "got", "\\u", "children_", "=_", "children_", "(_", "got", "\\u", "element_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "len_", "(_", "want", "\\u", "children_", ")_", "!=_", "len_", "(_", "got", "\\u", "children_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "for_", "want_", ",_", "got_", "in_", "zip_", "(_", "want", "\\u", "children_", ",_", "got", "\\u", "children_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "not_", "check", "\\u", "element_", "(_", "want_", ",_", "got_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "return_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "want_", ",_", "got_", "=_", "self_", "._", "\\u", "strip", "\\u", "quotes_", "(_", "want_", ",_", "got_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "want_", "=_", "want_", "._", "replace_", "(_", "'\\\\\\\\", "n", "'_", ",_", "'\\\\", "n", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "got_", "=_", "got_", "._", "replace_", "(_", "'\\\\\\\\", "n", "'_", ",_", "'\\\\", "n", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "If", " ", "the", " ", "string", " ", "is", " ", "not", " ", "a", " ", "complete", " ", "xml", " ", "document", ",", " ", "we", " ", "may", " ", "need", " ", "to", " ", "add", " ", "a_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "root", " ", "element", ".", " ", "Thi", "s", " ", "allow", " ", "us", " ", "to", " ", "compare", " ", "fragment", "s", ",", " ", "like", " ", "\"<", "foo", "/>", "<", "bar", "/>\"_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "not_", "want_", "._", "startswith_", "(_", "'<", "?", "xml", "'_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "wrapper_", "=_", "'<", "root", ">", "%", "s", "</", "root", ">'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "want_", "=_", "wrapper_", "%_", "want_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "got_", "=_", "wrapper_", "%_", "got_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Pars", "e", " ", "the", " ", "want", " ", "and", " ", "got", " ", "string", "s", ",", " ", "and", " ", "compare", " ", "the", " ", "pars", "ings", "._", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "want", "\\u", "root_", "=_", "parse", "String_", "(_", "want_", ")_", "._", "first", "Child_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "got", "\\u", "root_", "=_", "parse", "String_", "(_", "got_", ")_", "._", "first", "Child_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "check", "\\u", "element_", "(_", "want", "\\u", "root_", ",_", "got", "\\u", "root_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Output", "Checker_", "(_", "doctest_", "._", "Output", "Checker_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "check", "\\u", "output", "\\u", "json_", "(_", "self_", ",_", "want_", ",_", "got_", ",_", "options", "flags_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"", "Trie", "s", " ", "to", " ", "compare", " ", "want", " ", "and", " ", "got", " ", "as", " ", "if", " ", "the", "y", " ", "wer", "e", " ", "JSO", "N", "-", "encode", "d", " ", "data", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "want_", ",_", "got_", "=_", "self_", "._", "\\u", "strip", "\\u", "quotes_", "(_", "want_", ",_", "got_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "want", "\\u", "json_", "=_", "simplejson_", "._", "loads_", "(_", "want_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "got", "\\u", "json_", "=_", "simplejson_", "._", "loads_", "(_", "got_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "want", "\\u", "json_", "==_", "got", "\\u", "json_", "\\u\\u\\uNEWLINE\\u\\u\\u_" ]
[ 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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 2, 2, 2, 2, 2, 2, 2, 2, 0, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 ]
Unused import
jambonrose/DjangoUnleashed-1.8/core/templatetags/display_form.py
[ { "content": "from django.core.exceptions import \\\n ImproperlyConfigured\nfrom django.core.urlresolvers import reverse\nfrom django.template import (\n Library, TemplateSyntaxError)\n\n# https://docs.djangoproject.com/en/1.8/howto/custom-template-tags/\nregister = Library()\n\n\n\n\n", "metadata": "root", "header": "['module', '___EOS___']", "index": 0 }, { "content": "@register.inclusion_tag(\n 'core/includes/form.html',\n takes_context=True)\ndef form(context, *args, **kwargs):\n action = (args[0] if len(args) > 0\n else kwargs.get('action'))\n button = (args[1] if len(args) > 1\n else kwargs.get('button'))\n method = (args[2] if len(args) > 2\n else kwargs.get('method'))\n form = context.get('form')\n if action is None:\n raise TemplateSyntaxError(\n \"form template tag requires \"\n \"at least one argument: action, \"\n \"which is a URL.\")\n return {\n 'action': action,\n 'button': button,\n 'form': form,\n 'method': method}", "metadata": "root.form", "header": "['module', '___EOS___']", "index": 10 }, { "content": "@register.inclusion_tag(\n 'core/includes/confirm_delete_form.html',\n takes_context=True)\ndef delete_form(context, *args, **kwargs):\n action = (args[0] if len(args) > 0\n else kwargs.get('action'))\n method = (args[1] if len(args) > 1\n else kwargs.get('method'))\n form = context.get('form')\n display_object = kwargs.get(\n 'object', context.get('object'))\n if action is None:\n raise TemplateSyntaxError(\n \"delete_form template tag \"\n \"requires at least one argument: \"\n \"action, which is a URL.\")\n if display_object is None:\n raise TemplateSyntaxError(\n \"display_form needs object \"\n \"manually specified in this case.\")\n if hasattr(display_object, 'name'):\n obj_title = display_object.name\n elif hasattr(display_object, 'title'):\n obj_title = display_object.title.title()\n else:\n obj_title = str(display_object)\n obj_type = kwargs.get(\n 'obj_type',\n display_object._meta.verbose_name.title())\n return {\n 'action': action,\n 'form': form,\n 'method': method,\n 'object': display_object,\n 'obj_title': obj_title,\n 'obj_type': obj_type}", "metadata": "root.delete_form", "header": "['module', '___EOS___']", "index": 33 } ]
[ { "span": "from django.core.exceptions import \\\n ImproperlyConfigured", "start_line": 0, "start_column": 0, "end_line": 1, "end_column": 24 }, { "span": "from django.core.urlresolvers import reverse", "start_line": 2, "start_column": 0, "end_line": 2, "end_column": 44 } ]
[]
1
false
[ "[CLS]_", "Un", "used_", "import_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "from_", "django_", "._", "core_", "._", "exceptions_", "import_", "Impro", "perl", "y", "Configured_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "django_", "._", "core_", "._", "urlresolvers_", "import_", "reverse_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "django_", "._", "template_", "import_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "Library_", ",_", "Templa", "te", "Syntax", "Error_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "https", "://", "docs", ".", "django", "project", ".", "com", "/", "en", "/", "1.8", "/", "how", "to", "/", "custom", "-", "template", "-", "tags", "/_", "\\u\\u\\uNL\\u\\u\\u_", "register_", "=_", "Library_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "@_", "register_", "._", "inclusion", "\\u", "tag_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "'", "core", "/", "include", "s", "/", "form", ".", "html", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "take", "s", "\\u", "context_", "=_", "True_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "form_", "(_", "context_", ",_", "*_", "args_", ",_", "**_", "kwargs_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "action_", "=_", "(_", "args_", "[_", "0_", "]_", "if_", "len_", "(_", "args_", ")_", ">_", "0_", "\\u\\u\\uNL\\u\\u\\u_", "else_", "kwargs_", "._", "get_", "(_", "'", "action", "'_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "button_", "=_", "(_", "args_", "[_", "1_", "]_", "if_", "len_", "(_", "args_", ")_", ">_", "1_", "\\u\\u\\uNL\\u\\u\\u_", "else_", "kwargs_", "._", "get_", "(_", "'", "button", "'_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "method_", "=_", "(_", "args_", "[_", "2_", "]_", "if_", "len_", "(_", "args_", ")_", ">_", "2_", "\\u\\u\\uNL\\u\\u\\u_", "else_", "kwargs_", "._", "get_", "(_", "'", "method", "'_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "form_", "=_", "context_", "._", "get_", "(_", "'", "form", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "action_", "is_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "raise_", "Templa", "te", "Syntax", "Error_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "form", " ", "template", " ", "tag", " ", "require", "s", " ", "\"_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "at", " ", "leas", "t", " ", "one", " ", "argu", "ment", ":", " ", "action", ",", " ", "\"_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "whi", "ch", " ", "is", " ", "a", " ", "URL", ".\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "'", "action", "'_", ":_", "action_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "button", "'_", ":_", "button_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "form", "'_", ":_", "form_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "method", "'_", ":_", "method_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "@_", "register_", "._", "inclusion", "\\u", "tag_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "'", "core", "/", "include", "s", "/", "confirm", "\\u", "delete", "\\u", "form", ".", "html", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "take", "s", "\\u", "context_", "=_", "True_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "delete", "\\u", "form_", "(_", "context_", ",_", "*_", "args_", ",_", "**_", "kwargs_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "action_", "=_", "(_", "args_", "[_", "0_", "]_", "if_", "len_", "(_", "args_", ")_", ">_", "0_", "\\u\\u\\uNL\\u\\u\\u_", "else_", "kwargs_", "._", "get_", "(_", "'", "action", "'_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "method_", "=_", "(_", "args_", "[_", "1_", "]_", "if_", "len_", "(_", "args_", ")_", ">_", "1_", "\\u\\u\\uNL\\u\\u\\u_", "else_", "kwargs_", "._", "get_", "(_", "'", "method", "'_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "form_", "=_", "context_", "._", "get_", "(_", "'", "form", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "display", "\\u", "object_", "=_", "kwargs_", "._", "get_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "'", "object", "'_", ",_", "context_", "._", "get_", "(_", "'", "object", "'_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "action_", "is_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "raise_", "Templa", "te", "Syntax", "Error_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "delete", "\\u", "form", " ", "template", " ", "tag", " ", "\"_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "require", "s", " ", "at", " ", "leas", "t", " ", "one", " ", "argu", "ment", ":", " ", "\"_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "action", ",", " ", "whi", "ch", " ", "is", " ", "a", " ", "URL", ".\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "display", "\\u", "object_", "is_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "raise_", "Templa", "te", "Syntax", "Error_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "display", "\\u", "form", " ", "need", "s", " ", "object", " ", "\"_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "manu", "ally", " ", "specified", " ", "in", " ", "this", " ", "case", ".\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "hasattr_", "(_", "display", "\\u", "object_", ",_", "'", "name", "'_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "obj", "\\u", "title_", "=_", "display", "\\u", "object_", "._", "name_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "hasattr_", "(_", "display", "\\u", "object_", ",_", "'", "title", "'_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "obj", "\\u", "title_", "=_", "display", "\\u", "object_", "._", "title_", "._", "title_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "obj", "\\u", "title_", "=_", "str_", "(_", "display", "\\u", "object_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "obj", "\\u", "type_", "=_", "kwargs_", "._", "get_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "'", "obj", "\\u", "type", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "display", "\\u", "object_", "._", "\\u", "meta_", "._", "verbo", "se", "\\u", "name_", "._", "title_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "'", "action", "'_", ":_", "action_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "form", "'_", ":_", "form_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "method", "'_", ":_", "method_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "object", "'_", ":_", "display", "\\u", "object_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "obj", "\\u", "title", "'_", ":_", "obj", "\\u", "title_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "obj", "\\u", "type", "'_", ":_", "obj", "\\u", "type_", "}_" ]
[ 4, 4, 4, 4, 4, 2, 2, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 0, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2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 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 ]
Unused import
VisTrails/VisTrails/vistrails/gui/version_view.py
[ { "content": "###############################################################################\n##\n## Copyright (C) 2014-2016, New York University.\n## Copyright (C) 2011-2014, NYU-Poly.\n## Copyright (C) 2006-2011, University of Utah.\n## All rights reserved.\n## Contact: [email protected]\n##\n## This file is part of VisTrails.\n##\n## \"Redistribution and use in source and binary forms, with or without\n## modification, are permitted provided that the following conditions are met:\n##\n## - Redistributions of source code must retain the above copyright notice,\n## this list of conditions and the following disclaimer.\n## - Redistributions in binary form must reproduce the above copyright\n## notice, this list of conditions and the following disclaimer in the\n## documentation and/or other materials provided with the distribution.\n## - Neither the name of the New York University nor the names of its\n## contributors may be used to endorse or promote products derived from\n## this software without specific prior written permission.\n##\n## THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\"\n## AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,\n## THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\n## PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR\n## CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,\n## EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,\n## PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;\n## OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,\n## WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR\n## OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF\n## ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\"\n##\n###############################################################################\n\"\"\" This is a QGraphicsView for pipeline view, it also holds different\ntypes of graphics items that are only available in the pipeline\nview. It only handles GUI-related actions, the rest of the\nfunctionalities are implemented at somewhere else,\ne.g. core.vistrails\n\nQGraphicsLinkItem\nQGraphicsVersionTextItem\nQGraphicsVersionItem\nQVersionTreeScene\nQVersionTreeView\n\"\"\"\nfrom __future__ import division\n\nfrom PyQt4 import QtCore, QtGui\nfrom vistrails.core.configuration import get_vistrails_configuration\nfrom vistrails.core import debug\nfrom vistrails.core.system import systemType\nfrom vistrails.core.thumbnails import ThumbnailCache\nfrom vistrails.core.vistrail.controller import custom_color_key, \\\n parse_custom_color\nfrom vistrails.core.vistrail.vistrail import Vistrail\nfrom vistrails.gui.base_view import BaseView\nfrom vistrails.gui.graphics_view import (QInteractiveGraphicsScene,\n QInteractiveGraphicsView,\n QGraphicsItemInterface)\nfrom vistrails.gui.qt import qt_super\nfrom vistrails.gui.theme import CurrentTheme\nfrom vistrails.gui.version_prop import QVersionPropOverlay\nfrom vistrails.gui.collection.workspace import QParamExplorationEntityItem\nimport vistrails.gui.utils\n\n\n################################################################################\n# QGraphicsLinkItem\n\n\n\n##############################################################################\n# QGraphicsVerstionTextItem\n\n\n##############################################################################\n# QGraphicsVersionItem\n\n\n\n\n\n", "metadata": "root", "header": "['module', '___EOS___']", "index": 0 }, { "content": "class QGraphicsLinkItem(QGraphicsItemInterface, QtGui.QGraphicsPolygonItem):\n \"\"\"\n QGraphicsLinkItem is a connection shape connecting two versions\n \n \"\"\"\n\n\n\n\n\n", "metadata": "root.QGraphicsLinkItem", "header": "['module', '___EOS___']", "index": 71 }, { "content": " def __init__(self, parent=None, scene=None):\n \"\"\" QGraphicsLinkItem(parent: QGraphicsItem,\n scene: QGraphicsScene) -> QGraphicsLinkItem\n Create the shape, initialize its pen and brush accordingly\n \n \"\"\"\n QtGui.QGraphicsPolygonItem.__init__(self, parent, scene)\n self.setFlags(QtGui.QGraphicsItem.ItemIsSelectable)\n self.setZValue(0)\n self.linkPen = CurrentTheme.LINK_PEN\n self.ghosted = False\n \n # cache link endpoints to improve performance on scene updates\n self.c1 = None\n self.c2 = None\n self.expand = None\n self.collapse = None", "metadata": "root.QGraphicsLinkItem.__init__", "header": "['class', 'QGraphicsLinkItem', '(', 'QGraphicsItemInterface', ',', 'QtGui', '.', 'QGraphicsPolygonItem', ')', ':', '___EOS___']", "index": 76 }, { "content": " def mousePressEvent(self, event):\n \"\"\" mousePressEvent(event: QMouseEvent) -> None\n\n \"\"\"\n qt_super(QGraphicsLinkItem, self).mousePressEvent(event)\n self.setSelected(True)", "metadata": "root.QGraphicsLinkItem.mousePressEvent", "header": "['class', 'QGraphicsLinkItem', '(', 'QGraphicsItemInterface', ',', 'QtGui', '.', 'QGraphicsPolygonItem', ')', ':', '___EOS___']", "index": 94 }, { "content": " def mouseReleaseEvent(self, event):\n \"\"\" mouseReleaseEvent(event: QMouseEvent) -> None\n \n \"\"\"\n qt_super(QGraphicsLinkItem, self).mouseReleaseEvent(event)\n if self.expand:\n self.scene().controller.expand_versions(self.startVersion, self.endVersion)\n elif self.collapse:\n self.scene().controller.collapse_versions(self.endVersion)\n self.setSelected(False)", "metadata": "root.QGraphicsLinkItem.mouseReleaseEvent", "header": "['class', 'QGraphicsLinkItem', '(', 'QGraphicsItemInterface', ',', 'QtGui', '.', 'QGraphicsPolygonItem', ')', ':', '___EOS___']", "index": 101 }, { "content": " def setGhosted(self, ghosted):\n \"\"\" setGhosted(ghosted: True) -> None\n Set this link to be ghosted or not\n \n \"\"\"\n if self.ghosted <> ghosted:\n self.ghosted = ghosted\n if ghosted:\n self.linkPen = CurrentTheme.GHOSTED_LINK_PEN\n else:\n self.linkPen = CurrentTheme.LINK_PEN", "metadata": "root.QGraphicsLinkItem.setGhosted", "header": "['class', 'QGraphicsLinkItem', '(', 'QGraphicsItemInterface', ',', 'QtGui', '.', 'QGraphicsPolygonItem', ')', ':', '___EOS___']", "index": 112 }, { "content": " def setupLink(self, v1, v2, expand=False, collapse=False):\n \"\"\" setupLink(v1, v2: QGraphicsVersionItem, compact: bool) -> None\n Setup a line connecting v1 and v2 items\n \n \"\"\"\n self.startVersion = min(v1.id, v2.id)\n self.endVersion = max(v1.id, v2.id)\n \n c1 = v1.sceneBoundingRect().center()\n c2 = v2.sceneBoundingRect().center()\n\n # check if it is the same geometry \n # improves performance on updates\n if self.c1 is not None and self.c2 is not None and \\\n self.expand is not None and self.collapse !=None:\n isTheSame = self.c1 == c1 and \\\n self.c2 == c2 and \\\n self.expand == expand and \\\n self.collapse == collapse\n if isTheSame:\n return\n \n # update current state\n self.c1 = c1\n self.c2 = c2\n self.collapse = collapse\n self.expand = expand\n\n # Compute the line of the link and its normal line throught\n # the midpoint\n mainLine = QtCore.QLineF(c1, c2)\n normalLine = mainLine.normalVector() \n normalLine.setLength(CurrentTheme.LINK_SEGMENT_LENGTH)\n dis = (mainLine.pointAt(0.5)-mainLine.p1()+\n normalLine.p1()-normalLine.pointAt(0.5))\n normalLine.translate(dis.x(), dis.y())\n\n # Generate 2 segments along the main line and 3 segments along\n # the normal line\n if not self.collapse and not self.expand:\n self.lines = [mainLine]\n poly = QtGui.QPolygonF()\n poly.append(self.lines[0].p1())\n poly.append(self.lines[0].p2())\n poly.append(self.lines[0].p1())\n self.setPolygon(poly)\n else:\n self.lines = []\n \n normalLine = mainLine.normalVector() \n normalLine.setLength(CurrentTheme.LINK_SEGMENT_SQUARE_LENGTH)\n dis = (mainLine.pointAt(0.5)-mainLine.p1()+\n normalLine.p1()-normalLine.pointAt(0.5))\n normalLine.translate(dis.x(), dis.y())\n \n gapLine = QtCore.QLineF(mainLine)\n gapLine.setLength(CurrentTheme.LINK_SEGMENT_SQUARE_LENGTH/2)\n gapVector = gapLine.p2()-gapLine.p1()\n \n # First segment along the main line\n line = QtCore.QLineF(mainLine)\n line.setLength(line.length()/2-CurrentTheme.LINK_SEGMENT_SQUARE_LENGTH/2)\n self.lines.append(QtCore.QLineF(line))\n \n # Second segment along the main line\n line.translate(line.p2()-line.p1()+gapVector*2)\n self.lines.append(QtCore.QLineF(line))\n \n # First normal segment in front\n line_t = QtCore.QLineF(normalLine)\n line_t.translate(gapVector*(-1.0))\n self.lines.append(QtCore.QLineF(line_t))\n \n # Second normal segment in back\n line_b = QtCore.QLineF(normalLine)\n line_b.translate(gapVector)\n self.lines.append(QtCore.QLineF(line_b))\n \n # Left box\n line = QtCore.QLineF(line_t.p1(),line_b.p1())\n self.lines.append(QtCore.QLineF(line))\n \n # Right box\n line = QtCore.QLineF(line_t.p2(),line_b.p2())\n self.lines.append(QtCore.QLineF(line))\n\n # Horizontal plus\n line_h = QtCore.QLineF(normalLine.pointAt(0.2),normalLine.pointAt(0.8))\n self.lines.append(QtCore.QLineF(line_h))\n \n if self.expand:\n # Vertical plus\n line = QtCore.QLineF(mainLine)\n line.translate((line.p2()-line.p1())/2-gapVector)\n line.setLength(CurrentTheme.LINK_SEGMENT_SQUARE_LENGTH)\n line_v = QtCore.QLineF(line.pointAt(0.2), line.pointAt(0.8))\n self.lines.append(QtCore.QLineF(line_v))\n \n # Create the poly line for selection and redraw\n poly = QtGui.QPolygonF()\n poly.append(self.lines[0].p1())\n poly.append(self.lines[2].p1())\n poly.append(self.lines[3].p1())\n poly.append(self.lines[1].p2())\n poly.append(self.lines[3].p2())\n poly.append(self.lines[2].p2())\n poly.append(self.lines[0].p1())\n self.setPolygon(poly)\n\n self.setGhosted(v1.ghosted and v2.ghosted)", "metadata": "root.QGraphicsLinkItem.setupLink", "header": "['class', 'QGraphicsLinkItem', '(', 'QGraphicsItemInterface', ',', 'QtGui', '.', 'QGraphicsPolygonItem', ')', ':', '___EOS___']", "index": 124 }, { "content": " def paint(self, painter, option, widget=None):\n \"\"\" paint(painter: QPainter, option: QStyleOptionGraphicsItem,\n widget: QWidget) -> None\n Peform actual painting of the link\n \n \"\"\"\n if self.isSelected():\n painter.setPen(CurrentTheme.LINK_SELECTED_PEN)\n else:\n painter.setPen(self.linkPen)\n for line in self.lines:\n painter.drawLine(line)", "metadata": "root.QGraphicsLinkItem.paint", "header": "['class', 'QGraphicsLinkItem', '(', 'QGraphicsItemInterface', ',', 'QtGui', '.', 'QGraphicsPolygonItem', ')', ':', '___EOS___']", "index": 235 }, { "content": " def itemChange(self, change, value):\n \"\"\" itemChange(change: GraphicsItemChange, value: variant) -> variant\n Do not allow link to be selected with version shape\n \n \"\"\"\n if change==QtGui.QGraphicsItem.ItemSelectedChange and value:\n return False\n return QtGui.QGraphicsPolygonItem.itemChange(self, change, value)", "metadata": "root.QGraphicsLinkItem.itemChange", "header": "['class', 'QGraphicsLinkItem', '(', 'QGraphicsItemInterface', ',', 'QtGui', '.', 'QGraphicsPolygonItem', ')', ':', '___EOS___']", "index": 248 }, { "content": "class QGraphicsVersionTextItem(QGraphicsItemInterface, QtGui.QGraphicsTextItem):\n \"\"\"\n QGraphicsVersionTextItem is an editable text item that appears on top of\n a QGraphicsVersionItem to allow the tag to be changed\n\n \"\"\"\n\n\n\n\n\n\n\n", "metadata": "root.QGraphicsVersionTextItem", "header": "['module', '___EOS___']", "index": 261 }, { "content": " def __init__(self, parent=None, scene=None):\n \"\"\" QGraphicsVersionTextItem(parent: QGraphicsVersionItem, \n scene: QGraphicsScene) -> QGraphicsVersionTextItem\n\n Create the shape, intialize its drawing style\n\n \"\"\"\n QtGui.QGraphicsTextItem.__init__(self, parent, scene)\n self.timer = None\n self.isEditable = None\n self.setEditable(False)\n self.setFont(CurrentTheme.VERSION_FONT)\n self.setTextWidth(CurrentTheme.VERSION_LABEL_MARGIN[0])\n self.setDefaultTextColor(CurrentTheme.VERSION_LABEL_COLOR)\n self.centerX = 0.0\n self.centerY = 0.0\n self.label = ''\n self.isTag = True\n self.updatingTag = False", "metadata": "root.QGraphicsVersionTextItem.__init__", "header": "['class', 'QGraphicsVersionTextItem', '(', 'QGraphicsItemInterface', ',', 'QtGui', '.', 'QGraphicsTextItem', ')', ':', '___EOS___']", "index": 267 }, { "content": " def setEditable(self, editable=True):\n if self.timer:\n self.timer.stop()\n self.timer = None\n if editable == self.isEditable:\n return\n self.isEditable = editable\n if editable:\n self.setTextInteractionFlags(QtCore.Qt.TextEditorInteraction)\n else:\n if self.textCursor():\n c = self.textCursor()\n c.clearSelection()\n self.setTextCursor(c)\n self.setTextInteractionFlags(QtCore.Qt.NoTextInteraction)", "metadata": "root.QGraphicsVersionTextItem.setEditable", "header": "['class', 'QGraphicsVersionTextItem', '(', 'QGraphicsItemInterface', ',', 'QtGui', '.', 'QGraphicsTextItem', ')', ':', '___EOS___']", "index": 287 }, { "content": " def setEditableLater(self):\n self.timer = QtCore.QTimer(self)\n self.timer.setSingleShot(True)\n self.connect(self.timer, QtCore.SIGNAL(\"timeout()\"), self.setEditable)\n self.timer.start(QtGui.QApplication.doubleClickInterval() + 5)", "metadata": "root.QGraphicsVersionTextItem.setEditableLater", "header": "['class', 'QGraphicsVersionTextItem', '(', 'QGraphicsItemInterface', ',', 'QtGui', '.', 'QGraphicsTextItem', ')', ':', '___EOS___']", "index": 303 }, { "content": " def setGhosted(self, ghosted):\n if ghosted:\n self.setDefaultTextColor(CurrentTheme.GHOSTED_VERSION_LABEL_COLOR)\n else:\n self.setDefaultTextColor(CurrentTheme.VERSION_LABEL_COLOR)", "metadata": "root.QGraphicsVersionTextItem.setGhosted", "header": "['class', 'QGraphicsVersionTextItem', '(', 'QGraphicsItemInterface', ',', 'QtGui', '.', 'QGraphicsTextItem', ')', ':', '___EOS___']", "index": 309 }, { "content": " def changed(self, x, y, label, tag=True):\n \"\"\" changed(x: float, y: float, label: str) -> None\n Change the position and text label from outside the editor\n\n \"\"\"\n if self.centerX <> x or self.centerY <> y or self.label <> label:\n self.centerX = x\n self.centerY = y\n self.label = label\n self.isTag = tag\n if self.isTag:\n self.setFont(CurrentTheme.VERSION_FONT)\n else:\n self.setFont(CurrentTheme.VERSION_DESCRIPTION_FONT)\n self.reset()", "metadata": "root.QGraphicsVersionTextItem.changed", "header": "['class', 'QGraphicsVersionTextItem', '(', 'QGraphicsItemInterface', ',', 'QtGui', '.', 'QGraphicsTextItem', ')', ':', '___EOS___']", "index": 315 }, { "content": " def reset(self):\n \"\"\" reset() -> None\n Resets the text label, width, and positions to the stored values\n\n \"\"\"\n self.setPlainText(self.label)\n self.setEditable(False)\n if (len(str(self.label)) > 0):\n self.setTextWidth(-1)\n else:\n self.setTextWidth(CurrentTheme.VERSION_LABEL_MARGIN[0])\n \n if self.isTag:\n self.setFont(CurrentTheme.VERSION_FONT)\n else:\n self.setFont(CurrentTheme.VERSION_DESCRIPTION_FONT) \n self.updatePos()\n self.parentItem().updateWidthFromLabel()", "metadata": "root.QGraphicsVersionTextItem.reset", "header": "['class', 'QGraphicsVersionTextItem', '(', 'QGraphicsItemInterface', ',', 'QtGui', '.', 'QGraphicsTextItem', ')', ':', '___EOS___']", "index": 331 }, { "content": " def updatePos(self):\n \"\"\" updatePos() -> None\n Center the text, by default it uses the upper left corner\n \n \"\"\"\n self.setPos(self.centerX-self.boundingRect().width()/2.0,\n self.centerY-self.boundingRect().height()/2.0)", "metadata": "root.QGraphicsVersionTextItem.updatePos", "header": "['class', 'QGraphicsVersionTextItem', '(', 'QGraphicsItemInterface', ',', 'QtGui', '.', 'QGraphicsTextItem', ')', ':', '___EOS___']", "index": 350 }, { "content": " def keyPressEvent(self, event):\n \"\"\" keyPressEvent(event: QEvent) -> None\n Enter and Return keys signal a change in the label. Other keys\n update the position and size of the parent ellipse during key entry.\n\n \"\"\"\n if event.key() in [QtCore.Qt.Key_Enter, QtCore.Qt.Key_Return]:\n self.updatingTag = True\n if (self.label == str(self.toPlainText()) or\n not self.scene().controller.update_current_tag(str(self.toPlainText()))):\n self.reset()\n self.updatingTag = False\n event.ignore()\n self.clearFocus()\n return\n qt_super(QGraphicsVersionTextItem, self).keyPressEvent(event)\n if (len(str(self.toPlainText())) > 0):\n self.setTextWidth(-1)\n self.updatePos()\n self.parentItem().updateWidthFromLabel()", "metadata": "root.QGraphicsVersionTextItem.keyPressEvent", "header": "['class', 'QGraphicsVersionTextItem', '(', 'QGraphicsItemInterface', ',', 'QtGui', '.', 'QGraphicsTextItem', ')', ':', '___EOS___']", "index": 358 }, { "content": " def focusOutEvent(self, event):\n \"\"\" focusOutEvent(event: QEvent) -> None\n Update the tag if the text has changed\n\n \"\"\"\n qt_super(QGraphicsVersionTextItem, self).focusOutEvent(event)\n if not self.updatingTag and self.label != self.toPlainText():\n self.updatingTag = True\n if (self.label == str(self.toPlainText()) or \n not self.scene().controller.update_current_tag(str(self.toPlainText()))):\n self.reset()\n self.updatingTag = False", "metadata": "root.QGraphicsVersionTextItem.focusOutEvent", "header": "['class', 'QGraphicsVersionTextItem', '(', 'QGraphicsItemInterface', ',', 'QtGui', '.', 'QGraphicsTextItem', ')', ':', '___EOS___']", "index": 379 }, { "content": "class QGraphicsVersionItem(QGraphicsItemInterface, QtGui.QGraphicsEllipseItem):\n \"\"\"\n QGraphicsVersionItem is the version shape holding version id and\n label\n \n \"\"\"\n\n versionPen = property(_get_versionPen, _set_versionPen)\n\n versionBrush = property(_get_versionBrush, _set_versionBrush)\n\n\n\n\n \n\n\n\n\n\n \n\n\n\n\n\n\n \n\n", "metadata": "root.QGraphicsVersionItem", "header": "['module', '___EOS___']", "index": 396 }, { "content": " def __init__(self, parent=None, scene=None):\n \"\"\" QGraphicsVersionItem(parent: QGraphicsItem, scene: QGraphicsScene)\n -> QGraphicsVersionItem\n Create the shape, initialize its pen and brush accordingly\n \n \"\"\"\n QtGui.QGraphicsEllipseItem.__init__(self, parent, scene)\n self.setZValue(1)\n self.setAcceptDrops(True)\n self.setFlags(QtGui.QGraphicsItem.ItemIsSelectable)\n self._versionPenNormal = CurrentTheme.VERSION_PEN\n self._versionPen = CurrentTheme.VERSION_PEN\n self._versionBrush = CurrentTheme.VERSION_USER_BRUSH\n self.id = -1\n self.label = ''\n self.descriptionLabel = ''\n self.dragging = False\n self.ghosted = False\n self.updatePainterState()\n\n # self.rank is a positive number that determines the\n # saturation of the node. Two version nodes might have the\n # same rank if they were created by different users\n # self.max_rank is the maximum rank for that version class\n self.rank = -1\n self.max_rank = -1\n \n # Editable text item that remains hidden unless the version is selected\n self.text = QGraphicsVersionTextItem(self)\n\n # Need a timer to start a drag to avoid stalls on QGraphicsView\n self.dragTimer = QtCore.QTimer()\n self.dragTimer.setSingleShot(True)\n self.dragTimer.connect(self.dragTimer,\n QtCore.SIGNAL('timeout()'),\n self.startDrag)\n\n self.dragPos = QtCore.QPoint()", "metadata": "root.QGraphicsVersionItem.__init__", "header": "['class', 'QGraphicsVersionItem', '(', 'QGraphicsItemInterface', ',', 'QtGui', '.', 'QGraphicsEllipseItem', ')', ':', '___EOS___']", "index": 402 }, { "content": " def _get_versionPen(self):\n return self._versionPen", "metadata": "root.QGraphicsVersionItem._get_versionPen", "header": "['class', 'QGraphicsVersionItem', '(', 'QGraphicsItemInterface', ',', 'QtGui', '.', 'QGraphicsEllipseItem', ')', ':', '___EOS___']", "index": 441 }, { "content": " def _set_versionPen(self, pen):\n self._versionPen = pen\n self.updatePainterState()", "metadata": "root.QGraphicsVersionItem._set_versionPen", "header": "['class', 'QGraphicsVersionItem', '(', 'QGraphicsItemInterface', ',', 'QtGui', '.', 'QGraphicsEllipseItem', ')', ':', '___EOS___']", "index": 443 }, { "content": " def _get_versionBrush(self):\n return self._versionBrush", "metadata": "root.QGraphicsVersionItem._get_versionBrush", "header": "['class', 'QGraphicsVersionItem', '(', 'QGraphicsItemInterface', ',', 'QtGui', '.', 'QGraphicsEllipseItem', ')', ':', '___EOS___']", "index": 448 }, { "content": " def _set_versionBrush(self, brush):\n self._versionBrush = brush\n self.updatePainterState()", "metadata": "root.QGraphicsVersionItem._set_versionBrush", "header": "['class', 'QGraphicsVersionItem', '(', 'QGraphicsItemInterface', ',', 'QtGui', '.', 'QGraphicsEllipseItem', ')', ':', '___EOS___']", "index": 450 }, { "content": " def itemChange(self, change, value):\n if change == QtGui.QGraphicsItem.ItemSelectedHasChanged:\n if self.isSelected():\n self.versionPen = CurrentTheme.VERSION_SELECTED_PEN\n self.text.setEditableLater()\n else:\n self.versionPen = self._versionPenNormal\n self.text.setEditable(False)\n self.updatePainterState()\n return QtGui.QGraphicsItem.itemChange(self, change, value)", "metadata": "root.QGraphicsVersionItem.itemChange", "header": "['class', 'QGraphicsVersionItem', '(', 'QGraphicsItemInterface', ',', 'QtGui', '.', 'QGraphicsEllipseItem', ')', ':', '___EOS___']", "index": 455 }, { "content": " def setGhosted(self, ghosted=True):\n \"\"\" setGhosted(ghosted: True) -> None\n Set this version to be ghosted or not\n \n \"\"\"\n if self.ghosted <> ghosted:\n self.ghosted = ghosted\n self.text.setGhosted(ghosted)\n if ghosted:\n self._versionPenNormal = CurrentTheme.GHOSTED_VERSION_PEN\n self._versionBrush = CurrentTheme.GHOSTED_VERSION_USER_BRUSH\n else:\n self._versionPenNormal = CurrentTheme.VERSION_PEN\n self._versionBrush = CurrentTheme.VERSION_USER_BRUSH\n if not self.isSelected():\n self._versionPen = self._versionPenNormal\n self.updatePainterState()", "metadata": "root.QGraphicsVersionItem.setGhosted", "header": "['class', 'QGraphicsVersionItem', '(', 'QGraphicsItemInterface', ',', 'QtGui', '.', 'QGraphicsEllipseItem', ')', ':', '___EOS___']", "index": 466 }, { "content": " def update_color(self, isThisUs, new_rank, new_max_rank, new_ghosted,\n new_customcolor):\n \"\"\" update_color(isThisUs: bool,\n new_rank, new_max_rank: int) -> None\n\n If necessary, update the colors of this version node based on\n who owns the node and new ranks\n\n NOTE: if username changes during execution, this might break.\n \"\"\"\n if (new_rank == self.rank and new_max_rank == self.max_rank and\n new_ghosted == self.ghosted and\n new_customcolor == self.custom_color):\n # nothing changed\n return\n self.setGhosted(new_ghosted)\n self.custom_color = new_customcolor\n self.rank = new_rank\n self.max_rank = new_max_rank\n if not self.ghosted:\n if self.custom_color is not None:\n configuration = get_vistrails_configuration()\n sat_from_rank = not configuration.check(\n 'fixedCustomVersionColorSaturation')\n brush = QtGui.QBrush(QtGui.QColor.fromRgb(*self.custom_color))\n else:\n if isThisUs:\n brush = CurrentTheme.VERSION_USER_BRUSH\n else:\n brush = CurrentTheme.VERSION_OTHER_BRUSH\n sat_from_rank = True\n if sat_from_rank:\n sat = float(new_rank+1) / new_max_rank\n (h, s, v, a) = brush.color().getHsvF()\n newHsv = (h, s*sat, v+(1.0-v)*(1-sat), a)\n brush = QtGui.QBrush(brush)\n brush.setColor(QtGui.QColor.fromHsvF(*newHsv))\n self.versionBrush = brush\n self.update()", "metadata": "root.QGraphicsVersionItem.update_color", "header": "['class', 'QGraphicsVersionItem', '(', 'QGraphicsItemInterface', ',', 'QtGui', '.', 'QGraphicsEllipseItem', ')', ':', '___EOS___']", "index": 484 }, { "content": " def setSaturation(self, isThisUser, sat):\n \"\"\" setSaturation(isThisUser: bool, sat: float) -> None \n Set the color of this version depending on whose is the user\n and its saturation\n \n \"\"\"\n if not self.ghosted:\n if isThisUser:\n brush = CurrentTheme.VERSION_USER_BRUSH\n else:\n brush = CurrentTheme.VERSION_OTHER_BRUSH\n\n (h, s, v, a) = brush.color().getHsvF()\n newHsv = (h, s*sat, v+(1.0-v)*(1-sat), a)\n self.versionBrush = QtGui.QBrush(QtGui.QColor.fromHsvF(*newHsv))", "metadata": "root.QGraphicsVersionItem.setSaturation", "header": "['class', 'QGraphicsVersionItem', '(', 'QGraphicsItemInterface', ',', 'QtGui', '.', 'QGraphicsEllipseItem', ')', ':', '___EOS___']", "index": 524 }, { "content": " def updateWidthFromLabel(self):\n \"\"\" updateWidthFromLabel() -> None\n Change the width of the ellipse based on a temporary change in the label\n\n \"\"\"\n prevWidth = self.rect().width()\n width = self.text.boundingRect().width() + \\\n CurrentTheme.VERSION_LABEL_MARGIN[0] - 4\n r = self.rect()\n r.setX(r.x()+(prevWidth-width)/2.0)\n r.setWidth(width)\n self.setRect(r)\n self.update()", "metadata": "root.QGraphicsVersionItem.updateWidthFromLabel", "header": "['class', 'QGraphicsVersionItem', '(', 'QGraphicsItemInterface', ',', 'QtGui', '.', 'QGraphicsEllipseItem', ')', ':', '___EOS___']", "index": 540 }, { "content": " def setupVersion(self, node, action, tag, description):\n \"\"\" setupPort(node: DotNode,\n action: DBAction,\n tag: str,\n description: str) -> None\n Update the version dimensions and id\n \n \"\"\"\n # Lauro:\n # what was this hacking??? the coordinates inside\n # the input \"node\" should come to this point ready. This is\n # not the point to do layout calculations (e.g. -node.p.y/2)\n\n # Carlos:\n # This is not layout as much as dealing with the way Qt\n # specifies rectangles. Besides, moving this back here reduces\n # code duplication, and allows customized behavior for\n # subclasses.\n\n rect = QtCore.QRectF(node.p.x-node.width/2.0,\n node.p.y-node.height/2.0,\n node.width,\n node.height)\n validLabel = True\n if tag is None:\n label = ''\n validLabel=False\n else:\n label = tag\n\n self.id = node.id\n self.label = label\n if description is None:\n self.descriptionLabel = ''\n else:\n self.descriptionLabel = description\n if validLabel:\n textToDraw=self.label\n else:\n textToDraw=self.descriptionLabel\n\n if (ThumbnailCache.getInstance().conf.mouseHover and\n action and action.thumbnail is not None):\n fname = ThumbnailCache.getInstance().get_abs_name_entry(action.thumbnail)\n self.setToolTip('<img src=\"%s\" height=\"128\" border=\"1\"/>'%fname)\n else:\n self.setToolTip('') \n self.text.changed(node.p.x, node.p.y, textToDraw, validLabel)\n self.setRect(rect)", "metadata": "root.QGraphicsVersionItem.setupVersion", "header": "['class', 'QGraphicsVersionItem', '(', 'QGraphicsItemInterface', ',', 'QtGui', '.', 'QGraphicsEllipseItem', ')', ':', '___EOS___']", "index": 554 }, { "content": " def boundingRect(self):\n \"\"\" boundingRect() -> QRectF\n Add a padded space to avoid un-updated area\n \"\"\"\n return self.rect().adjusted(-2, -2, 2, 2)", "metadata": "root.QGraphicsVersionItem.boundingRect", "header": "['class', 'QGraphicsVersionItem', '(', 'QGraphicsItemInterface', ',', 'QtGui', '.', 'QGraphicsEllipseItem', ')', ':', '___EOS___']", "index": 604 }, { "content": " def paint(self, painter, option, widget=None):\n option.state &= ~QtGui.QStyle.State_Selected\n QtGui.QGraphicsEllipseItem.paint(self, painter, option, widget)", "metadata": "root.QGraphicsVersionItem.paint", "header": "['class', 'QGraphicsVersionItem', '(', 'QGraphicsItemInterface', ',', 'QtGui', '.', 'QGraphicsEllipseItem', ')', ':', '___EOS___']", "index": 610 }, { "content": " def updatePainterState(self):\n self.setPen(self._versionPen)\n self.setBrush(self._versionBrush)", "metadata": "root.QGraphicsVersionItem.updatePainterState", "header": "['class', 'QGraphicsVersionItem', '(', 'QGraphicsItemInterface', ',', 'QtGui', '.', 'QGraphicsEllipseItem', ')', ':', '___EOS___']", "index": 614 }, { "content": " def mousePressEvent(self, event):\n \"\"\" mousePressEvent(event: QMouseEvent) -> None\n Start dragging a version to someplaces...\n \n \"\"\"\n if event.button()==QtCore.Qt.LeftButton:\n self.dragging = True\n self.dragPos = QtCore.QPoint(event.screenPos())\n return QtGui.QGraphicsEllipseItem.mousePressEvent(self, event)", "metadata": "root.QGraphicsVersionItem.mousePressEvent", "header": "['class', 'QGraphicsVersionItem', '(', 'QGraphicsItemInterface', ',', 'QtGui', '.', 'QGraphicsEllipseItem', ')', ':', '___EOS___']", "index": 618 }, { "content": " def mouseMoveEvent(self, event):\n \"\"\" mouseMoveEvent(event: QMouseEvent) -> None \n Now set the timer preparing for dragging. Must use a timer in\n junction with QDrag in order to avoid problem updates stall of\n QGraphicsView, especially on Linux\n \n \"\"\"\n if (self.dragging and\n (event.screenPos()-self.dragPos).manhattanLength()>2):\n self.dragging = False\n #the timer has undesirable effects on Windows\n if systemType not in ['Windows', 'Microsoft']:\n self.dragTimer.start(1)\n else:\n self.startDrag()\n QtGui.QGraphicsEllipseItem.mouseMoveEvent(self, event)\n # super(QGraphicsVersionItem, self).mouseMoveEvent(event)", "metadata": "root.QGraphicsVersionItem.mouseMoveEvent", "header": "['class', 'QGraphicsVersionItem', '(', 'QGraphicsItemInterface', ',', 'QtGui', '.', 'QGraphicsEllipseItem', ')', ':', '___EOS___']", "index": 628 }, { "content": " def startDrag(self):\n \"\"\" startDrag() -> None\n Start the drag of QDrag\n \n \"\"\"\n data = QtCore.QMimeData()\n data.versionId = self.id\n data.controller = self.scene().controller\n drag = QtGui.QDrag(self.scene().views()[0])\n drag.setMimeData(data)\n drag.setPixmap(CurrentTheme.VERSION_DRAG_PIXMAP)\n drag.start()", "metadata": "root.QGraphicsVersionItem.startDrag", "header": "['class', 'QGraphicsVersionItem', '(', 'QGraphicsItemInterface', ',', 'QtGui', '.', 'QGraphicsEllipseItem', ')', ':', '___EOS___']", "index": 646 }, { "content": " def mouseReleaseEvent(self, event):\n \"\"\" mouseReleaseEvent(event: QMouseEvent) -> None\n Cancel the drag\n \n \"\"\"\n self.dragging = False\n QtGui.QGraphicsEllipseItem.mouseReleaseEvent(self, event)", "metadata": "root.QGraphicsVersionItem.mouseReleaseEvent", "header": "['class', 'QGraphicsVersionItem', '(', 'QGraphicsItemInterface', ',', 'QtGui', '.', 'QGraphicsEllipseItem', ')', ':', '___EOS___']", "index": 659 }, { "content": " def dragEnterEvent(self, event):\n \"\"\" dragEnterEvent(event: QDragEnterEvent) -> None\n Capture version-to-version drag-and-drop\n Also capture parameter exploration assignment\n \"\"\"\n data = event.mimeData()\n if (hasattr(data, 'versionId') and\n hasattr(data, 'controller') and\n data.versionId!=self.id) or \\\n (hasattr(data, 'items') and \n len(data.items) == 1 and\n isinstance(data.items[0], QParamExplorationEntityItem)):\n event.accept()\n else:\n event.ignore()", "metadata": "root.QGraphicsVersionItem.dragEnterEvent", "header": "['class', 'QGraphicsVersionItem', '(', 'QGraphicsItemInterface', ',', 'QtGui', '.', 'QGraphicsEllipseItem', ')', ':', '___EOS___']", "index": 667 }, { "content": " def dropEvent(self, event):\n data = event.mimeData()\n if (hasattr(data, 'versionId') and hasattr(data, 'controller') and\n data.controller==self.scene().controller):\n event.accept()\n self.scene().emit(QtCore.SIGNAL('diffRequested(int,int)'),\n data.versionId, self.id)\n # visDiff = QVisualDiff(self.scene().controller.vistrail,\n # data.versionId,\n # self.id,\n # self.scene().controller,\n # self.scene().views()[0])\n # visDiff.show()\n elif (hasattr(data, 'items') and \n len(data.items) == 1 and\n isinstance(data.items[0], QParamExplorationEntityItem)):\n # apply this parameter exploration to the new version, validate it and switch to PE view\n from vistrails.gui.vistrails_window import _app\n view = _app.get_current_view()\n view.apply_parameter_exploration(self.id, data.items[0].entity.pe)\n event.accept()\n else:\n event.ignore() ", "metadata": "root.QGraphicsVersionItem.dropEvent", "header": "['class', 'QGraphicsVersionItem', '(', 'QGraphicsItemInterface', ',', 'QtGui', '.', 'QGraphicsEllipseItem', ')', ':', '___EOS___']", "index": 683 }, { "content": " def perform_analogy(self):\n sender = self.scene().sender()\n analogy_name = str(sender.text())\n # selectedItems = self.scene().selectedItems()\n controller = self.scene().controller\n print \"calling perform analogy\", analogy_name, self.id\n # for item in selectedItems:\n controller.perform_analogy(analogy_name, self.id)", "metadata": "root.QGraphicsVersionItem.perform_analogy", "header": "['class', 'QGraphicsVersionItem', '(', 'QGraphicsItemInterface', ',', 'QtGui', '.', 'QGraphicsEllipseItem', ')', ':', '___EOS___']", "index": 707 }, { "content": " def show_raw_pipeline(self):\n self.scene().emit_selection = False\n for item in self.scene().selectedItems():\n item.setSelected(False)\n self.setSelected(True)\n self.scene().emit_selection = True\n self.scene().emit(\n QtCore.SIGNAL('versionSelected(int,bool,bool,bool,bool)'),\n self.id, True, False, True, True)", "metadata": "root.QGraphicsVersionItem.show_raw_pipeline", "header": "['class', 'QGraphicsVersionItem', '(', 'QGraphicsItemInterface', ',', 'QtGui', '.', 'QGraphicsEllipseItem', ')', ':', '___EOS___']", "index": 716 }, { "content": " def construct_from_root(self):\n self.scene().emit_selection = False\n for item in self.scene().selectedItems():\n item.setSelected(False)\n self.setSelected(True)\n self.scene().emit_selection = True\n self.scene().emit(\n QtCore.SIGNAL('versionSelected(int,bool,bool,bool,bool)'),\n self.id, True, True, True, True)", "metadata": "root.QGraphicsVersionItem.construct_from_root", "header": "['class', 'QGraphicsVersionItem', '(', 'QGraphicsItemInterface', ',', 'QtGui', '.', 'QGraphicsEllipseItem', ')', ':', '___EOS___']", "index": 726 }, { "content": " def contextMenuEvent(self, event):\n \"\"\"contextMenuEvent(event: QGraphicsSceneContextMenuEvent) -> None\n Captures context menu event.\n\n \"\"\"\n controller = self.scene().controller\n menu = QtGui.QMenu()\n raw_action = QtGui.QAction(\"Display raw pipeline\", self.scene())\n from_root_action = QtGui.QAction(\"Construct from root\", self.scene())\n QtCore.QObject.connect(raw_action,\n QtCore.SIGNAL(\"triggered()\"),\n self.show_raw_pipeline)\n QtCore.QObject.connect(from_root_action,\n QtCore.SIGNAL(\"triggered()\"),\n self.construct_from_root)\n menu.addAction(raw_action)\n menu.addAction(from_root_action)\n if len(controller.analogy) > 0:\n analogies = QtGui.QMenu(\"Perform analogy...\")\n for title in sorted(controller.analogy.keys()):\n act = QtGui.QAction(title, self.scene())\n analogies.addAction(act)\n QtCore.QObject.connect(act,\n QtCore.SIGNAL(\"triggered()\"),\n self.perform_analogy)\n menu.addMenu(analogies)\n menu.exec_(event.screenPos())", "metadata": "root.QGraphicsVersionItem.contextMenuEvent", "header": "['class', 'QGraphicsVersionItem', '(', 'QGraphicsItemInterface', ',', 'QtGui', '.', 'QGraphicsEllipseItem', ')', ':', '___EOS___']", "index": 736 }, { "content": " def mouseDoubleClickEvent(self, event):\n # QtGui.QGraphicsEllipseItem.mouseDoubleClickEvent(self, event)\n event.accept()\n self.scene().double_click(self.id)", "metadata": "root.QGraphicsVersionItem.mouseDoubleClickEvent", "header": "['class', 'QGraphicsVersionItem', '(', 'QGraphicsItemInterface', ',', 'QtGui', '.', 'QGraphicsEllipseItem', ')', ':', '___EOS___']", "index": 764 }, { "content": "class QVersionTreeScene(QInteractiveGraphicsScene):\n \"\"\"\n QVersionTree inherits from QInteractiveGraphicsScene to keep track\n of the version scenes, i.e. versions, connections, etc.\n \n \"\"\"\n\n\n\n\n \n\n\n\n\n\n\n", "metadata": "root.QVersionTreeScene", "header": "['module', '___EOS___']", "index": 770 }, { "content": " def __init__(self, parent=None):\n \"\"\" QVersionTree(parent: QWidget) -> QVersionTree\n Initialize the graphics scene with no shapes\n \n \"\"\"\n QInteractiveGraphicsScene.__init__(self, parent)\n self.setBackgroundBrush(CurrentTheme.VERSION_TREE_BACKGROUND_BRUSH)\n self.setSceneRect(QtCore.QRectF(-5000, -5000, 10000, 10000))\n self.versions = {} # id -> version gui object\n self.edges = {} # (sourceVersion, targetVersion) -> edge gui object\n self.controller = None\n self.fullGraph = None\n self.emit_selection = True\n self.select_by_click = True\n self.connect(self, QtCore.SIGNAL(\"selectionChanged()\"),\n self.selectionChanged)", "metadata": "root.QVersionTreeScene.__init__", "header": "['class', 'QVersionTreeScene', '(', 'QInteractiveGraphicsScene', ')', ':', '___EOS___']", "index": 777 }, { "content": " def addVersion(self, node, action, tag, description):\n \"\"\" addModule(node, action: DBAction, tag: str, description: str,\n custom_color: (int, int, int))\n -> None\n Add a module to the scene.\n\n \"\"\"\n versionShape = QGraphicsVersionItem(None)\n versionShape.setupVersion(node, action, tag, description)\n self.addItem(versionShape)\n self.versions[node.id] = versionShape", "metadata": "root.QVersionTreeScene.addVersion", "header": "['class', 'QVersionTreeScene', '(', 'QInteractiveGraphicsScene', ')', ':', '___EOS___']", "index": 794 }, { "content": " def removeVersion(self, v):\n \"\"\" addLink(v: integer) -> None\n Remove version from scene and mapping\n \n \"\"\"\n versionShape = self.versions[v]\n self.removeItem(versionShape)\n self.versions.pop(v)", "metadata": "root.QVersionTreeScene.removeVersion", "header": "['class', 'QVersionTreeScene', '(', 'QInteractiveGraphicsScene', ')', ':', '___EOS___']", "index": 806 }, { "content": " def addLink(self, guiSource, guiTarget, expand, collapse):\n \"\"\" addLink(v1, v2: QGraphicsVersionItem) -> None\n Add a link to the scene\n \n \"\"\"\n linkShape = QGraphicsLinkItem()\n linkShape.setupLink(guiSource, guiTarget, expand, collapse)\n self.addItem(linkShape)\n self.edges[(guiSource.id, guiTarget.id)] = linkShape", "metadata": "root.QVersionTreeScene.addLink", "header": "['class', 'QVersionTreeScene', '(', 'QInteractiveGraphicsScene', ')', ':', '___EOS___']", "index": 815 }, { "content": " def removeLink(self, source, target):\n \"\"\" removeLink(v1, v2: integers) -> None\n Remove link from scene and mapping\n \n \"\"\"\n linkShape = self.edges[(source,target)]\n self.removeItem(linkShape)\n self.edges.pop((source, target))", "metadata": "root.QVersionTreeScene.removeLink", "header": "['class', 'QVersionTreeScene', '(', 'QInteractiveGraphicsScene', ')', ':', '___EOS___']", "index": 825 }, { "content": " def clear(self):\n \"\"\" clear() -> None\n Clear the whole scene\n \n \"\"\"\n self.versions = {}\n self.clearItems()", "metadata": "root.QVersionTreeScene.clear", "header": "['class', 'QVersionTreeScene', '(', 'QInteractiveGraphicsScene', ')', ':', '___EOS___']", "index": 834 }, { "content": " def adjust_version_colors(self, controller):\n \"\"\" adjust_version_colors(controller: VistrailController) -> None\n Based on the controller to set version colors\n \n \"\"\"\n currentUser = controller.vistrail.getUser()\n ranks = {}\n ourMaxRank = 0\n otherMaxRank = 0\n am = controller.vistrail.actionMap\n for nodeId in sorted(self.versions.keys()):\n if nodeId!=0:\n nodeUser = am[nodeId].user\n if nodeUser==currentUser:\n ranks[nodeId] = ourMaxRank\n ourMaxRank += 1\n else:\n ranks[nodeId] = otherMaxRank\n otherMaxRank += 1\n for (nodeId, item) in self.versions.iteritems():\n if nodeId == 0:\n item.setGhosted(True)\n continue\n nodeUser = am[nodeId].user\n if controller.search and nodeId!=0:\n action = am[nodeId]\n if getattr(get_vistrails_configuration(), 'hideUpgrades',\n True):\n # Use upgraded version to match\n action = am[controller.vistrail.get_upgrade(nodeId, False)]\n ghosted = not controller.search.match(controller, action)\n else:\n ghosted = False\n \n #item.setGhosted(ghosted) # we won't set it now so we can check if\n # the state changed in update_color\n if nodeUser==currentUser:\n max_rank = ourMaxRank\n else:\n max_rank = otherMaxRank\n# max_rank = ourMaxRank if nodeUser==currentUser else otherMaxRank\n configuration = get_vistrails_configuration()\n if configuration.check('customVersionColors'):\n custom_color = controller.vistrail.get_action_annotation(\n nodeId,\n custom_color_key)\n if custom_color is not None:\n try:\n custom_color = parse_custom_color(custom_color.value)\n except ValueError, e:\n debug.warning(\"Version %r has invalid color annotation \"\n \"(%s)\" % (nodeId, e))\n custom_color = None\n else:\n custom_color = None\n ####\n item.update_color(nodeUser==currentUser,\n ranks[nodeId],\n max_rank, ghosted, custom_color)\n for (version_from, version_to), link in self.edges.iteritems():\n if self.versions[version_from].ghosted and \\\n self.versions[version_to].ghosted:\n link.setGhosted(True)\n else:\n link.setGhosted(False)", "metadata": "root.QVersionTreeScene.adjust_version_colors", "header": "['class', 'QVersionTreeScene', '(', 'QInteractiveGraphicsScene', ')', ':', '___EOS___']", "index": 842 }, { "content": " def update_scene_single_node_change(self, controller, old_version, new_version):\n \"\"\" update_scene_single_node_change(controller: VistrailController,\n old_version, new_version: int) -> None\n\n Faster alternative to setup_scene when a single version is\n changed. When this is called, we know that both old_version\n and new_version don't have tags associated, so no layout\n changes happen\n \n \"\"\"\n # self.setupScene(controller)\n\n # we need to call this every time because version ranks might\n # change\n self.adjust_version_colors(controller)\n\n # update version item\n v = self.versions[old_version]\n old_desc = controller.vistrail.get_description(old_version)\n new_desc = controller.vistrail.get_description(new_version)\n if old_desc != new_desc:\n v.descriptionLabel = new_desc\n v.text.changed(v.text.centerX, v.text.centerY, new_desc, False)\n v.updateWidthFromLabel()\n self.versions[new_version] = v\n del self.versions[old_version]\n v.id = new_version\n\n # update link items\n dst = controller._current_terse_graph.edges_from(new_version)\n for eto, (expand, collapse) in dst:\n edge = self.edges[(old_version, eto)]\n edge.setupLink(self.versions[new_version],\n self.versions[eto],\n expand,\n False) # We shouldn't ever need a collapse here\n self.edges[(new_version, eto)] = edge\n del self.edges[(old_version, eto)]\n\n src = controller._current_terse_graph.edges_to(new_version)\n for efrom, (expand, collapse) in src:\n edge = self.edges[(efrom, old_version)]\n edge.setupLink(self.versions[efrom],\n self.versions[new_version],\n expand,\n False) # We shouldn't ever need a collapse here\n self.edges[(efrom, new_version)] = edge\n del self.edges[(efrom, old_version)]", "metadata": "root.QVersionTreeScene.update_scene_single_node_change", "header": "['class', 'QVersionTreeScene', '(', 'QInteractiveGraphicsScene', ')', ':', '___EOS___']", "index": 908 }, { "content": " def setupScene(self, controller, select_node=True):\n \"\"\" setupScene(controller: VistrailController) -> None\n Construct the scene to view a version tree\n \n \"\"\"\n self.select_by_click = False \n self.controller = controller\n\n # perform graph layout\n (tree, self.fullGraph, layout) = controller.refine_graph()\n\n # compute nodes that should be removed\n # O(n * (hashmap query key time)) on \n # where n is the number of current \n # nodes in the scene\n removeNodeSet = set(i for i in self.versions\n if not i in tree.vertices)\n\n # compute edges to be removed\n # O(n * (hashmap query key time)) \n # where n is the number of current \n # edges in the scene\n removeEdgeSet = set((s, t) for (s, t) in self.edges\n if (s in removeNodeSet or\n t in removeNodeSet or\n not tree.has_edge(s, t)))\n\n # loop on the nodes of the tree\n vistrail = controller.vistrail\n am = vistrail.actionMap\n last_n = vistrail.getLastActions(controller.num_versions_always_shown)\n\n self.emit_selection = False\n for node in layout.nodes.itervalues():\n # version id\n v = node.id\n\n # version tag\n tag = tree.vertices.get(v, None)\n action = am.get(v, None)\n description = vistrail.get_description(v)\n\n # if the version gui object already exists...\n if v in self.versions:\n versionShape = self.versions[v]\n versionShape.setupVersion(node, action, tag, description)\n else:\n self.addVersion(node, action, tag, description)\n if select_node:\n self.versions[v].setSelected(v == controller.current_base_version)\n\n self.emit_selection = True\n self.selectionChanged()\n\n # remove gui edges from scene\n for (v1, v2) in removeEdgeSet:\n self.removeLink(v1,v2)\n\n # remove gui nodes from scene\n for v in removeNodeSet:\n self.removeVersion(v)\n\n # adjust the colors\n self.adjust_version_colors(controller)\n\n # Add or update links\n for source, source_tag in tree.vertices.iteritems():\n eFrom = tree.edges_from(source)\n for target, (expand, collapse) in eFrom:\n guiSource = self.versions[source]\n guiTarget = self.versions[target]\n if self.edges.has_key((source,target)):\n linkShape = self.edges[(source,target)]\n linkShape.setupLink(guiSource, guiTarget,\n expand, collapse)\n else:\n self.addLink(guiSource, guiTarget, \n expand, collapse)\n\n # Update bounding rects and fit to all view\n self.updateSceneBoundingRect()\n\n self.select_by_click = True", "metadata": "root.QVersionTreeScene.setupScene", "header": "['class', 'QVersionTreeScene', '(', 'QInteractiveGraphicsScene', ')', ':', '___EOS___']", "index": 957 }, { "content": " def keyPressEvent(self, event):\n \"\"\" keyPressEvent(event: QKeyEvent) -> None\n Capture 'Del', 'Backspace' for pruning versions when not editing a tag\n \n \"\"\" \n selectedItems = self.selectedItems()\n versions = [item.id for item in selectedItems \n if isinstance(item, QGraphicsVersionItem)\n and not item.text.hasFocus()] \n if (self.controller and len(versions)>0 and\n event.key() in [QtCore.Qt.Key_Backspace, QtCore.Qt.Key_Delete]):\n event.accept()\n versions = [item.id for item in selectedItems]\n res = vistrails.gui.utils.show_question(\"VisTrails\",\n \"Are you sure that you want to \"\n \"prune the selected version(s)?\",\n [vistrails.gui.utils.YES_BUTTON,\n vistrails.gui.utils.NO_BUTTON],\n vistrails.gui.utils.NO_BUTTON)\n if res == vistrails.gui.utils.YES_BUTTON:\n self.controller.prune_versions(versions)\n else:\n qt_super(QVersionTreeScene, self).keyPressEvent(event)", "metadata": "root.QVersionTreeScene.keyPressEvent", "header": "['class', 'QVersionTreeScene', '(', 'QInteractiveGraphicsScene', ')', ':', '___EOS___']", "index": 1041 }, { "content": " def selectionChanged(self):\n if not self.emit_selection:\n return\n\n selected_items = self.selectedItems()\n if len(selected_items) == 1:\n # emit versionSelected selected_id\n self.emit(QtCore.SIGNAL('versionSelected(int,bool,bool,bool,bool)'),\n selected_items[0].id, self.select_by_click, \n True, False, False)\n else:\n # emit versionSelected -1\n for item in selected_items:\n if item.text.isEditable:\n item.text.setEditable(False)\n self.emit(QtCore.SIGNAL('versionSelected(int,bool,bool,bool,bool)'),\n -1, self.select_by_click, True, False, False)\n\n if len(selected_items) == 2:\n self.emit(\n QtCore.SIGNAL('twoVersionsSelected(int, int)'),\n selected_items[0].id, selected_items[1].id)", "metadata": "root.QVersionTreeScene.selectionChanged", "header": "['class', 'QVersionTreeScene', '(', 'QInteractiveGraphicsScene', ')', ':', '___EOS___']", "index": 1065 }, { "content": " def double_click(self, version_id):\n self.mouseGrabberItem().ungrabMouse()\n self.emit(QtCore.SIGNAL('versionSelected(int,bool,bool,bool,bool)'),\n version_id, self.select_by_click, True, False, True)", "metadata": "root.QVersionTreeScene.double_click", "header": "['class', 'QVersionTreeScene', '(', 'QInteractiveGraphicsScene', ')', ':', '___EOS___']", "index": 1088 }, { "content": "class QVersionTreeView(QInteractiveGraphicsView, BaseView):\n \"\"\"\n QVersionTreeView inherits from QInteractiveGraphicsView that will\n handle drawing of versions layout output from Dotty\n \n \"\"\"\n\n\n \n \n\n \n \n\n\n \n \n \n \n \n \n\n\n\n\n\n", "metadata": "root.QVersionTreeView", "header": "['module', '___EOS___']", "index": 1093 }, { "content": " def __init__(self, parent=None):\n \"\"\" QVersionTreeView(parent: QWidget) -> QVersionTreeView\n Initialize the graphics view and its properties\n \n \"\"\"\n QInteractiveGraphicsView.__init__(self, parent)\n BaseView.__init__(self)\n self.controller = None\n self.set_title('Version Tree')\n self.setScene(QVersionTreeScene(self))\n self.versionProp = QVersionPropOverlay(self, self.viewport())\n self.versionProp.hide()\n self._view_fitted = False", "metadata": "root.QVersionTreeView.__init__", "header": "['class', 'QVersionTreeView', '(', 'QInteractiveGraphicsView', ',', 'BaseView', ')', ':', '___EOS___']", "index": 1100 }, { "content": " def set_default_layout(self):\n from vistrails.gui.collection.workspace import QWorkspaceWindow\n from vistrails.gui.version_prop import QVersionProp\n self.set_palette_layout(\n {QtCore.Qt.LeftDockWidgetArea: QWorkspaceWindow,\n QtCore.Qt.RightDockWidgetArea: QVersionProp,\n })", "metadata": "root.QVersionTreeView.set_default_layout", "header": "['class', 'QVersionTreeView', '(', 'QInteractiveGraphicsView', ',', 'BaseView', ')', ':', '___EOS___']", "index": 1114 }, { "content": " def set_action_links(self):\n self.action_links = \\\n {\n 'publishWeb' : ('version_changed', self.check_publish_db),\n 'publishPaper': ('version_changed', self.check_publish),\n 'redo': ('version_changed', self.can_redo),\n 'undo': ('version_changed', self.can_undo),\n 'execute': ('pipeline_changed', self.can_execute)\n }", "metadata": "root.QVersionTreeView.set_action_links", "header": "['class', 'QVersionTreeView', '(', 'QInteractiveGraphicsView', ',', 'BaseView', ')', ':', '___EOS___']", "index": 1122 }, { "content": " def set_action_defaults(self):\n self.action_defaults['execute'] = \\\n [('setEnabled', True, self.set_action_execute_default)]", "metadata": "root.QVersionTreeView.set_action_defaults", "header": "['class', 'QVersionTreeView', '(', 'QInteractiveGraphicsView', ',', 'BaseView', ')', ':', '___EOS___']", "index": 1132 }, { "content": " def set_action_execute_default(self):\n if self.controller:\n if self.controller.current_pipeline:\n return len(self.controller.current_pipeline.modules) > 0\n return False", "metadata": "root.QVersionTreeView.set_action_execute_default", "header": "['class', 'QVersionTreeView', '(', 'QInteractiveGraphicsView', ',', 'BaseView', ')', ':', '___EOS___']", "index": 1136 }, { "content": " def check_publish_db(self, versionId):\n loc = self.controller.locator\n result = False\n if hasattr(loc,'host'):\n result = True \n return result and self.check_publish(versionId)", "metadata": "root.QVersionTreeView.check_publish_db", "header": "['class', 'QVersionTreeView', '(', 'QInteractiveGraphicsView', ',', 'BaseView', ')', ':', '___EOS___']", "index": 1142 }, { "content": " def check_publish(self, versionId):\n return versionId > 0 ", "metadata": "root.QVersionTreeView.check_publish", "header": "['class', 'QVersionTreeView', '(', 'QInteractiveGraphicsView', ',', 'BaseView', ')', ':', '___EOS___']", "index": 1149 }, { "content": " def can_redo(self, versionId):\n return self.controller and self.controller.can_redo()", "metadata": "root.QVersionTreeView.can_redo", "header": "['class', 'QVersionTreeView', '(', 'QInteractiveGraphicsView', ',', 'BaseView', ')', ':', '___EOS___']", "index": 1152 }, { "content": " def can_undo(self, versionId):\n return self.controller and self.controller.can_undo()", "metadata": "root.QVersionTreeView.can_undo", "header": "['class', 'QVersionTreeView', '(', 'QInteractiveGraphicsView', ',', 'BaseView', ')', ':', '___EOS___']", "index": 1155 }, { "content": " def can_execute(self, pipeline):\n return pipeline is not None and len(pipeline.modules) > 0", "metadata": "root.QVersionTreeView.can_execute", "header": "['class', 'QVersionTreeView', '(', 'QInteractiveGraphicsView', ',', 'BaseView', ')', ':', '___EOS___']", "index": 1158 }, { "content": " def execute(self):\n res = self.controller.execute_user_workflow()\n from vistrails.gui.vistrails_window import _app\n if len(res[0][0].errors) > 0:\n _app.qactions['pipeline'].trigger()\n _app.notify('execution_updated')", "metadata": "root.QVersionTreeView.execute", "header": "['class', 'QVersionTreeView', '(', 'QInteractiveGraphicsView', ',', 'BaseView', ')', ':', '___EOS___']", "index": 1161 }, { "content": " def publish_to_web(self):\n from vistrails.gui.publishing import QVersionEmbed\n panel = QVersionEmbed.instance()\n panel.switchType('Wiki')\n panel.set_visible(True)", "metadata": "root.QVersionTreeView.publish_to_web", "header": "['class', 'QVersionTreeView', '(', 'QInteractiveGraphicsView', ',', 'BaseView', ')', ':', '___EOS___']", "index": 1168 }, { "content": " def publish_to_paper(self):\n from vistrails.gui.publishing import QVersionEmbed\n panel = QVersionEmbed.instance()\n panel.switchType('Latex')\n panel.set_visible(True)", "metadata": "root.QVersionTreeView.publish_to_paper", "header": "['class', 'QVersionTreeView', '(', 'QInteractiveGraphicsView', ',', 'BaseView', ')', ':', '___EOS___']", "index": 1174 }, { "content": " def selectModules(self):\n \"\"\" selectModules() -> None\n Overrides parent class to disable text items if you click on background\n\n \"\"\"\n if self.canSelectRectangle:\n br = self.selectionBox.sceneBoundingRect()\n else:\n br = QtCore.QRectF(self.startSelectingPos,\n self.startSelectingPos)\n items = self.scene().items(br)\n if len(items)==0 or items==[self.selectionBox]:\n for item in self.scene().selectedItems():\n if isinstance(item, QGraphicsVersionItem):\n item.text.clearFocus()\n qt_super(QVersionTreeView, self).selectModules()", "metadata": "root.QVersionTreeView.selectModules", "header": "['class', 'QVersionTreeView', '(', 'QInteractiveGraphicsView', ',', 'BaseView', ')', ':', '___EOS___']", "index": 1180 }, { "content": " def set_title(self, title):\n BaseView.set_title(self, title)\n self.setWindowTitle(title)", "metadata": "root.QVersionTreeView.set_title", "header": "['class', 'QVersionTreeView', '(', 'QInteractiveGraphicsView', ',', 'BaseView', ')', ':', '___EOS___']", "index": 1197 }, { "content": " def set_controller(self, controller):\n self._view_fitted = False\n oldController = self.controller\n if oldController != controller:\n if oldController is not None:\n self.disconnect(oldController,\n QtCore.SIGNAL('vistrailChanged()'),\n self.vistrailChanged)\n self.disconnect(oldController,\n QtCore.SIGNAL('invalidateSingleNodeInVersionTree'),\n self.single_node_changed)\n self.disconnect(oldController,\n QtCore.SIGNAL('notesChanged()'),\n self.notesChanged)\n self.controller = controller\n self.scene().controller = controller\n self.connect(controller,\n QtCore.SIGNAL('vistrailChanged()'),\n self.vistrailChanged)\n self.connect(controller,\n QtCore.SIGNAL('invalidateSingleNodeInVersionTree'),\n self.single_node_changed)\n self.connect(controller,\n QtCore.SIGNAL(\"notesChanged()\"),\n self.notesChanged)\n if controller:\n self.versionProp.updateController(controller)\n self.scene().setupScene(controller)\n # self.vistrailChanged()\n # self.versionProp.updateController(controller)\n # self.versionView.versionProp.updateController(controller)", "metadata": "root.QVersionTreeView.set_controller", "header": "['class', 'QVersionTreeView', '(', 'QInteractiveGraphicsView', ',', 'BaseView', ')', ':', '___EOS___']", "index": 1201 }, { "content": " def vistrailChanged(self):\n \"\"\" vistrailChanged() -> None\n An action was performed on the current vistrail\n \n \"\"\"\n from vistrails.gui.vistrails_window import _app\n select_node = True\n if _app._previous_view and _app._previous_view.window() != self.window():\n select_node = False\n self.scene().setupScene(self.controller, select_node)\n if self.controller and self.controller.reset_version_view:\n self.scene().fitToAllViews()\n if self.controller:\n # self.versionProp.updateVersion(self.controller.current_version)\n self.versionProp.updateVersion(self.controller.current_version)\n self.emit(QtCore.SIGNAL(\"vistrailChanged()\"))", "metadata": "root.QVersionTreeView.vistrailChanged", "header": "['class', 'QVersionTreeView', '(', 'QInteractiveGraphicsView', ',', 'BaseView', ')', ':', '___EOS___']", "index": 1233 }, { "content": " def single_node_changed(self, old_version, new_version):\n \"\"\" single_node_changed(old_version, new_version)\n Handle single node change on version tree by not recomputing\n entire scene.\n\n \"\"\"\n self.scene().update_scene_single_node_change(self.controller,\n old_version,\n new_version)\n if self.controller and self.controller.reset_version_view:\n self.scene().fitToAllViews()\n if self.controller:\n # self.versionProp.updateVersion(self.controller.current_version)\n self.versionProp.updateVersion(self.controller.current_version)\n self.emit(QtCore.SIGNAL(\"vistrailChanged()\"))", "metadata": "root.QVersionTreeView.single_node_changed", "header": "['class', 'QVersionTreeView', '(', 'QInteractiveGraphicsView', ',', 'BaseView', ')', ':', '___EOS___']", "index": 1250 }, { "content": " def notesChanged(self):\n \"\"\" notesChanged() -> None\n The notes for the current vistrail version changed\n\n \"\"\"\n if self.controller:\n self.versionProp.updateVersion(self.controller.current_version)", "metadata": "root.QVersionTreeView.notesChanged", "header": "['class', 'QVersionTreeView', '(', 'QInteractiveGraphicsView', ',', 'BaseView', ')', ':', '___EOS___']", "index": 1266 }, { "content": " def select_current_version(self):\n self.scene().setupScene(self.controller)", "metadata": "root.QVersionTreeView.select_current_version", "header": "['class', 'QVersionTreeView', '(', 'QInteractiveGraphicsView', ',', 'BaseView', ')', ':', '___EOS___']", "index": 1274 }, { "content": " def viewSelected(self):\n if not self._view_fitted and self.isVisible():\n # We only do this once after a set_controller() call\n self.zoomToFit()\n self._view_fitted = True", "metadata": "root.QVersionTreeView.viewSelected", "header": "['class', 'QVersionTreeView', '(', 'QInteractiveGraphicsView', ',', 'BaseView', ')', ':', '___EOS___']", "index": 1277 } ]
[ { "span": "from vistrails.core.vistrail.vistrail import Vistrail", "start_line": 56, "start_column": 0, "end_line": 56, "end_column": 53 } ]
[]
1
false
[ "[CLS]_", "Un", "used_", "import_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "###########", "###########", "###########", "###########", "###########", "###########", "###########", "##", "_", "\\u\\u\\uNL\\u\\u\\u_", "##", "_", "\\u\\u\\uNL\\u\\u\\u_", "##", " ", "Copy", "right", " ", "(", "C", ")", " ", "2014", "-", "2016", ",", " ", "New", " ", "Yo", "rk", " ", "Univers", "it", "y", "._", "\\u\\u\\uNL\\u\\u\\u_", "##", " ", "Copy", "right", " ", "(", "C", ")", " ", "2011", "-", "2014", ",", " ", "NY", "U", "-", "Poly", "._", "\\u\\u\\uNL\\u\\u\\u_", "##", " ", "Copy", "right", " ", "(", "C", ")", " ", "2006", "-", "2011", ",", " ", "Univers", "it", "y", " ", "of", " ", "Ut", "ah", "._", "\\u\\u\\uNL\\u\\u\\u_", "##", " ", "All", " ", "rights", " ", "reserve", "d", "._", "\\u\\u\\uNL\\u\\u\\u_", "##", " ", "Conta", "ct", ":", " ", "contact", "@", "vist", "rail", "s", ".", "org_", "\\u\\u\\uNL\\u\\u\\u_", "##", "_", "\\u\\u\\uNL\\u\\u\\u_", "##", " ", "Thi", "s", " ", "file", " ", "is", " ", "part", " ", "of", " ", "Vis", "Trail", "s", "._", "\\u\\u\\uNL\\u\\u\\u_", "##", "_", "\\u\\u\\uNL\\u\\u\\u_", "##", " ", "\"", "Redistributi", "on", " ", "and", " ", "use", " ", "in", " ", "source", " ", "and", " ", "binar", "y", " ", "forms", ",", " ", "with", " ", "or", " ", "with", "out_", "\\u\\u\\uNL\\u\\u\\u_", "##", " ", "modification", ",", " ", "are", " ", "permit", "ted", " ", "provided", " ", "tha", "t", " ", "the", " ", "follow", "ing", " ", "condition", "s", " ", "are", " ", "met", ":_", "\\u\\u\\uNL\\u\\u\\u_", "##", "_", "\\u\\u\\uNL\\u\\u\\u_", "##", " ", " ", "-", " ", "Redistributi", "ons", " ", "of", " ", "source", " ", "code", " ", "must", " ", "retain", " ", "the", " ", "above", " ", "copyr", "ight", " ", "notice", ",_", "\\u\\u\\uNL\\u\\u\\u_", "##", " ", " ", " ", " ", "this", " ", "list", " ", "of", " ", "condition", "s", " ", "and", " ", "the", " ", "follow", "ing", " ", "discl", "aime", "r", "._", "\\u\\u\\uNL\\u\\u\\u_", "##", " ", " ", "-", " ", "Redistributi", "ons", " ", "in", " ", "binar", "y", " ", "form", " ", "must", " ", "reproduce", " ", "the", " ", "above", " ", "copyright_", "\\u\\u\\uNL\\u\\u\\u_", "##", " ", " ", " ", " ", "notice", ",", " ", "this", " ", "list", " ", "of", " ", "condition", "s", " ", "and", " ", "the", " ", "follow", "ing", " ", "discl", "aime", "r", " ", "in", " ", "the_", "\\u\\u\\uNL\\u\\u\\u_", "##", " ", " ", " ", " ", "documentation", " ", "and", "/", "or", " ", "other", " ", "material", "s", " ", "provided", " ", "with", " ", "the", " ", "distribu", "tion", "._", "\\u\\u\\uNL\\u\\u\\u_", "##", " ", " ", "-", " ", "Nei", "ther", " ", "the", " ", "name", " ", "of", " ", "the", " ", "New", " ", "Yo", "rk", " ", "Univers", "it", "y", " ", "nor", " ", "the", " ", "names", " ", "of", " ", "its_", "\\u\\u\\uNL\\u\\u\\u_", "##", " ", " ", " ", " ", "contributor", "s", " ", "may", " ", "be", " ", "used", " ", "to", " ", "endo", "rse", " ", "or", " ", "promote", " ", "products", " ", "derive", "d", " ", "from_", "\\u\\u\\uNL\\u\\u\\u_", "##", " ", " ", " ", " ", "this", " ", "software", " ", "with", "out", " ", "specific", " ", "prior", " ", "writt", "en", " ", "permissi", "on", "._", "\\u\\u\\uNL\\u\\u\\u_", "##", "_", "\\u\\u\\uNL\\u\\u\\u_", "##", " ", "THIS", " ", "SOFT", "WARE", " ", "IS", " ", "PROVI", "DED", " ", "BY", " ", "THE", " ", "COPY", "RIG", "HT", " ", "HOLD", "ERS", " ", "AND", " ", "CONTRIB", "UTO", "RS", " ", "\"", "AS", " ", "IS", "\"_", "\\u\\u\\uNL\\u\\u\\u_", "##", " ", "AND", " ", "ANY", " ", "EXPR", "ESS", " ", "OR", " ", "IMPL", "IED", " ", "WAR", "RAN", "TIES", ",", " ", "INC", "LU", "DING", ",", " ", "BUT", " ", "NOT", " ", "LIMIT", "ED", " ", "TO", ",_", "\\u\\u\\uNL\\u\\u\\u_", "##", " ", "THE", " ", "IMPL", "IED", " ", "WAR", "RAN", "TIES", " ", "OF", " ", "MER", "CHAN", "TAB", "ILI", "TY", " ", "AND", " ", "FIT", "NESS", " ", "FOR", " ", "A", " ", "PARTI", "CUL", "AR_", "\\u\\u\\uNL\\u\\u\\u_", "##", " ", "PUR", "POS", "E", " ", "ARE", " ", "DISC", "LAI", "MED", ".", " ", "IN", " ", "NO", " ", "EVENT", " ", "SHA", "LL", " ", "THE", " ", "COPY", "RIG", "HT", " ", "HOLD", "ER", " ", "OR_", "\\u\\u\\uNL\\u\\u\\u_", "##", " ", "CONTRIB", "UTO", "RS", " ", "BE", " ", "LI", "AB", "LE", " ", "FOR", " ", "ANY", " ", "DIRECT", ",", " ", "INDI", "RECT", ",", " ", "INC", "IDENT", "AL", ",", " ", "SPECIAL", ",_", "\\u\\u\\uNL\\u\\u\\u_", "##", " ", "EXE", "MPL", "ARY", ",", " ", "OR", " ", "CONS", "EQU", "ENTI", "AL", " ", "DA", "MAGE", "S", " ", "(", "INC", "LU", "DING", ",", " ", "BUT", " ", "NOT", " ", "LIMIT", "ED", " ", "TO", ",_", "\\u\\u\\uNL\\u\\u\\u_", "##", " ", "PROC", "URE", "MENT", " ", "OF", " ", "SUBST", "ITU", "TE", " ", "GOOD", "S", " ", "OR", " ", "SERVICES", ";", " ", "LOSS", " ", "OF", " ", "USE", ",", " ", "DATA", ",", " ", "OR", " ", "PROF", "IT", "S", ";_", "\\u\\u\\uNL\\u\\u\\u_", "##", " ", "OR", " ", "BUS", "INE", "SS", " ", "INTER", "RU", "PTION", ")", " ", "HO", "WE", "VER", " ", "CAU", "SED", " ", "AND", " ", "ON", " ", "ANY", " ", "THE", "ORY", " ", "OF", " ", "LI", "ABI", "LIT", "Y", ",_", "\\u\\u\\uNL\\u\\u\\u_", "##", " ", "WHE", "THER", " ", "IN", " ", "CONTR", "ACT", ",", " ", "STRI", "CT", " ", "LI", "ABI", "LIT", "Y", ",", " ", "OR", " ", "TOR", "T", " ", "(", "INC", "LU", "DING", " ", "NEG", "LIG", "ENCE", " ", "OR_", "\\u\\u\\uNL\\u\\u\\u_", "##", " ", "OTHER", "WI", "SE", ")", " ", "ARI", "SIN", "G", " ", "IN", " ", "ANY", " ", "WAY", " ", "OUT", " ", "OF", " ", "THE", " ", "USE", " ", "OF", " ", "THIS", " ", "SOFT", "WARE", ",", " ", "EVE", "N", " ", "IF_", "\\u\\u\\uNL\\u\\u\\u_", "##", " ", "ADV", "ISE", "D", " ", "OF", " ", "THE", " ", "POS", "SIB", "ILI", "TY", " ", "OF", " ", "SUC", "H", " ", "DA", "MAGE", ".\"_", "\\u\\u\\uNL\\u\\u\\u_", "##", "_", "\\u\\u\\uNL\\u\\u\\u_", "###########", "###########", "###########", "###########", "###########", "###########", "###########", "##", "_", "\\u\\u\\uNL\\u\\u\\u_", "\"\"\"", " ", "Thi", "s", " ", "is", " ", "a", " ", "QG", "raph", "ics", "View", " ", "for", " ", "pipeline", " ", "view", ",", " ", "it", " ", "als", "o", " ", "hold", "s", " ", "different", "\\", "10", ";", "types", " ", "of", " ", "graphic", "s", " ", "items", " ", "tha", "t", " ", "are", " ", "only", " ", "avail", "able", " ", "in", " ", "the", " ", "pipeline", "\\", "10", ";", "view", ".", " ", "It", " ", "only", " ", "handle", "s", " ", "GU", "I", "-", "relate", "d", " ", "action", "s", ",", " ", "the", " ", "rest", " ", "of", " ", "the", "\\", "10", ";", "functional", "iti", "es", " ", "are", " ", "implemented", " ", "at", " ", "some", "where", " ", "else", ",", "\\", "10", ";", "e", ".", "g", ".", " ", "core", ".", "vist", "rail", "s", "\\", "10", ";", "\\", "10", ";", "QG", "raph", "ics", "Link", "Item", "\\", "10", ";", "QG", "raph", "ics", "Version", "Text", "Item", "\\", "10", ";", "QG", "raph", "ics", "Version", "Item", "\\", "10", ";", "QV", "ersi", "on", "Tree", "Scen", "e", "\\", "10", ";", "QV", "ersi", "on", "Tree", "View", "\\", "10", ";\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "\\u\\u", "future\\u\\u_", "import_", "division_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "from_", "Py", "Qt4_", "import_", "Qt", "Core_", ",_", "Qt", "Gui_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "vist", "rail", "s_", "._", "core_", "._", "configuration_", "import_", "get", "\\u", "vist", "rail", "s", "\\u", "configuration_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "vist", "rail", "s_", "._", "core_", "import_", "debug_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "vist", "rail", "s_", "._", "core_", "._", "system_", "import_", "system", "Type_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "vist", "rail", "s_", "._", "core_", "._", "thumbnail", "s_", "import_", "Thumb", "nail", "Cache_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "vist", "rail", "s_", "._", "core_", "._", "vist", "rail", "_", "._", "controller_", "import_", "custom", "\\u", "color", "\\u", "key_", ",_", "parse", "\\u", "custom", "\\u", "color_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "vist", "rail", "s_", "._", "core_", "._", "vist", "rail", "_", "._", "vist", "rail", "_", "import_", "Vis", "trail_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "vist", "rail", "s_", "._", "gui_", "._", "base", "\\u", "view_", "import_", "Base", "View_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "vist", "rail", "s_", "._", "gui_", "._", "graphic", "s", "\\u", "view_", "import_", "(_", "QI", "nter", "active", "Graphic", "s", "Scene_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "QI", "nter", "active", "Graphic", "s", "View_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "QG", "raph", "ics", "Item", "Interface_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "vist", "rail", "s_", "._", "gui_", "._", "qt_", "import_", "qt", "\\u", "super_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "vist", "rail", "s_", "._", "gui_", "._", "theme_", "import_", "Curr", "ent", "Theme_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "vist", "rail", "s_", "._", "gui_", "._", "version", "\\u", "prop_", "import_", "QV", "ersi", "on", "Prop", "Overla", "y_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "vist", "rail", "s_", "._", "gui_", "._", "collection_", "._", "workspace_", "import_", "QP", "aram", "Explo", "ration", "Entit", "y", "Item_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "vist", "rail", "s_", "._", "gui_", "._", "utils_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "###########", "###########", "###########", "###########", "###########", "###########", "###########", "###", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "QG", "raph", "ics", "Link", "Item_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "###########", "###########", "###########", "###########", "###########", "###########", "###########", "#", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "QG", "raph", "ics", "Vers", "tion", "Text", "Item_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "###########", "###########", "###########", "###########", "###########", "###########", "###########", "#", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "QG", "raph", "ics", "Version", "Item_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "class_", "QG", "raph", "ics", "Link", "Item_", "(_", "QG", "raph", "ics", "Item", "Interface_", ",_", "Qt", "Gui_", "._", "QG", "raph", "ics", "Polygon", "Item_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "QG", "raph", "ics", "Link", "Item", " ", "is", " ", "a", " ", "connecti", "on", " ", "shape", " ", "connecti", "ng", " ", "two", " ", "version", "s", "\\", "10", ";", " ", " ", " ", " ", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "[SEP]_", "class_", "QG", "raph", "ics", "Link", "Item_", "(_", "QG", "raph", "ics", "Item", "Interface_", ",_", "Qt", "Gui_", "._", "QG", "raph", "ics", "Polygon", "Item_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "\\u\\u", "init\\u\\u_", "(_", "self_", ",_", "parent_", "=_", "None_", ",_", "scene_", "=_", "None_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", " ", "QG", "raph", "ics", "Link", "Item", "(", "parent", ":", " ", "QG", "raph", "ics", "Item", ",", "\\", "10", ";", " ", " ", " ", " ", "scen", "e", ":", " ", "QG", "raph", "ics", "Scen", "e", ")", " ", "->", " ", "QG", "raph", "ics", "Link", "Item", "\\", "10", ";", " ", " ", " ", " ", "Creat", "e", " ", "the", " ", "shape", ",", " ", "initialize", " ", "its", " ", "pen", " ", "and", " ", "brus", "h", " ", "according", "ly", "\\", "10", ";", " ", " ", " ", " ", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "Qt", "Gui_", "._", "QG", "raph", "ics", "Polygon", "Item_", "._", "\\u\\u", "init\\u\\u_", "(_", "self_", ",_", "parent_", ",_", "scene_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "set", "Flags_", "(_", "Qt", "Gui_", "._", "QG", "raph", "ics", "Item_", "._", "Item", "Is", "Select", "able_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "set", "Z", "Value_", "(_", "0_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "link", "Pen_", "=_", "Curr", "ent", "Theme_", "._", "LINK", "\\u", "PEN", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "ghost", "ed_", "=_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "cache", " ", "link", " ", "endpoint", "s", " ", "to", " ", "improve", " ", "perform", "anc", "e", " ", "on", " ", "scen", "e", " ", "updates_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "c1_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "c2_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "expand_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "collapse", "_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "QG", "raph", "ics", "Link", "Item_", "(_", "QG", "raph", "ics", "Item", "Interface_", ",_", "Qt", "Gui_", "._", "QG", "raph", "ics", "Polygon", "Item_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "mouse", "Press", "Event_", "(_", "self_", ",_", "event_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", " ", "mouse", "Press", "Event", "(", "event", ":", " ", "QM", "ouse", "Event", ")", " ", "->", " ", "Non", "e", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "qt", "\\u", "super_", "(_", "QG", "raph", "ics", "Link", "Item_", ",_", "self_", ")_", "._", "mouse", "Press", "Event_", "(_", "event_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "set", "Selected_", "(_", "True_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "QG", "raph", "ics", "Link", "Item_", "(_", "QG", "raph", "ics", "Item", "Interface_", ",_", "Qt", "Gui_", "._", "QG", "raph", "ics", "Polygon", "Item_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "mouse", "Release", "Event_", "(_", "self_", ",_", "event_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", " ", "mouse", "Release", "Event", "(", "event", ":", " ", "QM", "ouse", "Event", ")", " ", "->", " ", "Non", "e", "\\", "10", ";", " ", " ", " ", " ", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "qt", "\\u", "super_", "(_", "QG", "raph", "ics", "Link", "Item_", ",_", "self_", ")_", "._", "mouse", "Release", "Event_", "(_", "event_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "self_", "._", "expand_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "scene_", "(_", ")_", "._", "controller_", "._", "expand", "\\u", "versions_", "(_", "self_", "._", "start", "Version_", ",_", "self_", "._", "end", "Version_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "self_", "._", "collapse", "_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "scene_", "(_", ")_", "._", "controller_", "._", "collapse", "\\u", "versions_", "(_", "self_", "._", "end", "Version_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "set", "Selected_", "(_", "False_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "QG", "raph", "ics", "Link", "Item_", "(_", "QG", "raph", "ics", "Item", "Interface_", ",_", "Qt", "Gui_", "._", "QG", "raph", "ics", "Polygon", "Item_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "set", "Ghost", "ed_", "(_", "self_", ",_", "ghost", "ed_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", " ", "set", "Ghost", "ed", "(", "ghost", "ed", ":", " ", "Tru", "e", ")", " ", "->", " ", "Non", "e", "\\", "10", ";", " ", " ", " ", " ", "Set", " ", "this", " ", "link", " ", "to", " ", "be", " ", "ghost", "ed", " ", "or", " ", "not", "\\", "10", ";", " ", " ", " ", " ", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "self_", "._", "ghost", "ed_", "<_", ">_", "ghost", "ed_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "ghost", "ed_", "=_", "ghost", "ed_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "ghost", "ed_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "link", "Pen_", "=_", "Curr", "ent", "Theme_", "._", "GH", "OST", "ED", "\\u", "LINK", "\\u", "PEN", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "link", "Pen_", "=_", "Curr", "ent", "Theme_", "._", "LINK", "\\u", "PEN", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "QG", "raph", "ics", "Link", "Item_", "(_", "QG", "raph", "ics", "Item", "Interface_", ",_", "Qt", "Gui_", "._", "QG", "raph", "ics", "Polygon", "Item_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "setup", "Link_", "(_", "self_", ",_", "v1_", ",_", "v2_", ",_", "expand_", "=_", "False_", ",_", "collapse", "_", "=_", "False_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", " ", "setup", "Link", "(", "v1", ",", " ", "v2", ":", " ", "QG", "raph", "ics", "Version", "Item", ",", " ", "compact", ":", " ", "bool", ")", " ", "->", " ", "Non", "e", "\\", "10", ";", " ", " ", " ", " ", "Set", "up", " ", "a", " ", "line", " ", "connecti", "ng", " ", "v1", " ", "and", " ", "v2", " ", "items", "\\", "10", ";", " ", " ", " ", " ", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "start", "Version_", "=_", "min_", "(_", "v1_", "._", "id_", ",_", "v2_", "._", "id_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "end", "Version_", "=_", "max_", "(_", "v1_", "._", "id_", ",_", "v2_", "._", "id_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "c1_", "=_", "v1_", "._", "scen", "e", "Bound", "ing", "Rect_", "(_", ")_", "._", "center_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "c2_", "=_", "v2_", "._", "scen", "e", "Bound", "ing", "Rect_", "(_", ")_", "._", "center_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "check", " ", "if", " ", "it", " ", "is", " ", "the", " ", "same", " ", "geom", "etry", " _", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "improve", "s", " ", "perform", "anc", "e", " ", "on", " ", "updates_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "self_", "._", "c1_", "is_", "not_", "None_", "and_", "self_", "._", "c2_", "is_", "not_", "None_", "and_", "self_", "._", "expand_", "is_", "not_", "None_", "and_", "self_", "._", "collapse", "_", "!=_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "is", "The", "Sam", "e_", "=_", "self_", "._", "c1_", "==_", "c1_", "and_", "self_", "._", "c2_", "==_", "c2_", "and_", "self_", "._", "expand_", "==_", "expand_", "and_", "self_", "._", "collapse", "_", "==_", "collapse", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "is", "The", "Sam", "e_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "update", " ", "current", " ", "state_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "c1_", "=_", "c1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "c2_", "=_", "c2_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "collapse", "_", "=_", "collapse", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "expand_", "=_", "expand_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Compute", " ", "the", " ", "line", " ", "of", " ", "the", " ", "link", " ", "and", " ", "its", " ", "normal", " ", "line", " ", "through", "t_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "the", " ", "midpoint", "_", "\\u\\u\\uNL\\u\\u\\u_", "main", "Line_", "=_", "Qt", "Core_", "._", "QL", "ine", "F_", "(_", "c1_", ",_", "c2_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "normal", "Line_", "=_", "main", "Line_", "._", "normal", "Vector_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "normal", "Line_", "._", "set", "Length_", "(_", "Curr", "ent", "Theme_", "._", "LINK", "\\u", "SEGMENT", "\\u", "LENGTH_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "dis_", "=_", "(_", "main", "Line_", "._", "point", "At_", "(_", "0.5_", ")_", "-_", "main", "Line_", "._", "p1_", "(_", ")_", "+_", "\\u\\u\\uNL\\u\\u\\u_", "normal", "Line_", "._", "p1_", "(_", ")_", "-_", "normal", "Line_", "._", "point", "At_", "(_", "0.5_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "normal", "Line_", "._", "translate_", "(_", "dis_", "._", "x_", "(_", ")_", ",_", "dis_", "._", "y_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Generate", " ", "2", " ", "segments", " ", "along", " ", "the", " ", "main", " ", "line", " ", "and", " ", "3", " ", "segments", " ", "along", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "the", " ", "normal", " ", "line_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "not_", "self_", "._", "collapse", "_", "and_", "not_", "self_", "._", "expand_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "lines_", "=_", "[_", "main", "Line_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "poly_", "=_", "Qt", "Gui_", "._", "QP", "oly", "gon", "F_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "poly_", "._", "append_", "(_", "self_", "._", "lines_", "[_", "0_", "]_", "._", "p1_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "poly_", "._", "append_", "(_", "self_", "._", "lines_", "[_", "0_", "]_", "._", "p2_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "poly_", "._", "append_", "(_", "self_", "._", "lines_", "[_", "0_", "]_", "._", "p1_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "set", "Polygon_", "(_", "poly_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "lines_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "normal", "Line_", "=_", "main", "Line_", "._", "normal", "Vector_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "normal", "Line_", "._", "set", "Length_", "(_", "Curr", "ent", "Theme_", "._", "LINK", "\\u", "SEGMENT", "\\u", "SQUARE", "\\u", "LENGTH_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "dis_", "=_", "(_", "main", "Line_", "._", "point", "At_", "(_", "0.5_", ")_", "-_", "main", "Line_", "._", "p1_", "(_", ")_", "+_", "\\u\\u\\uNL\\u\\u\\u_", "normal", "Line_", "._", "p1_", "(_", ")_", "-_", "normal", "Line_", "._", "point", "At_", "(_", "0.5_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "normal", "Line_", "._", "translate_", "(_", "dis_", "._", "x_", "(_", ")_", ",_", "dis_", "._", "y_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "gap", "Line_", "=_", "Qt", "Core_", "._", "QL", "ine", "F_", "(_", "main", "Line_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "gap", "Line_", "._", "set", "Length_", "(_", "Curr", "ent", "Theme_", "._", "LINK", "\\u", "SEGMENT", "\\u", "SQUARE", "\\u", "LENGTH_", "/_", "2_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "gap", "Vector_", "=_", "gap", "Line_", "._", "p2_", "(_", ")_", "-_", "gap", "Line_", "._", "p1_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Fi", "rst", " ", "segment", " ", "along", " ", "the", " ", "main", " ", "line_", "\\u\\u\\uNL\\u\\u\\u_", "line_", "=_", "Qt", "Core_", "._", "QL", "ine", "F_", "(_", "main", "Line_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "line_", "._", "set", "Length_", "(_", "line_", "._", "length_", "(_", ")_", "/_", "2_", "-_", "Curr", "ent", "Theme_", "._", "LINK", "\\u", "SEGMENT", "\\u", "SQUARE", "\\u", "LENGTH_", "/_", "2_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "lines_", "._", "append_", "(_", "Qt", "Core_", "._", "QL", "ine", "F_", "(_", "line_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Second", " ", "segment", " ", "along", " ", "the", " ", "main", " ", "line_", "\\u\\u\\uNL\\u\\u\\u_", "line_", "._", "translate_", "(_", "line_", "._", "p2_", "(_", ")_", "-_", "line_", "._", "p1_", "(_", ")_", "+_", "gap", "Vector_", "*_", "2_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "lines_", "._", "append_", "(_", "Qt", "Core_", "._", "QL", "ine", "F_", "(_", "line_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Fi", "rst", " ", "normal", " ", "segment", " ", "in", " ", "front_", "\\u\\u\\uNL\\u\\u\\u_", "line", "\\u", "t_", "=_", "Qt", "Core_", "._", "QL", "ine", "F_", "(_", "normal", "Line_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "line", "\\u", "t_", "._", "translate_", "(_", "gap", "Vector_", "*_", "(_", "-_", "1.0_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "lines_", "._", "append_", "(_", "Qt", "Core_", "._", "QL", "ine", "F_", "(_", "line", "\\u", "t_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Second", " ", "normal", " ", "segment", " ", "in", " ", "back_", "\\u\\u\\uNL\\u\\u\\u_", "line", "\\u", "b_", "=_", "Qt", "Core_", "._", "QL", "ine", "F_", "(_", "normal", "Line_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "line", "\\u", "b_", "._", "translate_", "(_", "gap", "Vector_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "lines_", "._", "append_", "(_", "Qt", "Core_", "._", "QL", "ine", "F_", "(_", "line", "\\u", "b_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Le", "ft", " ", "box_", "\\u\\u\\uNL\\u\\u\\u_", "line_", "=_", "Qt", "Core_", "._", "QL", "ine", "F_", "(_", "line", "\\u", "t_", "._", "p1_", "(_", ")_", ",_", "line", "\\u", "b_", "._", "p1_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "lines_", "._", "append_", "(_", "Qt", "Core_", "._", "QL", "ine", "F_", "(_", "line_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Rig", "ht", " ", "box_", "\\u\\u\\uNL\\u\\u\\u_", "line_", "=_", "Qt", "Core_", "._", "QL", "ine", "F_", "(_", "line", "\\u", "t_", "._", "p2_", "(_", ")_", ",_", "line", "\\u", "b_", "._", "p2_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "lines_", "._", "append_", "(_", "Qt", "Core_", "._", "QL", "ine", "F_", "(_", "line_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Horiz", "onta", "l", " ", "plus_", "\\u\\u\\uNL\\u\\u\\u_", "line", "\\u", "h_", "=_", "Qt", "Core_", "._", "QL", "ine", "F_", "(_", "normal", "Line_", "._", "point", "At_", "(_", "0.2_", ")_", ",_", "normal", "Line_", "._", "point", "At_", "(_", "0.8_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "lines_", "._", "append_", "(_", "Qt", "Core_", "._", "QL", "ine", "F_", "(_", "line", "\\u", "h_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "self_", "._", "expand_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Vertica", "l", " ", "plus_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "line_", "=_", "Qt", "Core_", "._", "QL", "ine", "F_", "(_", "main", "Line_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "line_", "._", "translate_", "(_", "(_", "line_", "._", "p2_", "(_", ")_", "-_", "line_", "._", "p1_", "(_", ")_", ")_", "/_", "2_", "-_", "gap", "Vector_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "line_", "._", "set", "Length_", "(_", "Curr", "ent", "Theme_", "._", "LINK", "\\u", "SEGMENT", "\\u", "SQUARE", "\\u", "LENGTH_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "line", "\\u", "v_", "=_", "Qt", "Core_", "._", "QL", "ine", "F_", "(_", "line_", "._", "point", "At_", "(_", "0.2_", ")_", ",_", "line_", "._", "point", "At_", "(_", "0.8_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "lines_", "._", "append_", "(_", "Qt", "Core_", "._", "QL", "ine", "F_", "(_", "line", "\\u", "v_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Creat", "e", " ", "the", " ", "poly", " ", "line", " ", "for", " ", "selection", " ", "and", " ", "redraw_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "poly_", "=_", "Qt", "Gui_", "._", "QP", "oly", "gon", "F_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "poly_", "._", "append_", "(_", "self_", "._", "lines_", "[_", "0_", "]_", "._", "p1_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "poly_", "._", "append_", "(_", "self_", "._", "lines_", "[_", "2_", "]_", "._", "p1_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "poly_", "._", "append_", "(_", "self_", "._", "lines_", "[_", "3_", "]_", "._", "p1_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "poly_", "._", "append_", "(_", "self_", "._", "lines_", "[_", "1_", "]_", "._", "p2_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "poly_", "._", "append_", "(_", "self_", "._", "lines_", "[_", "3_", "]_", "._", "p2_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "poly_", "._", "append_", "(_", "self_", "._", "lines_", "[_", "2_", "]_", "._", "p2_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "poly_", "._", "append_", "(_", "self_", "._", "lines_", "[_", "0_", "]_", "._", "p1_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "set", "Polygon_", "(_", "poly_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "set", "Ghost", "ed_", "(_", "v1_", "._", "ghost", "ed_", "and_", "v2_", "._", "ghost", "ed_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "QG", "raph", "ics", "Link", "Item_", "(_", "QG", "raph", "ics", "Item", "Interface_", ",_", "Qt", "Gui_", "._", "QG", "raph", "ics", "Polygon", "Item_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "paint_", "(_", "self_", ",_", "painter_", ",_", "option_", ",_", "widget_", "=_", "None_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", " ", "pain", "t", "(", "painte", "r", ":", " ", "QP", "aint", "er", ",", " ", "option", ":", " ", "QS", "tyl", "e", "Optio", "n", "Graphic", "s", "Item", ",", "\\", "10", ";", " ", " ", " ", " ", " ", " ", "widget", ":", " ", "QW", "idge", "t", ")", " ", "->", " ", "Non", "e", "\\", "10", ";", " ", " ", " ", " ", "Pe", "form", " ", "actual", " ", "pain", "ting", " ", "of", " ", "the", " ", "link", "\\", "10", ";", " ", " ", " ", " ", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "self_", "._", "is", "Selected_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "painter_", "._", "set", "Pen_", "(_", "Curr", "ent", "Theme_", "._", "LINK", "\\u", "SELECTED", "\\u", "PEN", "_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "painter_", "._", "set", "Pen_", "(_", "self_", "._", "link", "Pen_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "for_", "line_", "in_", "self_", "._", "lines_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "painter_", "._", "draw", "Line_", "(_", "line_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "QG", "raph", "ics", "Link", "Item_", "(_", "QG", "raph", "ics", "Item", "Interface_", ",_", "Qt", "Gui_", "._", "QG", "raph", "ics", "Polygon", "Item_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "item", "Change_", "(_", "self_", ",_", "change_", ",_", "value_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", " ", "item", "Change", "(", "change", ":", " ", "Graphic", "s", "Item", "Change", ",", " ", "value", ":", " ", "variant", ")", " ", "->", " ", "variant", "\\", "10", ";", " ", " ", " ", " ", "Do", " ", "not", " ", "allow", " ", "link", " ", "to", " ", "be", " ", "selecte", "d", " ", "with", " ", "version", " ", "shape", "\\", "10", ";", " ", " ", " ", " ", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "change_", "==_", "Qt", "Gui_", "._", "QG", "raph", "ics", "Item_", "._", "Item", "Select", "ed", "Change_", "and_", "value_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "Qt", "Gui_", "._", "QG", "raph", "ics", "Polygon", "Item_", "._", "item", "Change_", "(_", "self_", ",_", "change_", ",_", "value_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "class_", "QG", "raph", "ics", "Version", "Text", "Item_", "(_", "QG", "raph", "ics", "Item", "Interface_", ",_", "Qt", "Gui_", "._", "QG", "raph", "ics", "Text", "Item_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "QG", "raph", "ics", "Version", "Text", "Item", " ", "is", " ", "an", " ", "edita", "ble", " ", "text", " ", "item", " ", "tha", "t", " ", "appear", "s", " ", "on", " ", "top", " ", "of", "\\", "10", ";", " ", " ", " ", " ", "a", " ", "QG", "raph", "ics", "Version", "Item", " ", "to", " ", "allow", " ", "the", " ", "tag", " ", "to", " ", "be", " ", "change", "d", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "[SEP]_", "class_", "QG", "raph", "ics", "Version", "Text", "Item_", "(_", "QG", "raph", "ics", "Item", "Interface_", ",_", "Qt", "Gui_", "._", "QG", "raph", "ics", "Text", "Item_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "\\u\\u", "init\\u\\u_", "(_", "self_", ",_", "parent_", "=_", "None_", ",_", "scene_", "=_", "None_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", " ", "QG", "raph", "ics", "Version", "Text", "Item", "(", "parent", ":", " ", "QG", "raph", "ics", "Version", "Item", ",", " ", "\\", "10", ";", " ", " ", " ", " ", "scen", "e", ":", " ", "QG", "raph", "ics", "Scen", "e", ")", " ", "->", " ", "QG", "raph", "ics", "Version", "Text", "Item", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "Creat", "e", " ", "the", " ", "shape", ",", " ", "inti", "alize", " ", "its", " ", "drawing", " ", "style", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "Qt", "Gui_", "._", "QG", "raph", "ics", "Text", "Item_", "._", "\\u\\u", "init\\u\\u_", "(_", "self_", ",_", "parent_", ",_", "scene_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "timer_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "is", "Editable", "_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "set", "Editable", "_", "(_", "False_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "set", "Font_", "(_", "Curr", "ent", "Theme_", "._", "VERSI", "ON", "\\u", "FONT_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "set", "Text", "Width_", "(_", "Curr", "ent", "Theme_", "._", "VERSI", "ON", "\\u", "LAB", "EL", "\\u", "MARGIN", "_", "[_", "0_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "set", "Default", "Text", "Color_", "(_", "Curr", "ent", "Theme_", "._", "VERSI", "ON", "\\u", "LAB", "EL", "\\u", "COLOR_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "center", "X_", "=_", "0.0_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "center", "Y_", "=_", "0.0_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "label_", "=_", "''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "is", "Tag_", "=_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "updat", "ing", "Tag_", "=_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "QG", "raph", "ics", "Version", "Text", "Item_", "(_", "QG", "raph", "ics", "Item", "Interface_", ",_", "Qt", "Gui_", "._", "QG", "raph", "ics", "Text", "Item_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "set", "Editable", "_", "(_", "self_", ",_", "editable_", "=_", "True_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "self_", "._", "timer_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "timer_", "._", "stop_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "timer_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "editable_", "==_", "self_", "._", "is", "Editable", "_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "is", "Editable", "_", "=_", "editable_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "editable_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "set", "Text", "Interaction", "Flags_", "(_", "Qt", "Core_", "._", "Qt_", "._", "Text", "Edit", "or", "Interaction", "_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "self_", "._", "text", "Cursor_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "c_", "=_", "self_", "._", "text", "Cursor_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "c_", "._", "clear", "Selection_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "set", "Text", "Cursor_", "(_", "c_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "set", "Text", "Interaction", "Flags_", "(_", "Qt", "Core_", "._", "Qt_", "._", "No", "Text", "Interaction", "_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "QG", "raph", "ics", "Version", "Text", "Item_", "(_", "QG", "raph", "ics", "Item", "Interface_", ",_", "Qt", "Gui_", "._", "QG", "raph", "ics", "Text", "Item_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "set", "Editable", "Later_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "timer_", "=_", "Qt", "Core_", "._", "QT", "ime", "r_", "(_", "self_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "timer_", "._", "set", "Sing", "le", "Shot", "_", "(_", "True_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "connect_", "(_", "self_", "._", "timer_", ",_", "Qt", "Core_", "._", "SIGNAL_", "(_", "\"", "timeo", "ut", "()\"_", ")_", ",_", "self_", "._", "set", "Editable", "_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "timer_", "._", "start_", "(_", "Qt", "Gui_", "._", "QA", "ppl", "ication", "_", "._", "double", "Click", "Interval_", "(_", ")_", "+_", "5_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "QG", "raph", "ics", "Version", "Text", "Item_", "(_", "QG", "raph", "ics", "Item", "Interface_", ",_", "Qt", "Gui_", "._", "QG", "raph", "ics", "Text", "Item_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "set", "Ghost", "ed_", "(_", "self_", ",_", "ghost", "ed_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "ghost", "ed_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "set", "Default", "Text", "Color_", "(_", "Curr", "ent", "Theme_", "._", "GH", "OST", "ED", "\\u", "VERSI", "ON", "\\u", "LAB", "EL", "\\u", "COLOR_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "set", "Default", "Text", "Color_", "(_", "Curr", "ent", "Theme_", "._", "VERSI", "ON", "\\u", "LAB", "EL", "\\u", "COLOR_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "QG", "raph", "ics", "Version", "Text", "Item_", "(_", "QG", "raph", "ics", "Item", "Interface_", ",_", "Qt", "Gui_", "._", "QG", "raph", "ics", "Text", "Item_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "changed_", "(_", "self_", ",_", "x_", ",_", "y_", ",_", "label_", ",_", "tag_", "=_", "True_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", " ", "change", "d", "(", "x", ":", " ", "float", ",", " ", "y", ":", " ", "float", ",", " ", "label", ":", " ", "str", ")", " ", "->", " ", "Non", "e", "\\", "10", ";", " ", " ", " ", " ", "Change", " ", "the", " ", "position", " ", "and", " ", "text", " ", "label", " ", "from", " ", "outsi", "de", " ", "the", " ", "editor", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "self_", "._", "center", "X_", "<_", ">_", "x_", "or_", "self_", "._", "center", "Y_", "<_", ">_", "y_", "or_", "self_", "._", "label_", "<_", ">_", "label_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "center", "X_", "=_", "x_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "center", "Y_", "=_", "y_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "label_", "=_", "label_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "is", "Tag_", "=_", "tag_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "self_", "._", "is", "Tag_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "set", "Font_", "(_", "Curr", "ent", "Theme_", "._", "VERSI", "ON", "\\u", "FONT_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "set", "Font_", "(_", "Curr", "ent", "Theme_", "._", "VERSI", "ON", "\\u", "DESCRIPT", "ION", "\\u", "FONT_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "reset_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "QG", "raph", "ics", "Version", "Text", "Item_", "(_", "QG", "raph", "ics", "Item", "Interface_", ",_", "Qt", "Gui_", "._", "QG", "raph", "ics", "Text", "Item_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "reset_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", " ", "reset", "()", " ", "->", " ", "Non", "e", "\\", "10", ";", " ", " ", " ", " ", "Reset", "s", " ", "the", " ", "text", " ", "label", ",", " ", "widt", "h", ",", " ", "and", " ", "position", "s", " ", "to", " ", "the", " ", "store", "d", " ", "values", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "set", "Plai", "n", "Text_", "(_", "self_", "._", "label_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "set", "Editable", "_", "(_", "False_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "(_", "len_", "(_", "str_", "(_", "self_", "._", "label_", ")_", ")_", ">_", "0_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "set", "Text", "Width_", "(_", "-_", "1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "set", "Text", "Width_", "(_", "Curr", "ent", "Theme_", "._", "VERSI", "ON", "\\u", "LAB", "EL", "\\u", "MARGIN", "_", "[_", "0_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "self_", "._", "is", "Tag_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "set", "Font_", "(_", "Curr", "ent", "Theme_", "._", "VERSI", "ON", "\\u", "FONT_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "set", "Font_", "(_", "Curr", "ent", "Theme_", "._", "VERSI", "ON", "\\u", "DESCRIPT", "ION", "\\u", "FONT_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "update", "Pos_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "parent", "Item_", "(_", ")_", "._", "update", "Wid", "th", "Fro", "m", "Label_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "QG", "raph", "ics", "Version", "Text", "Item_", "(_", "QG", "raph", "ics", "Item", "Interface_", ",_", "Qt", "Gui_", "._", "QG", "raph", "ics", "Text", "Item_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "update", "Pos_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", " ", "update", "Pos", "()", " ", "->", " ", "Non", "e", "\\", "10", ";", " ", " ", " ", " ", "Center", " ", "the", " ", "text", ",", " ", "by", " ", "default", " ", "it", " ", "use", "s", " ", "the", " ", "upper", " ", "left", " ", "corn", "er", "\\", "10", ";", " ", " ", " ", " ", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "set", "Pos_", "(_", "self_", "._", "center", "X_", "-_", "self_", "._", "bound", "ing", "Rect_", "(_", ")_", "._", "width_", "(_", ")_", "/_", "2.0_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "center", "Y_", "-_", "self_", "._", "bound", "ing", "Rect_", "(_", ")_", "._", "height_", "(_", ")_", "/_", "2.0_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "QG", "raph", "ics", "Version", "Text", "Item_", "(_", "QG", "raph", "ics", "Item", "Interface_", ",_", "Qt", "Gui_", "._", "QG", "raph", "ics", "Text", "Item_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "key", "Press", "Event_", "(_", "self_", ",_", "event_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", " ", "key", "Press", "Event", "(", "event", ":", " ", "QE", "vent", ")", " ", "->", " ", "Non", "e", "\\", "10", ";", " ", " ", " ", " ", "Enter", " ", "and", " ", "Return", " ", "keys", " ", "signal", " ", "a", " ", "change", " ", "in", " ", "the", " ", "label", ".", " ", " ", "Ot", "her", " ", "keys", "\\", "10", ";", " ", " ", " ", " ", "update", " ", "the", " ", "position", " ", "and", " ", "size", " ", "of", " ", "the", " ", "parent", " ", "ellips", "e", " ", "dur", "ing", " ", "key", " ", "entry", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "event_", "._", "key_", "(_", ")_", "in_", "[_", "Qt", "Core_", "._", "Qt_", "._", "Key", "\\u", "Enter", "_", ",_", "Qt", "Core_", "._", "Qt_", "._", "Key", "\\u", "Return_", "]_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "updat", "ing", "Tag_", "=_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "(_", "self_", "._", "label_", "==_", "str_", "(_", "self_", "._", "to", "Plai", "n", "Text_", "(_", ")_", ")_", "or_", "\\u\\u\\uNL\\u\\u\\u_", "not_", "self_", "._", "scene_", "(_", ")_", "._", "controller_", "._", "update", "\\u", "current", "\\u", "tag_", "(_", "str_", "(_", "self_", "._", "to", "Plai", "n", "Text_", "(_", ")_", ")_", ")_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "reset_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "updat", "ing", "Tag_", "=_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "event_", "._", "ignore_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "clear", "Focus_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "qt", "\\u", "super_", "(_", "QG", "raph", "ics", "Version", "Text", "Item_", ",_", "self_", ")_", "._", "key", "Press", "Event_", "(_", "event_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "(_", "len_", "(_", "str_", "(_", "self_", "._", "to", "Plai", "n", "Text_", "(_", ")_", ")_", ")_", ">_", "0_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "set", "Text", "Width_", "(_", "-_", "1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "update", "Pos_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "parent", "Item_", "(_", ")_", "._", "update", "Wid", "th", "Fro", "m", "Label_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "QG", "raph", "ics", "Version", "Text", "Item_", "(_", "QG", "raph", "ics", "Item", "Interface_", ",_", "Qt", "Gui_", "._", "QG", "raph", "ics", "Text", "Item_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "foc", "us", "Out", "Event_", "(_", "self_", ",_", "event_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", " ", "foc", "us", "Out", "Event", "(", "event", ":", " ", "QE", "vent", ")", " ", "->", " ", "Non", "e", "\\", "10", ";", " ", " ", " ", " ", "Update", " ", "the", " ", "tag", " ", "if", " ", "the", " ", "text", " ", "has", " ", "change", "d", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "qt", "\\u", "super_", "(_", "QG", "raph", "ics", "Version", "Text", "Item_", ",_", "self_", ")_", "._", "foc", "us", "Out", "Event_", "(_", "event_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "not_", "self_", "._", "updat", "ing", "Tag_", "and_", "self_", "._", "label_", "!=_", "self_", "._", "to", "Plai", "n", "Text_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "updat", "ing", "Tag_", "=_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "(_", "self_", "._", "label_", "==_", "str_", "(_", "self_", "._", "to", "Plai", "n", "Text_", "(_", ")_", ")_", "or_", "\\u\\u\\uNL\\u\\u\\u_", "not_", "self_", "._", "scene_", "(_", ")_", "._", "controller_", "._", "update", "\\u", "current", "\\u", "tag_", "(_", "str_", "(_", "self_", "._", "to", "Plai", "n", "Text_", "(_", ")_", ")_", ")_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "reset_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "updat", "ing", "Tag_", "=_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "class_", "QG", "raph", "ics", "Version", "Item_", "(_", "QG", "raph", "ics", "Item", "Interface_", ",_", "Qt", "Gui_", "._", "QG", "raph", "ics", "Ellipse", "Item_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "QG", "raph", "ics", "Version", "Item", " ", "is", " ", "the", " ", "version", " ", "shape", " ", "holding", " ", "version", " ", "id", " ", "and", "\\", "10", ";", " ", " ", " ", " ", "label", "\\", "10", ";", " ", " ", " ", " ", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "version", "Pen_", "=_", "property_", "(_", "\\u", "get", "\\u", "version", "Pen_", ",_", "\\u", "set\\u", "version", "Pen_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "version", "Brush_", "=_", "property_", "(_", "\\u", "get", "\\u", "version", "Brush_", ",_", "\\u", "set\\u", "version", "Brush_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "[SEP]_", "class_", "QG", "raph", "ics", "Version", "Item_", "(_", "QG", "raph", "ics", "Item", "Interface_", ",_", "Qt", "Gui_", "._", "QG", "raph", "ics", "Ellipse", "Item_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "\\u\\u", "init\\u\\u_", "(_", "self_", ",_", "parent_", "=_", "None_", ",_", "scene_", "=_", "None_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", " ", "QG", "raph", "ics", "Version", "Item", "(", "parent", ":", " ", "QG", "raph", "ics", "Item", ",", " ", "scen", "e", ":", " ", "QG", "raph", "ics", "Scen", "e", ")", "\\", "10", ";", " ", " ", " ", " ", " ", " ", "->", " ", "QG", "raph", "ics", "Version", "Item", "\\", "10", ";", " ", " ", " ", " ", "Creat", "e", " ", "the", " ", "shape", ",", " ", "initialize", " ", "its", " ", "pen", " ", "and", " ", "brus", "h", " ", "according", "ly", "\\", "10", ";", " ", " ", " ", " ", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "Qt", "Gui_", "._", "QG", "raph", "ics", "Ellipse", "Item_", "._", "\\u\\u", "init\\u\\u_", "(_", "self_", ",_", "parent_", ",_", "scene_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "set", "Z", "Value_", "(_", "1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "set", "Accept", "Drop", "s_", "(_", "True_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "set", "Flags_", "(_", "Qt", "Gui_", "._", "QG", "raph", "ics", "Item_", "._", "Item", "Is", "Select", "able_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "\\u", "version", "Pen", "Normal_", "=_", "Curr", "ent", "Theme_", "._", "VERSI", "ON", "\\u", "PEN", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "\\u", "version", "Pen_", "=_", "Curr", "ent", "Theme_", "._", "VERSI", "ON", "\\u", "PEN", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "\\u", "version", "Brush_", "=_", "Curr", "ent", "Theme_", "._", "VERSI", "ON", "\\u", "USER", "\\u", "BR", "US", "H_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "id_", "=_", "-_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "label_", "=_", "''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "description", "Label_", "=_", "''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "dragg", "ing_", "=_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "ghost", "ed_", "=_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "update", "Paint", "er", "State_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "self", ".", "rank", " ", "is", " ", "a", " ", "posit", "ive", " ", "number", " ", "tha", "t", " ", "dete", "rmin", "es", " ", "the_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "saturation", " ", "of", " ", "the", " ", "node", ".", " ", "Tw", "o", " ", "version", " ", "nodes", " ", "mig", "ht", " ", "have", " ", "the_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "same", " ", "rank", " ", "if", " ", "the", "y", " ", "wer", "e", " ", "created", " ", "by", " ", "different", " ", "users_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "self", ".", "max", "\\u", "rank", " ", "is", " ", "the", " ", "maxim", "um", " ", "rank", " ", "for", " ", "tha", "t", " ", "version", " ", "class_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "rank_", "=_", "-_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "max", "\\u", "rank_", "=_", "-_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Editable", " ", "text", " ", "item", " ", "tha", "t", " ", "remains", " ", "hidden", " ", "unl", "ess", " ", "the", " ", "version", " ", "is", " ", "selected_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "text_", "=_", "QG", "raph", "ics", "Version", "Text", "Item_", "(_", "self_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Ne", "ed", " ", "a", " ", "timer", " ", "to", " ", "start", " ", "a", " ", "drag", " ", "to", " ", "avoid", " ", "stall", "s", " ", "on", " ", "QG", "raph", "ics", "View_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "drag", "Timer_", "=_", "Qt", "Core_", "._", "QT", "ime", "r_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "drag", "Timer_", "._", "set", "Sing", "le", "Shot", "_", "(_", "True_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "drag", "Timer_", "._", "connect_", "(_", "self_", "._", "drag", "Timer_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "Qt", "Core_", "._", "SIGNAL_", "(_", "'", "timeo", "ut", "()'_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "start", "Drag", "_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "drag", "Pos_", "=_", "Qt", "Core_", "._", "QP", "oint_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "QG", "raph", "ics", "Version", "Item_", "(_", "QG", "raph", "ics", "Item", "Interface_", ",_", "Qt", "Gui_", "._", "QG", "raph", "ics", "Ellipse", "Item_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "\\u", "get", "\\u", "version", "Pen_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "self_", "._", "\\u", "version", "Pen_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "QG", "raph", "ics", "Version", "Item_", "(_", "QG", "raph", "ics", "Item", "Interface_", ",_", "Qt", "Gui_", "._", "QG", "raph", "ics", "Ellipse", "Item_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "\\u", "set\\u", "version", "Pen_", "(_", "self_", ",_", "pen_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "\\u", "version", "Pen_", "=_", "pen_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "update", "Paint", "er", "State_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "QG", "raph", "ics", "Version", "Item_", "(_", "QG", "raph", "ics", "Item", "Interface_", ",_", "Qt", "Gui_", "._", "QG", "raph", "ics", "Ellipse", "Item_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "\\u", "get", "\\u", "version", "Brush_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "self_", "._", "\\u", "version", "Brush_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "QG", "raph", "ics", "Version", "Item_", "(_", "QG", "raph", "ics", "Item", "Interface_", ",_", "Qt", "Gui_", "._", "QG", "raph", "ics", "Ellipse", "Item_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "\\u", "set\\u", "version", "Brush_", "(_", "self_", ",_", "brush_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "\\u", "version", "Brush_", "=_", "brush_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "update", "Paint", "er", "State_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "QG", "raph", "ics", "Version", "Item_", "(_", "QG", "raph", "ics", "Item", "Interface_", ",_", "Qt", "Gui_", "._", "QG", "raph", "ics", "Ellipse", "Item_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "item", "Change_", "(_", "self_", ",_", "change_", ",_", "value_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "change_", "==_", "Qt", "Gui_", "._", "QG", "raph", "ics", "Item_", "._", "Item", "Select", "ed", "Has", "Changed_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "self_", "._", "is", "Selected_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "version", "Pen_", "=_", "Curr", "ent", "Theme_", "._", "VERSI", "ON", "\\u", "SELECTED", "\\u", "PEN", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "text_", "._", "set", "Editable", "Later_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "version", "Pen_", "=_", "self_", "._", "\\u", "version", "Pen", "Normal_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "text_", "._", "set", "Editable", "_", "(_", "False_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "update", "Paint", "er", "State_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "Qt", "Gui_", "._", "QG", "raph", "ics", "Item_", "._", "item", "Change_", "(_", "self_", ",_", "change_", ",_", "value_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "QG", "raph", "ics", "Version", "Item_", "(_", "QG", "raph", "ics", "Item", "Interface_", ",_", "Qt", "Gui_", "._", "QG", "raph", "ics", "Ellipse", "Item_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "set", "Ghost", "ed_", "(_", "self_", ",_", "ghost", "ed_", "=_", "True_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", " ", "set", "Ghost", "ed", "(", "ghost", "ed", ":", " ", "Tru", "e", ")", " ", "->", " ", "Non", "e", "\\", "10", ";", " ", " ", " ", " ", "Set", " ", "this", " ", "version", " ", "to", " ", "be", " ", "ghost", "ed", " ", "or", " ", "not", "\\", "10", ";", " ", " ", " ", " ", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "self_", "._", "ghost", "ed_", "<_", ">_", "ghost", "ed_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "ghost", "ed_", "=_", "ghost", "ed_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "text_", "._", "set", "Ghost", "ed_", "(_", "ghost", "ed_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "ghost", "ed_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "\\u", "version", "Pen", "Normal_", "=_", "Curr", "ent", "Theme_", "._", "GH", "OST", "ED", "\\u", "VERSI", "ON", "\\u", "PEN", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "\\u", "version", "Brush_", "=_", "Curr", "ent", "Theme_", "._", "GH", "OST", "ED", "\\u", "VERSI", "ON", "\\u", "USER", "\\u", "BR", "US", "H_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "\\u", "version", "Pen", "Normal_", "=_", "Curr", "ent", "Theme_", "._", "VERSI", "ON", "\\u", "PEN", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "\\u", "version", "Brush_", "=_", "Curr", "ent", "Theme_", "._", "VERSI", "ON", "\\u", "USER", "\\u", "BR", "US", "H_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "not_", "self_", "._", "is", "Selected_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "\\u", "version", "Pen_", "=_", "self_", "._", "\\u", "version", "Pen", "Normal_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "update", "Paint", "er", "State_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "QG", "raph", "ics", "Version", "Item_", "(_", "QG", "raph", "ics", "Item", "Interface_", ",_", "Qt", "Gui_", "._", "QG", "raph", "ics", "Ellipse", "Item_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "update", "\\u", "color_", "(_", "self_", ",_", "is", "Thi", "s", "Us", "_", ",_", "new", "\\u", "rank_", ",_", "new", "\\u", "max", "\\u", "rank_", ",_", "new", "\\u", "ghost", "ed_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "new", "\\u", "custom", "color_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", " ", "update", "\\u", "color", "(", "is", "Thi", "s", "Us", ":", " ", "bool", ",", "\\", "10", ";", " ", " ", " ", "new", "\\u", "rank", ",", " ", "new", "\\u", "max", "\\u", "rank", ":", " ", "int", ")", " ", "->", " ", "Non", "e", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "If", " ", "necessar", "y", ",", " ", "update", " ", "the", " ", "colors", " ", "of", " ", "this", " ", "version", " ", "node", " ", "based", " ", "on", "\\", "10", ";", " ", " ", " ", " ", "who", " ", "owns", " ", "the", " ", "node", " ", "and", " ", "new", " ", "ranks", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "NOTE", ":", " ", "if", " ", "user", "name", " ", "change", "s", " ", "dur", "ing", " ", "executi", "on", ",", " ", "this", " ", "mig", "ht", " ", "break", ".", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "(_", "new", "\\u", "rank_", "==_", "self_", "._", "rank_", "and_", "new", "\\u", "max", "\\u", "rank_", "==_", "self_", "._", "max", "\\u", "rank_", "and_", "\\u\\u\\uNL\\u\\u\\u_", "new", "\\u", "ghost", "ed_", "==_", "self_", "._", "ghost", "ed_", "and_", "\\u\\u\\uNL\\u\\u\\u_", "new", "\\u", "custom", "color_", "==_", "self_", "._", "custom", "\\u", "color_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "not", "hing", " ", "changed_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "set", "Ghost", "ed_", "(_", "new", "\\u", "ghost", "ed_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "custom", "\\u", "color_", "=_", "new", "\\u", "custom", "color_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "rank_", "=_", "new", "\\u", "rank_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "max", "\\u", "rank_", "=_", "new", "\\u", "max", "\\u", "rank_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "not_", "self_", "._", "ghost", "ed_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "self_", "._", "custom", "\\u", "color_", "is_", "not_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "configuration_", "=_", "get", "\\u", "vist", "rail", "s", "\\u", "configuration_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "sat", "\\u", "from", "\\u", "rank_", "=_", "not_", "configuration_", "._", "check_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "'", "fixed", "Custom", "Version", "Color", "Satur", "ation", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "brush_", "=_", "Qt", "Gui_", "._", "QB", "rus", "h_", "(_", "Qt", "Gui_", "._", "QC", "olor_", "._", "from", "Rg", "b_", "(_", "*_", "self_", "._", "custom", "\\u", "color_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "is", "Thi", "s", "Us", "_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "brush_", "=_", "Curr", "ent", "Theme_", "._", "VERSI", "ON", "\\u", "USER", "\\u", "BR", "US", "H_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "brush_", "=_", "Curr", "ent", "Theme_", "._", "VERSI", "ON", "\\u", "OTHER", "\\u", "BR", "US", "H_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "sat", "\\u", "from", "\\u", "rank_", "=_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "sat", "\\u", "from", "\\u", "rank_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "sat_", "=_", "float_", "(_", "new", "\\u", "rank_", "+_", "1_", ")_", "/_", "new", "\\u", "max", "\\u", "rank_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "(_", "h_", ",_", "s_", ",_", "v_", ",_", "a_", ")_", "=_", "brush_", "._", "color_", "(_", ")_", "._", "get", "Hs", "v", "F_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "new", "Hs", "v_", "=_", "(_", "h_", ",_", "s_", "*_", "sat_", ",_", "v_", "+_", "(_", "1.0_", "-_", "v_", ")_", "*_", "(_", "1_", "-_", "sat_", ")_", ",_", "a_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "brush_", "=_", "Qt", "Gui_", "._", "QB", "rus", "h_", "(_", "brush_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "brush_", "._", "set", "Color_", "(_", "Qt", "Gui_", "._", "QC", "olor_", "._", "from", "Hs", "v", "F_", "(_", "*_", "new", "Hs", "v_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "version", "Brush_", "=_", "brush_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "update_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "QG", "raph", "ics", "Version", "Item_", "(_", "QG", "raph", "ics", "Item", "Interface_", ",_", "Qt", "Gui_", "._", "QG", "raph", "ics", "Ellipse", "Item_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "set", "Satur", "ation_", "(_", "self_", ",_", "is", "Thi", "s", "User_", ",_", "sat_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", " ", "set", "Satur", "ation", "(", "is", "Thi", "s", "User", ":", " ", "bool", ",", " ", "sat", ":", " ", "float", ")", " ", "->", " ", "Non", "e", " ", " ", " ", " ", "\\", "10", ";", " ", " ", " ", " ", "Set", " ", "the", " ", "color", " ", "of", " ", "this", " ", "version", " ", "depend", "ing", " ", "on", " ", "who", "se", " ", "is", " ", "the", " ", "user", "\\", "10", ";", " ", " ", " ", " ", "and", " ", "its", " ", "saturation", "\\", "10", ";", " ", " ", " ", " ", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "not_", "self_", "._", "ghost", "ed_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "is", "Thi", "s", "User_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "brush_", "=_", "Curr", "ent", "Theme_", "._", "VERSI", "ON", "\\u", "USER", "\\u", "BR", "US", "H_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "brush_", "=_", "Curr", "ent", "Theme_", "._", "VERSI", "ON", "\\u", "OTHER", "\\u", "BR", "US", "H_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "(_", "h_", ",_", "s_", ",_", "v_", ",_", "a_", ")_", "=_", "brush_", "._", "color_", "(_", ")_", "._", "get", "Hs", "v", "F_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "new", "Hs", "v_", "=_", "(_", "h_", ",_", "s_", "*_", "sat_", ",_", "v_", "+_", "(_", "1.0_", "-_", "v_", ")_", "*_", "(_", "1_", "-_", "sat_", ")_", ",_", "a_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "version", "Brush_", "=_", "Qt", "Gui_", "._", "QB", "rus", "h_", "(_", "Qt", "Gui_", "._", "QC", "olor_", "._", "from", "Hs", "v", "F_", "(_", "*_", "new", "Hs", "v_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "QG", "raph", "ics", "Version", "Item_", "(_", "QG", "raph", "ics", "Item", "Interface_", ",_", "Qt", "Gui_", "._", "QG", "raph", "ics", "Ellipse", "Item_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "update", "Wid", "th", "Fro", "m", "Label_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", " ", "update", "Wid", "th", "Fro", "m", "Label", "()", " ", "->", " ", "Non", "e", "\\", "10", ";", " ", " ", " ", " ", "Change", " ", "the", " ", "widt", "h", " ", "of", " ", "the", " ", "ellips", "e", " ", "based", " ", "on", " ", "a", " ", "temporar", "y", " ", "change", " ", "in", " ", "the", " ", "label", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "prev", "Width_", "=_", "self_", "._", "rect_", "(_", ")_", "._", "width_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "width_", "=_", "self_", "._", "text_", "._", "bound", "ing", "Rect_", "(_", ")_", "._", "width_", "(_", ")_", "+_", "Curr", "ent", "Theme_", "._", "VERSI", "ON", "\\u", "LAB", "EL", "\\u", "MARGIN", "_", "[_", "0_", "]_", "-_", "4_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "r_", "=_", "self_", "._", "rect_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "r_", "._", "set", "X_", "(_", "r_", "._", "x_", "(_", ")_", "+_", "(_", "prev", "Width_", "-_", "width_", ")_", "/_", "2.0_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "r_", "._", "set", "Width_", "(_", "width_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "set", "Rect_", "(_", "r_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "update_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "QG", "raph", "ics", "Version", "Item_", "(_", "QG", "raph", "ics", "Item", "Interface_", ",_", "Qt", "Gui_", "._", "QG", "raph", "ics", "Ellipse", "Item_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "setup", "Version_", "(_", "self_", ",_", "node_", ",_", "action_", ",_", "tag_", ",_", "description_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", " ", "setup", "Port", "(", "node", ":", " ", "Dot", "Node", ",", "\\", "10", ";", " ", " ", " ", " ", "action", ":", " ", "DBA", "ction", ",", "\\", "10", ";", " ", " ", " ", " ", "tag", ":", " ", "str", ",", "\\", "10", ";", " ", " ", " ", " ", "description", ":", " ", "str", ")", " ", "->", " ", "Non", "e", "\\", "10", ";", " ", " ", " ", " ", "Update", " ", "the", " ", "version", " ", "dimension", "s", " ", "and", " ", "id", "\\", "10", ";", " ", " ", " ", " ", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Lau", "ro", ":_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "what", " ", "was", " ", "this", " ", "hack", "ing", "???", " ", "the", " ", "coordinate", "s", " ", "inside_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "the", " ", "input", " ", "\"", "node", "\"", " ", "shou", "ld", " ", "come", " ", "to", " ", "this", " ", "point", " ", "read", "y", ".", " ", "Thi", "s", " ", "is_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "not", " ", "the", " ", "point", " ", "to", " ", "do", " ", "layout", " ", "calculati", "ons", " ", "(", "e", ".", "g", ".", " ", "-", "node", ".", "p", ".", "y", "/", "2", ")_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Carlo", "s", ":_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Thi", "s", " ", "is", " ", "not", " ", "layout", " ", "as", " ", "muc", "h", " ", "as", " ", "deal", "ing", " ", "with", " ", "the", " ", "way", " ", "Qt_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "speci", "fie", "s", " ", "rectangle", "s", ".", " ", "Bes", "ides", ",", " ", "movin", "g", " ", "this", " ", "back", " ", "here", " ", "reduce", "s_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "code", " ", "duplicat", "ion", ",", " ", "and", " ", "allow", "s", " ", "customize", "d", " ", "behavior", " ", "for_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "subclasses", "._", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "rect_", "=_", "Qt", "Core_", "._", "QR", "ect", "F_", "(_", "node_", "._", "p_", "._", "x_", "-_", "node_", "._", "width_", "/_", "2.0_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "node_", "._", "p_", "._", "y_", "-_", "node_", "._", "height_", "/_", "2.0_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "node_", "._", "width_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "node_", "._", "height_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "valid", "Label_", "=_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "tag_", "is_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "label_", "=_", "''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "valid", "Label_", "=_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "label_", "=_", "tag_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "id_", "=_", "node_", "._", "id_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "label_", "=_", "label_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "description_", "is_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "description", "Label_", "=_", "''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "description", "Label_", "=_", "description_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "valid", "Label_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "text", "To", "Draw_", "=_", "self_", "._", "label_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "text", "To", "Draw_", "=_", "self_", "._", "description", "Label_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "(_", "Thumb", "nail", "Cache_", "._", "get", "Instance_", "(_", ")_", "._", "conf_", "._", "mouse", "Hover", "_", "and_", "\\u\\u\\uNL\\u\\u\\u_", "action_", "and_", "action_", "._", "thumbnail_", "is_", "not_", "None_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "fname_", "=_", "Thumb", "nail", "Cache_", "._", "get", "Instance_", "(_", ")_", "._", "get", "\\u", "abs", "\\u", "name", "\\u", "entry_", "(_", "action_", "._", "thumbnail_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "set", "Tool", "Tip_", "(_", "'<", "img", " ", "src", "=\"", "%", "s", "\"", " ", "height", "=\"", "128", "\"", " ", "border", "=\"", "1", "\"/>'_", "%_", "fname_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "set", "Tool", "Tip_", "(_", "''_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "text_", "._", "changed_", "(_", "node_", "._", "p_", "._", "x_", ",_", "node_", "._", "p_", "._", "y_", ",_", "text", "To", "Draw_", ",_", "valid", "Label_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "set", "Rect_", "(_", "rect_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "QG", "raph", "ics", "Version", "Item_", "(_", "QG", "raph", "ics", "Item", "Interface_", ",_", "Qt", "Gui_", "._", "QG", "raph", "ics", "Ellipse", "Item_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "bound", "ing", "Rect_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", " ", "bound", "ing", "Rect", "()", " ", "->", " ", "QR", "ect", "F", "\\", "10", ";", " ", " ", " ", " ", "Add", " ", "a", " ", "padde", "d", " ", "space", " ", "to", " ", "avoid", " ", "un", "-", "update", "d", " ", "area", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "self_", "._", "rect_", "(_", ")_", "._", "adjusted", "_", "(_", "-_", "2_", ",_", "-_", "2_", ",_", "2_", ",_", "2_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "QG", "raph", "ics", "Version", "Item_", "(_", "QG", "raph", "ics", "Item", "Interface_", ",_", "Qt", "Gui_", "._", "QG", "raph", "ics", "Ellipse", "Item_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "paint_", "(_", "self_", ",_", "painter_", ",_", "option_", ",_", "widget_", "=_", "None_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "option_", "._", "state_", "&=_", "~_", "Qt", "Gui_", "._", "QS", "tyle_", "._", "State", "\\u", "Selected_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "Qt", "Gui_", "._", "QG", "raph", "ics", "Ellipse", "Item_", "._", "paint_", "(_", "self_", ",_", "painter_", ",_", "option_", ",_", "widget_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "QG", "raph", "ics", "Version", "Item_", "(_", "QG", "raph", "ics", "Item", "Interface_", ",_", "Qt", "Gui_", "._", "QG", "raph", "ics", "Ellipse", "Item_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "update", "Paint", "er", "State_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "set", "Pen_", "(_", "self_", "._", "\\u", "version", "Pen_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "set", "Brush_", "(_", "self_", "._", "\\u", "version", "Brush_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "QG", "raph", "ics", "Version", "Item_", "(_", "QG", "raph", "ics", "Item", "Interface_", ",_", "Qt", "Gui_", "._", "QG", "raph", "ics", "Ellipse", "Item_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "mouse", "Press", "Event_", "(_", "self_", ",_", "event_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", " ", "mouse", "Press", "Event", "(", "event", ":", " ", "QM", "ouse", "Event", ")", " ", "->", " ", "Non", "e", "\\", "10", ";", " ", " ", " ", " ", "Start", " ", "dragg", "ing", " ", "a", " ", "version", " ", "to", " ", "some", "place", "s", "...", "\\", "10", ";", " ", " ", " ", " ", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "event_", "._", "button_", "(_", ")_", "==_", "Qt", "Core_", "._", "Qt_", "._", "Le", "ft", "Button_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "dragg", "ing_", "=_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "drag", "Pos_", "=_", "Qt", "Core_", "._", "QP", "oint_", "(_", "event_", "._", "screen", "Pos_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "Qt", "Gui_", "._", "QG", "raph", "ics", "Ellipse", "Item_", "._", "mouse", "Press", "Event_", "(_", "self_", ",_", "event_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "QG", "raph", "ics", "Version", "Item_", "(_", "QG", "raph", "ics", "Item", "Interface_", ",_", "Qt", "Gui_", "._", "QG", "raph", "ics", "Ellipse", "Item_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "mouse", "Move", "Event_", "(_", "self_", ",_", "event_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", " ", "mouse", "Move", "Event", "(", "event", ":", " ", "QM", "ouse", "Event", ")", " ", "->", " ", "Non", "e", " ", " ", " ", " ", "\\", "10", ";", " ", " ", " ", " ", "No", "w", " ", "set", " ", "the", " ", "timer", " ", "prepar", "ing", " ", "for", " ", "dragg", "ing", ".", " ", "Mus", "t", " ", "use", " ", "a", " ", "timer", " ", "in", "\\", "10", ";", " ", " ", " ", " ", "junction", " ", "with", " ", "QD", "rag", " ", "in", " ", "order", " ", "to", " ", "avoid", " ", "problem", " ", "update", "s", " ", "stall", " ", "of", "\\", "10", ";", " ", " ", " ", " ", "QG", "raph", "ics", "View", ",", " ", "especial", "ly", " ", "on", " ", "Lin", "ux", "\\", "10", ";", " ", " ", " ", " ", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "(_", "self_", "._", "dragg", "ing_", "and_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "event_", "._", "screen", "Pos_", "(_", ")_", "-_", "self_", "._", "drag", "Pos_", ")_", "._", "man", "hatt", "an", "Length_", "(_", ")_", ">_", "2_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "dragg", "ing_", "=_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", "the", " ", "timer", " ", "has", " ", "unde", "sir", "able", " ", "effect", "s", " ", "on", " ", "Windows_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "system", "Type_", "not_", "in_", "[_", "'", "Window", "s", "'_", ",_", "'", "Micro", "soft", "'_", "]_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "drag", "Timer_", "._", "start_", "(_", "1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "start", "Drag", "_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "Qt", "Gui_", "._", "QG", "raph", "ics", "Ellipse", "Item_", "._", "mouse", "Move", "Event_", "(_", "self_", ",_", "event_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "super", "(", "QG", "raph", "ics", "Version", "Item", ",", " ", "self", ").", "mouse", "Move", "Event", "(", "event", ")_", "\\u\\u\\uNL\\u\\u\\u_", "[SEP]_", "class_", "QG", "raph", "ics", "Version", "Item_", "(_", "QG", "raph", "ics", "Item", "Interface_", ",_", "Qt", "Gui_", "._", "QG", "raph", "ics", "Ellipse", "Item_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "start", "Drag", "_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", " ", "start", "Drag", "()", " ", "->", " ", "Non", "e", "\\", "10", ";", " ", " ", " ", " ", "Start", " ", "the", " ", "drag", " ", "of", " ", "QD", "rag", "\\", "10", ";", " ", " ", " ", " ", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "data_", "=_", "Qt", "Core_", "._", "QM", "ime", "Data_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "data_", "._", "version", "Id_", "=_", "self_", "._", "id_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "data_", "._", "controller_", "=_", "self_", "._", "scene_", "(_", ")_", "._", "controller_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "drag", "_", "=_", "Qt", "Gui_", "._", "QD", "rag", "_", "(_", "self_", "._", "scene_", "(_", ")_", "._", "views_", "(_", ")_", "[_", "0_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "drag", "_", "._", "set", "Mim", "e", "Data_", "(_", "data_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "drag", "_", "._", "set", "Pixmap_", "(_", "Curr", "ent", "Theme_", "._", "VERSI", "ON", "\\u", "DRA", "G", "\\u", "PIX", "MAP_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "drag", "_", "._", "start_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "QG", "raph", "ics", "Version", "Item_", "(_", "QG", "raph", "ics", "Item", "Interface_", ",_", "Qt", "Gui_", "._", "QG", "raph", "ics", "Ellipse", "Item_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "mouse", "Release", "Event_", "(_", "self_", ",_", "event_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", " ", "mouse", "Release", "Event", "(", "event", ":", " ", "QM", "ouse", "Event", ")", " ", "->", " ", "Non", "e", "\\", "10", ";", " ", " ", " ", " ", "Cancel", " ", "the", " ", "drag", "\\", "10", ";", " ", " ", " ", " ", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "dragg", "ing_", "=_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "Qt", "Gui_", "._", "QG", "raph", "ics", "Ellipse", "Item_", "._", "mouse", "Release", "Event_", "(_", "self_", ",_", "event_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "QG", "raph", "ics", "Version", "Item_", "(_", "QG", "raph", "ics", "Item", "Interface_", ",_", "Qt", "Gui_", "._", "QG", "raph", "ics", "Ellipse", "Item_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "drag", "Enter", "Event_", "(_", "self_", ",_", "event_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", " ", "drag", "Enter", "Event", "(", "event", ":", " ", "QD", "rag", "Enter", "Event", ")", " ", "->", " ", "Non", "e", "\\", "10", ";", " ", " ", " ", " ", "Captur", "e", " ", "version", "-", "to", "-", "version", " ", "drag", "-", "and", "-", "drop", "\\", "10", ";", " ", " ", " ", " ", "Al", "so", " ", "captur", "e", " ", "parameter", " ", "exploration", " ", "assign", "ment", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "data_", "=_", "event_", "._", "mime", "Data_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "(_", "hasattr_", "(_", "data_", ",_", "'", "version", "Id", "'_", ")_", "and_", "\\u\\u\\uNL\\u\\u\\u_", "hasattr_", "(_", "data_", ",_", "'", "controlle", "r", "'_", ")_", "and_", "\\u\\u\\uNL\\u\\u\\u_", "data_", "._", "version", "Id_", "!=_", "self_", "._", "id_", ")_", "or_", "(_", "hasattr_", "(_", "data_", ",_", "'", "items", "'_", ")_", "and_", "\\u\\u\\uNL\\u\\u\\u_", "len_", "(_", "data_", "._", "items_", ")_", "==_", "1_", "and_", "\\u\\u\\uNL\\u\\u\\u_", "isinstance_", "(_", "data_", "._", "items_", "[_", "0_", "]_", ",_", "QP", "aram", "Explo", "ration", "Entit", "y", "Item_", ")_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "event_", "._", "accept_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "event_", "._", "ignore_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "QG", "raph", "ics", "Version", "Item_", "(_", "QG", "raph", "ics", "Item", "Interface_", ",_", "Qt", "Gui_", "._", "QG", "raph", "ics", "Ellipse", "Item_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "drop", "Event_", "(_", "self_", ",_", "event_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "data_", "=_", "event_", "._", "mime", "Data_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "(_", "hasattr_", "(_", "data_", ",_", "'", "version", "Id", "'_", ")_", "and_", "hasattr_", "(_", "data_", ",_", "'", "controlle", "r", "'_", ")_", "and_", "\\u\\u\\uNL\\u\\u\\u_", "data_", "._", "controller_", "==_", "self_", "._", "scene_", "(_", ")_", "._", "controller_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "event_", "._", "accept_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "scene_", "(_", ")_", "._", "emit_", "(_", "Qt", "Core_", "._", "SIGNAL_", "(_", "'", "diff", "Requeste", "d", "(", "int", ",", "int", ")'_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "data_", "._", "version", "Id_", ",_", "self_", "._", "id_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "vis", "Diff", " ", "=", " ", "QV", "isu", "al", "Diff", "(", "self", ".", "scen", "e", "()", ".", "controlle", "r", ".", "vist", "rail", ",_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", " ", " ", " ", " ", "data", ".", "version", "Id", ",_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", " ", " ", " ", " ", "self", ".", "id", ",_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", " ", " ", " ", " ", "self", ".", "scen", "e", "()", ".", "controlle", "r", ",_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", " ", " ", " ", " ", "self", ".", "scen", "e", "()", ".", "views", "()[", "0", "])", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "vis", "Diff", ".", "show", "()", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "(_", "hasattr_", "(_", "data_", ",_", "'", "items", "'_", ")_", "and_", "\\u\\u\\uNL\\u\\u\\u_", "len_", "(_", "data_", "._", "items_", ")_", "==_", "1_", "and_", "\\u\\u\\uNL\\u\\u\\u_", "isinstance_", "(_", "data_", "._", "items_", "[_", "0_", "]_", ",_", "QP", "aram", "Explo", "ration", "Entit", "y", "Item_", ")_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "appl", "y", " ", "this", " ", "parameter", " ", "exploration", " ", "to", " ", "the", " ", "new", " ", "version", ",", " ", "validat", "e", " ", "it", " ", "and", " ", "switch", " ", "to", " ", "PE", " ", "view_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "from_", "vist", "rail", "s_", "._", "gui_", "._", "vist", "rail", "s", "\\u", "window_", "import_", "\\u", "app_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "view_", "=_", "\\u", "app_", "._", "get", "\\u", "current", "\\u", "view_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "view_", "._", "appl", "y", "\\u", "parameter", "\\u", "exploration", "_", "(_", "self_", "._", "id_", ",_", "data_", "._", "items_", "[_", "0_", "]_", "._", "entity_", "._", "pe_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "event_", "._", "accept_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "event_", "._", "ignore_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "QG", "raph", "ics", "Version", "Item_", "(_", "QG", "raph", "ics", "Item", "Interface_", ",_", "Qt", "Gui_", "._", "QG", "raph", "ics", "Ellipse", "Item_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "perform", "\\u", "analog", "y_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "sender_", "=_", "self_", "._", "scene_", "(_", ")_", "._", "sender_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "analog", "y", "\\u", "name_", "=_", "str_", "(_", "sender_", "._", "text_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "selecte", "d", "Item", "s", " ", "=", " ", "self", ".", "scen", "e", "()", ".", "selecte", "d", "Item", "s", "()", "_", "\\u\\u\\uNL\\u\\u\\u_", "controller_", "=_", "self_", "._", "scene_", "(_", ")_", "._", "controller_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "print_", "\"", "calling", " ", "perform", " ", "analog", "y", "\"_", ",_", "analog", "y", "\\u", "name_", ",_", "self_", "._", "id_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "for", " ", "item", " ", "in", " ", "selecte", "d", "Item", "s", ":_", "\\u\\u\\uNL\\u\\u\\u_", "controller_", "._", "perform", "\\u", "analog", "y_", "(_", "analog", "y", "\\u", "name_", ",_", "self_", "._", "id_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "QG", "raph", "ics", "Version", "Item_", "(_", "QG", "raph", "ics", "Item", "Interface_", ",_", "Qt", "Gui_", "._", "QG", "raph", "ics", "Ellipse", "Item_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "show", "\\u", "raw", "\\u", "pipeline_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "scene_", "(_", ")_", "._", "emit", "\\u", "selection_", "=_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "item_", "in_", "self_", "._", "scene_", "(_", ")_", "._", "selecte", "d", "Items_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "item_", "._", "set", "Selected_", "(_", "False_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "set", "Selected_", "(_", "True_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "scene_", "(_", ")_", "._", "emit", "\\u", "selection_", "=_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "scene_", "(_", ")_", "._", "emit_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "Qt", "Core_", "._", "SIGNAL_", "(_", "'", "version", "Select", "ed", "(", "int", ",", "bool", ",", "bool", ",", "bool", ",", "bool", ")'_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "id_", ",_", "True_", ",_", "False_", ",_", "True_", ",_", "True_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "QG", "raph", "ics", "Version", "Item_", "(_", "QG", "raph", "ics", "Item", "Interface_", ",_", "Qt", "Gui_", "._", "QG", "raph", "ics", "Ellipse", "Item_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "construct", "\\u", "from", "\\u", "root_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "scene_", "(_", ")_", "._", "emit", "\\u", "selection_", "=_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "item_", "in_", "self_", "._", "scene_", "(_", ")_", "._", "selecte", "d", "Items_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "item_", "._", "set", "Selected_", "(_", "False_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "set", "Selected_", "(_", "True_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "scene_", "(_", ")_", "._", "emit", "\\u", "selection_", "=_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "scene_", "(_", ")_", "._", "emit_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "Qt", "Core_", "._", "SIGNAL_", "(_", "'", "version", "Select", "ed", "(", "int", ",", "bool", ",", "bool", ",", "bool", ",", "bool", ")'_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "id_", ",_", "True_", ",_", "True_", ",_", "True_", ",_", "True_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "QG", "raph", "ics", "Version", "Item_", "(_", "QG", "raph", "ics", "Item", "Interface_", ",_", "Qt", "Gui_", "._", "QG", "raph", "ics", "Ellipse", "Item_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "context", "Menu", "Event_", "(_", "self_", ",_", "event_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "context", "Menu", "Event", "(", "event", ":", " ", "QG", "raph", "ics", "Scen", "e", "Context", "Menu", "Event", ")", " ", "->", " ", "Non", "e", "\\", "10", ";", " ", " ", " ", " ", "Captur", "es", " ", "context", " ", "menu", " ", "event", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "controller_", "=_", "self_", "._", "scene_", "(_", ")_", "._", "controller_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "menu_", "=_", "Qt", "Gui_", "._", "QM", "enu_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "raw", "\\u", "action_", "=_", "Qt", "Gui_", "._", "QA", "ction_", "(_", "\"", "Display", " ", "raw", " ", "pipeline", "\"_", ",_", "self_", "._", "scene_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from", "\\u", "root", "\\u", "action_", "=_", "Qt", "Gui_", "._", "QA", "ction_", "(_", "\"", "Construct", " ", "from", " ", "root", "\"_", ",_", "self_", "._", "scene_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "Qt", "Core_", "._", "QO", "bject_", "._", "connect_", "(_", "raw", "\\u", "action_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "Qt", "Core_", "._", "SIGNAL_", "(_", "\"", "trigger", "ed", "()\"_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "show", "\\u", "raw", "\\u", "pipeline_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "Qt", "Core_", "._", "QO", "bject_", "._", "connect_", "(_", "from", "\\u", "root", "\\u", "action_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "Qt", "Core_", "._", "SIGNAL_", "(_", "\"", "trigger", "ed", "()\"_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "construct", "\\u", "from", "\\u", "root_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "menu_", "._", "add", "Action_", "(_", "raw", "\\u", "action_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "menu_", "._", "add", "Action_", "(_", "from", "\\u", "root", "\\u", "action_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "len_", "(_", "controller_", "._", "analog", "y_", ")_", ">_", "0_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "analog", "ies_", "=_", "Qt", "Gui_", "._", "QM", "enu_", "(_", "\"", "Perform", " ", "analog", "y", "...\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "title_", "in_", "sorted_", "(_", "controller_", "._", "analog", "y_", "._", "keys_", "(_", ")_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "act_", "=_", "Qt", "Gui_", "._", "QA", "ction_", "(_", "title_", ",_", "self_", "._", "scene_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "analog", "ies_", "._", "add", "Action_", "(_", "act_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "Qt", "Core_", "._", "QO", "bject_", "._", "connect_", "(_", "act_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "Qt", "Core_", "._", "SIGNAL_", "(_", "\"", "trigger", "ed", "()\"_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "perform", "\\u", "analog", "y_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "menu_", "._", "add", "Menu_", "(_", "analog", "ies_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "menu_", "._", "exec\\u_", "(_", "event_", "._", "screen", "Pos_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "QG", "raph", "ics", "Version", "Item_", "(_", "QG", "raph", "ics", "Item", "Interface_", ",_", "Qt", "Gui_", "._", "QG", "raph", "ics", "Ellipse", "Item_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "mouse", "Doub", "le", "Click", "Event_", "(_", "self_", ",_", "event_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Qt", "Gui", ".", "QG", "raph", "ics", "Ellipse", "Item", ".", "mouse", "Doub", "le", "Click", "Event", "(", "self", ",", " ", "event", ")_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "event_", "._", "accept_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "scene_", "(_", ")_", "._", "double", "\\u", "click_", "(_", "self_", "._", "id_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "class_", "QV", "ersi", "on", "Tree", "Scene_", "(_", "QI", "nter", "active", "Graphic", "s", "Scene_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "QV", "ersi", "on", "Tree", " ", "inherits", " ", "from", " ", "QI", "nter", "active", "Graphic", "s", "Scen", "e", " ", "to", " ", "keep", " ", "track", "\\", "10", ";", " ", " ", " ", " ", "of", " ", "the", " ", "version", " ", "scenes", ",", " ", "i", ".", "e", ".", " ", "version", "s", ",", " ", "connections", ",", " ", "etc", ".", "\\", "10", ";", " ", " ", " ", " ", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "[SEP]_", "class_", "QV", "ersi", "on", "Tree", "Scene_", "(_", "QI", "nter", "active", "Graphic", "s", "Scene_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "\\u\\u", "init\\u\\u_", "(_", "self_", ",_", "parent_", "=_", "None_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", " ", "QV", "ersi", "on", "Tree", "(", "parent", ":", " ", "QW", "idge", "t", ")", " ", "->", " ", "QV", "ersi", "on", "Tree", "\\", "10", ";", " ", " ", " ", " ", "Initializ", "e", " ", "the", " ", "graphic", "s", " ", "scen", "e", " ", "with", " ", "no", " ", "shape", "s", "\\", "10", ";", " ", " ", " ", " ", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "QI", "nter", "active", "Graphic", "s", "Scene_", "._", "\\u\\u", "init\\u\\u_", "(_", "self_", ",_", "parent_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "set", "Back", "ground", "Brush_", "(_", "Curr", "ent", "Theme_", "._", "VERSI", "ON", "\\u", "TREE", "\\u", "BACKGROUND", "\\u", "BR", "US", "H_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "set", "Scen", "e", "Rect_", "(_", "Qt", "Core_", "._", "QR", "ect", "F_", "(_", "-_", "5000_", ",_", "-_", "5000_", ",_", "10000_", ",_", "10000_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "versions_", "=_", "{_", "}_", "#", " ", "id", " ", "->", " ", "version", " ", "gui", " ", "object_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "edges_", "=_", "{_", "}_", "#", " ", "(", "source", "Version", ",", " ", "target", "Version", ")", " ", "->", " ", "edge", " ", "gui", " ", "object_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "controller_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "full", "Graph_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "emit", "\\u", "selection_", "=_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "select", "\\u", "by", "\\u", "click_", "=_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "connect_", "(_", "self_", ",_", "Qt", "Core_", "._", "SIGNAL_", "(_", "\"", "selection", "Change", "d", "()\"_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "selection", "Changed_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "QV", "ersi", "on", "Tree", "Scene_", "(_", "QI", "nter", "active", "Graphic", "s", "Scene_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "add", "Version_", "(_", "self_", ",_", "node_", ",_", "action_", ",_", "tag_", ",_", "description_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", " ", "add", "Modul", "e", "(", "node", ",", " ", "action", ":", " ", "DBA", "ction", ",", " ", "tag", ":", " ", "str", ",", " ", "description", ":", " ", "str", ",", "\\", "10", ";", " ", " ", " ", " ", "custom", "\\u", "color", ":", " ", "(", "int", ",", " ", "int", ",", " ", "int", "))\\", "10", ";", " ", " ", " ", " ", "->", " ", "Non", "e", "\\", "10", ";", " ", " ", " ", " ", "Add", " ", "a", " ", "module", " ", "to", " ", "the", " ", "scen", "e", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "version", "Shape_", "=_", "QG", "raph", "ics", "Version", "Item_", "(_", "None_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "version", "Shape_", "._", "setup", "Version_", "(_", "node_", ",_", "action_", ",_", "tag_", ",_", "description_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "add", "Item_", "(_", "version", "Shape_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "versions_", "[_", "node_", "._", "id_", "]_", "=_", "version", "Shape_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "QV", "ersi", "on", "Tree", "Scene_", "(_", "QI", "nter", "active", "Graphic", "s", "Scene_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "remove", "Version_", "(_", "self_", ",_", "v_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", " ", "add", "Link", "(", "v", ":", " ", "integ", "er", ")", " ", "->", " ", "Non", "e", "\\", "10", ";", " ", " ", " ", " ", "Remove", " ", "version", " ", "from", " ", "scen", "e", " ", "and", " ", "mapping", "\\", "10", ";", " ", " ", " ", " ", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "version", "Shape_", "=_", "self_", "._", "versions_", "[_", "v_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "remove", "Item_", "(_", "version", "Shape_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "versions_", "._", "pop_", "(_", "v_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "QV", "ersi", "on", "Tree", "Scene_", "(_", "QI", "nter", "active", "Graphic", "s", "Scene_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "add", "Link_", "(_", "self_", ",_", "gui", "Source_", ",_", "gui", "Target_", ",_", "expand_", ",_", "collapse", "_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", " ", "add", "Link", "(", "v1", ",", " ", "v2", ":", " ", "QG", "raph", "ics", "Version", "Item", ")", " ", "->", " ", "Non", "e", "\\", "10", ";", " ", " ", " ", " ", "Add", " ", "a", " ", "link", " ", "to", " ", "the", " ", "scen", "e", "\\", "10", ";", " ", " ", " ", " ", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "link", "Shape_", "=_", "QG", "raph", "ics", "Link", "Item_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "link", "Shape_", "._", "setup", "Link_", "(_", "gui", "Source_", ",_", "gui", "Target_", ",_", "expand_", ",_", "collapse", "_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "add", "Item_", "(_", "link", "Shape_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "edges_", "[_", "(_", "gui", "Source_", "._", "id_", ",_", "gui", "Target_", "._", "id_", ")_", "]_", "=_", "link", "Shape_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "QV", "ersi", "on", "Tree", "Scene_", "(_", "QI", "nter", "active", "Graphic", "s", "Scene_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "remove", "Link_", "(_", "self_", ",_", "source_", ",_", "target_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", " ", "remove", "Link", "(", "v1", ",", " ", "v2", ":", " ", "integ", "ers", ")", " ", "->", " ", "Non", "e", "\\", "10", ";", " ", " ", " ", " ", "Remove", " ", "link", " ", "from", " ", "scen", "e", " ", "and", " ", "mapping", "\\", "10", ";", " ", " ", " ", " ", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "link", "Shape_", "=_", "self_", "._", "edges_", "[_", "(_", "source_", ",_", "target_", ")_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "remove", "Item_", "(_", "link", "Shape_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "edges_", "._", "pop_", "(_", "(_", "source_", ",_", "target_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "QV", "ersi", "on", "Tree", "Scene_", "(_", "QI", "nter", "active", "Graphic", "s", "Scene_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "clear_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", " ", "clear", "()", " ", "->", " ", "Non", "e", "\\", "10", ";", " ", " ", " ", " ", "Clear", " ", "the", " ", "whole", " ", "scen", "e", "\\", "10", ";", " ", " ", " ", " ", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "versions_", "=_", "{_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "clear", "Items_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "QV", "ersi", "on", "Tree", "Scene_", "(_", "QI", "nter", "active", "Graphic", "s", "Scene_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "adjust", "\\u", "version", "\\u", "colors_", "(_", "self_", ",_", "controller_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", " ", "adjust", "\\u", "version", "\\u", "colors", "(", "controlle", "r", ":", " ", "Vis", "trail", "Controlle", "r", ")", " ", "->", " ", "Non", "e", "\\", "10", ";", " ", " ", " ", " ", "Base", "d", " ", "on", " ", "the", " ", "controlle", "r", " ", "to", " ", "set", " ", "version", " ", "colors", "\\", "10", ";", " ", " ", " ", " ", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "current", "User_", "=_", "controller_", "._", "vist", "rail", "_", "._", "get", "User_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "ranks_", "=_", "{_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "our", "Max", "Rank_", "=_", "0_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "other", "Max", "Rank_", "=_", "0_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "am_", "=_", "controller_", "._", "vist", "rail", "_", "._", "action", "Map_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "node", "Id_", "in_", "sorted_", "(_", "self_", "._", "versions_", "._", "keys_", "(_", ")_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "node", "Id_", "!=_", "0_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "node", "User_", "=_", "am_", "[_", "node", "Id_", "]_", "._", "user_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "node", "User_", "==_", "current", "User_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "ranks_", "[_", "node", "Id_", "]_", "=_", "our", "Max", "Rank_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "our", "Max", "Rank_", "+=_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "ranks_", "[_", "node", "Id_", "]_", "=_", "other", "Max", "Rank_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "other", "Max", "Rank_", "+=_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "for_", "(_", "node", "Id_", ",_", "item_", ")_", "in_", "self_", "._", "versions_", "._", "iteritems_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "node", "Id_", "==_", "0_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "item_", "._", "set", "Ghost", "ed_", "(_", "True_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "continue_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "node", "User_", "=_", "am_", "[_", "node", "Id_", "]_", "._", "user_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "controller_", "._", "search_", "and_", "node", "Id_", "!=_", "0_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "action_", "=_", "am_", "[_", "node", "Id_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "getattr_", "(_", "get", "\\u", "vist", "rail", "s", "\\u", "configuration_", "(_", ")_", ",_", "'", "hide", "Upgrade", "s", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "True_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Us", "e", " ", "upgrade", "d", " ", "version", " ", "to", " ", "match_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "action_", "=_", "am_", "[_", "controller_", "._", "vist", "rail", "_", "._", "get", "\\u", "upgrade_", "(_", "node", "Id_", ",_", "False_", ")_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "ghost", "ed_", "=_", "not_", "controller_", "._", "search_", "._", "match_", "(_", "controller_", ",_", "action_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "ghost", "ed_", "=_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", "item", ".", "set", "Ghost", "ed", "(", "ghost", "ed", ")", " ", "#", " ", "we", " ", "won", "'", "t", " ", "set", " ", "it", " ", "now", " ", "so", " ", "we", " ", "can", " ", "check", " ", "if_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "the", " ", "state", " ", "change", "d", " ", "in", " ", "update", "\\u", "color_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "node", "User_", "==_", "current", "User_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "max", "\\u", "rank_", "=_", "our", "Max", "Rank_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "max", "\\u", "rank_", "=_", "other", "Max", "Rank_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", " ", " ", " ", " ", "max", "\\u", "rank", " ", "=", " ", "our", "Max", "Rank", " ", "if", " ", "node", "User", "==", "current", "User", " ", "else", " ", "other", "Max", "Rank_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "configuration_", "=_", "get", "\\u", "vist", "rail", "s", "\\u", "configuration_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "configuration_", "._", "check_", "(_", "'", "custom", "Version", "Color", "s", "'_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "custom", "\\u", "color_", "=_", "controller_", "._", "vist", "rail", "_", "._", "get", "\\u", "action", "\\u", "annotation_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "node", "Id_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "custom", "\\u", "color", "\\u", "key_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "custom", "\\u", "color_", "is_", "not_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "custom", "\\u", "color_", "=_", "parse", "\\u", "custom", "\\u", "color_", "(_", "custom", "\\u", "color_", "._", "value_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "Value", "Error_", ",_", "e_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "debug_", "._", "warning_", "(_", "\"", "Version", " ", "%", "r", " ", "has", " ", "invalid", " ", "color", " ", "annot", "ation", " ", "\"_", "\\u\\u\\uNL\\u\\u\\u_", "\"(", "%", "s", ")\"_", "%_", "(_", "node", "Id_", ",_", "e_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "custom", "\\u", "color_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "custom", "\\u", "color_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "###", "#", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "item_", "._", "update", "\\u", "color_", "(_", "node", "User_", "==_", "current", "User_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "ranks_", "[_", "node", "Id_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "max", "\\u", "rank_", ",_", "ghost", "ed_", ",_", "custom", "\\u", "color_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "for_", "(_", "version", "\\u", "from_", ",_", "version", "\\u", "to_", ")_", ",_", "link_", "in_", "self_", "._", "edges_", "._", "iteritems_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "self_", "._", "versions_", "[_", "version", "\\u", "from_", "]_", "._", "ghost", "ed_", "and_", "self_", "._", "versions_", "[_", "version", "\\u", "to_", "]_", "._", "ghost", "ed_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "link_", "._", "set", "Ghost", "ed_", "(_", "True_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "link_", "._", "set", "Ghost", "ed_", "(_", "False_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "QV", "ersi", "on", "Tree", "Scene_", "(_", "QI", "nter", "active", "Graphic", "s", "Scene_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "update", "\\u", "scen", "e\\u", "single", "\\u", "node", "\\u", "change_", "(_", "self_", ",_", "controller_", ",_", "old", "\\u", "version_", ",_", "new", "\\u", "version_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", " ", "update", "\\u", "scen", "e\\u", "single", "\\u", "node", "\\u", "change", "(", "controlle", "r", ":", " ", "Vis", "trail", "Controlle", "r", ",", "\\", "10", ";", " ", " ", " ", " ", "old", "\\u", "version", ",", " ", "new", "\\u", "version", ":", " ", "int", ")", " ", "->", " ", "Non", "e", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "Fast", "er", " ", "alternative", " ", "to", " ", "setup", "\\u", "scen", "e", " ", "whe", "n", " ", "a", " ", "single", " ", "version", " ", "is", "\\", "10", ";", " ", " ", " ", " ", "change", "d", ".", " ", "Whe", "n", " ", "this", " ", "is", " ", "call", "ed", ",", " ", "we", " ", "know", " ", "tha", "t", " ", "bot", "h", " ", "old", "\\u", "version", "\\", "10", ";", " ", " ", " ", " ", "and", " ", "new", "\\u", "version", " ", "don", "'", "t", " ", "have", " ", "tags", " ", "associate", "d", ",", " ", "so", " ", "no", " ", "layout", "\\", "10", ";", " ", " ", " ", " ", "change", "s", " ", "happ", "en", "\\", "10", ";", " ", " ", " ", " ", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "self", ".", "setup", "Scen", "e", "(", "controlle", "r", ")_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "we", " ", "need", " ", "to", " ", "call", " ", "this", " ", "every", " ", "time", " ", "bec", "aus", "e", " ", "version", " ", "ranks", " ", "mig", "ht_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "change_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "adjust", "\\u", "version", "\\u", "colors_", "(_", "controller_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "update", " ", "version", " ", "item_", "\\u\\u\\uNL\\u\\u\\u_", "v_", "=_", "self_", "._", "versions_", "[_", "old", "\\u", "version_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "old", "\\u", "desc_", "=_", "controller_", "._", "vist", "rail", "_", "._", "get", "\\u", "description_", "(_", "old", "\\u", "version_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "new", "\\u", "desc_", "=_", "controller_", "._", "vist", "rail", "_", "._", "get", "\\u", "description_", "(_", "new", "\\u", "version_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "old", "\\u", "desc_", "!=_", "new", "\\u", "desc_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "v_", "._", "description", "Label_", "=_", "new", "\\u", "desc_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "v_", "._", "text_", "._", "changed_", "(_", "v_", "._", "text_", "._", "center", "X_", ",_", "v_", "._", "text_", "._", "center", "Y_", ",_", "new", "\\u", "desc_", ",_", "False_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "v_", "._", "update", "Wid", "th", "Fro", "m", "Label_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "versions_", "[_", "new", "\\u", "version_", "]_", "=_", "v_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "del_", "self_", "._", "versions_", "[_", "old", "\\u", "version_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "v_", "._", "id_", "=_", "new", "\\u", "version_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "update", " ", "link", " ", "items_", "\\u\\u\\uNL\\u\\u\\u_", "dst_", "=_", "controller_", "._", "\\u", "current", "\\u", "ters", "e\\u", "graph_", "._", "edge", "s", "\\u", "from_", "(_", "new", "\\u", "version_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "eto", "_", ",_", "(_", "expand_", ",_", "collapse", "_", ")_", "in_", "dst_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "edge_", "=_", "self_", "._", "edges_", "[_", "(_", "old", "\\u", "version_", ",_", "eto", "_", ")_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "edge_", "._", "setup", "Link_", "(_", "self_", "._", "versions_", "[_", "new", "\\u", "version_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "versions_", "[_", "eto", "_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "expand_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "False_", ")_", "#", " ", "We", " ", "shou", "ld", "n", "'", "t", " ", "ever", " ", "need", " ", "a", " ", "collapse", " ", "here_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "edges_", "[_", "(_", "new", "\\u", "version_", ",_", "eto", "_", ")_", "]_", "=_", "edge_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "del_", "self_", "._", "edges_", "[_", "(_", "old", "\\u", "version_", ",_", "eto", "_", ")_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "src_", "=_", "controller_", "._", "\\u", "current", "\\u", "ters", "e\\u", "graph_", "._", "edge", "s", "\\u", "to_", "(_", "new", "\\u", "version_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "ef", "rom_", ",_", "(_", "expand_", ",_", "collapse", "_", ")_", "in_", "src_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "edge_", "=_", "self_", "._", "edges_", "[_", "(_", "ef", "rom_", ",_", "old", "\\u", "version_", ")_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "edge_", "._", "setup", "Link_", "(_", "self_", "._", "versions_", "[_", "ef", "rom_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "versions_", "[_", "new", "\\u", "version_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "expand_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "False_", ")_", "#", " ", "We", " ", "shou", "ld", "n", "'", "t", " ", "ever", " ", "need", " ", "a", " ", "collapse", " ", "here_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "edges_", "[_", "(_", "ef", "rom_", ",_", "new", "\\u", "version_", ")_", "]_", "=_", "edge_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "del_", "self_", "._", "edges_", "[_", "(_", "ef", "rom_", ",_", "old", "\\u", "version_", ")_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "QV", "ersi", "on", "Tree", "Scene_", "(_", "QI", "nter", "active", "Graphic", "s", "Scene_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "setup", "Scene_", "(_", "self_", ",_", "controller_", ",_", "select", "\\u", "node_", "=_", "True_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", " ", "setup", "Scen", "e", "(", "controlle", "r", ":", " ", "Vis", "trail", "Controlle", "r", ")", " ", "->", " ", "Non", "e", "\\", "10", ";", " ", " ", " ", " ", "Construct", " ", "the", " ", "scen", "e", " ", "to", " ", "view", " ", "a", " ", "version", " ", "tree", "\\", "10", ";", " ", " ", " ", " ", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "select", "\\u", "by", "\\u", "click_", "=_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "controller_", "=_", "controller_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "perform", " ", "graph", " ", "layout_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "tree_", ",_", "self_", "._", "full", "Graph_", ",_", "layout_", ")_", "=_", "controller_", "._", "refine", "\\u", "graph_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "compute", " ", "nodes", " ", "tha", "t", " ", "shou", "ld", " ", "be", " ", "removed_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "O", "(", "n", " ", " ", "*", " ", "(", "hash", "map", " ", "query", " ", "key", " ", "time", "))", " ", "on", " _", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "where", " ", "n", " ", "is", " ", "the", " ", "number", " ", "of", " ", "current", " _", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "nodes", " ", "in", " ", "the", " ", "scene_", "\\u\\u\\uNL\\u\\u\\u_", "remove", "Node", "Set_", "=_", "set_", "(_", "i_", "for_", "i_", "in_", "self_", "._", "versions_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "not_", "i_", "in_", "tree_", "._", "vertices_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "compute", " ", "edge", "s", " ", "to", " ", "be", " ", "removed_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "O", "(", "n", " ", "*", " ", "(", "hash", "map", " ", "query", " ", "key", " ", "time", "))", " _", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "where", " ", "n", " ", "is", " ", "the", " ", "number", " ", "of", " ", "current", " _", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "edge", "s", " ", "in", " ", "the", " ", "scene_", "\\u\\u\\uNL\\u\\u\\u_", "remove", "Ed", "ge", "Set_", "=_", "set_", "(_", "(_", "s_", ",_", "t_", ")_", "for_", "(_", "s_", ",_", "t_", ")_", "in_", "self_", "._", "edges_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "(_", "s_", "in_", "remove", "Node", "Set_", "or_", "\\u\\u\\uNL\\u\\u\\u_", "t_", "in_", "remove", "Node", "Set_", "or_", "\\u\\u\\uNL\\u\\u\\u_", "not_", "tree_", "._", "has", "\\u", "edge_", "(_", "s_", ",_", "t_", ")_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "loop", " ", "on", " ", "the", " ", "nodes", " ", "of", " ", "the", " ", "tree_", "\\u\\u\\uNL\\u\\u\\u_", "vist", "rail", "_", "=_", "controller_", "._", "vist", "rail", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "am_", "=_", "vist", "rail", "_", "._", "action", "Map_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "last", "\\u", "n_", "=_", "vist", "rail", "_", "._", "get", "Las", "t", "Actions_", "(_", "controller_", "._", "num", "\\u", "version", "s", "\\u", "alw", "ay", "s", "\\u", "shown", "_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "emit", "\\u", "selection_", "=_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "node_", "in_", "layout_", "._", "nodes_", "._", "itervalues_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "version", " ", "id_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "v_", "=_", "node_", "._", "id_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "version", " ", "tag_", "\\u\\u\\uNL\\u\\u\\u_", "tag_", "=_", "tree_", "._", "vertices_", "._", "get_", "(_", "v_", ",_", "None_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "action_", "=_", "am_", "._", "get_", "(_", "v_", ",_", "None_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "description_", "=_", "vist", "rail", "_", "._", "get", "\\u", "description_", "(_", "v_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "if", " ", "the", " ", "version", " ", "gui", " ", "object", " ", "alr", "ead", "y", " ", "exist", "s", "..._", "\\u\\u\\uNL\\u\\u\\u_", "if_", "v_", "in_", "self_", "._", "versions_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "version", "Shape_", "=_", "self_", "._", "versions_", "[_", "v_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "version", "Shape_", "._", "setup", "Version_", "(_", "node_", ",_", "action_", ",_", "tag_", ",_", "description_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "add", "Version_", "(_", "node_", ",_", "action_", ",_", "tag_", ",_", "description_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "select", "\\u", "node_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "versions_", "[_", "v_", "]_", "._", "set", "Selected_", "(_", "v_", "==_", "controller_", "._", "current", "\\u", "base", "\\u", "version_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "emit", "\\u", "selection_", "=_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "selection", "Changed_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "remove", " ", "gui", " ", "edge", "s", " ", "from", " ", "scene_", "\\u\\u\\uNL\\u\\u\\u_", "for_", "(_", "v1_", ",_", "v2_", ")_", "in_", "remove", "Ed", "ge", "Set_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "remove", "Link_", "(_", "v1_", ",_", "v2_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "remove", " ", "gui", " ", "nodes", " ", "from", " ", "scene_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "for_", "v_", "in_", "remove", "Node", "Set_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "remove", "Version_", "(_", "v_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "adjust", " ", "the", " ", "colors_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "adjust", "\\u", "version", "\\u", "colors_", "(_", "controller_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Add", " ", "or", " ", "update", " ", "links_", "\\u\\u\\uNL\\u\\u\\u_", "for_", "source_", ",_", "source", "\\u", "tag_", "in_", "tree_", "._", "vertices_", "._", "iteritems_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "e", "From_", "=_", "tree_", "._", "edge", "s", "\\u", "from_", "(_", "source_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "target_", ",_", "(_", "expand_", ",_", "collapse", "_", ")_", "in_", "e", "From_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "gui", "Source_", "=_", "self_", "._", "versions_", "[_", "source_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "gui", "Target_", "=_", "self_", "._", "versions_", "[_", "target_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "self_", "._", "edges_", "._", "has", "\\u", "key_", "(_", "(_", "source_", ",_", "target_", ")_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "link", "Shape_", "=_", "self_", "._", "edges_", "[_", "(_", "source_", ",_", "target_", ")_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "link", "Shape_", "._", "setup", "Link_", "(_", "gui", "Source_", ",_", "gui", "Target_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "expand_", ",_", "collapse", "_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "self_", "._", "add", "Link_", "(_", "gui", "Source_", ",_", "gui", "Target_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "expand_", ",_", "collapse", "_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Update", " ", "bound", "ing", " ", "rect", "s", " ", "and", " ", "fit", " ", "to", " ", "all", " ", "view_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "update", "Scen", "e", "Bound", "ing", "Rect_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "select", "\\u", "by", "\\u", "click_", "=_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "QV", "ersi", "on", "Tree", "Scene_", "(_", "QI", "nter", "active", "Graphic", "s", "Scene_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "key", "Press", "Event_", "(_", "self_", ",_", "event_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", " ", "key", "Press", "Event", "(", "event", ":", " ", "QK", "ey", "Event", ")", " ", "->", " ", "Non", "e", "\\", "10", ";", " ", " ", " ", " ", "Captur", "e", " ", "'", "Del", "',", " ", "'", "Back", "space", "'", " ", "for", " ", "prun", "ing", " ", "version", "s", " ", "whe", "n", " ", "not", " ", "editin", "g", " ", "a", " ", "tag", "\\", "10", ";", " ", " ", " ", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "selecte", "d", "Items_", "=_", "self_", "._", "selecte", "d", "Items_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "versions_", "=_", "[_", "item_", "._", "id_", "for_", "item_", "in_", "selecte", "d", "Items_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "isinstance_", "(_", "item_", ",_", "QG", "raph", "ics", "Version", "Item_", ")_", "\\u\\u\\uNL\\u\\u\\u_", "and_", "not_", "item_", "._", "text_", "._", "has", "Focus_", "(_", ")_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "(_", "self_", "._", "controller_", "and_", "len_", "(_", "versions_", ")_", ">_", "0_", "and_", "\\u\\u\\uNL\\u\\u\\u_", "event_", "._", "key_", "(_", ")_", "in_", "[_", "Qt", "Core_", "._", "Qt_", "._", "Key", "\\u", "Back", "space_", ",_", "Qt", "Core_", "._", "Qt_", "._", "Key", "\\u", "Delete_", "]_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "event_", "._", "accept_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "versions_", "=_", "[_", "item_", "._", "id_", "for_", "item_", "in_", "selecte", "d", "Items_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "res_", "=_", "vist", "rail", "s_", "._", "gui_", "._", "utils_", "._", "show", "\\u", "question_", "(_", "\"", "Vis", "Trail", "s", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "Are", " ", "you", " ", "sure", " ", "tha", "t", " ", "you", " ", "want", " ", "to", " ", "\"_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "prune", " ", "the", " ", "selecte", "d", " ", "version", "(", "s", ")?", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "[_", "vist", "rail", "s_", "._", "gui_", "._", "utils_", "._", "YE", "S", "\\u", "BUTTON_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "vist", "rail", "s_", "._", "gui_", "._", "utils_", "._", "NO", "\\u", "BUTTON_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "vist", "rail", "s_", "._", "gui_", "._", "utils_", "._", "NO", "\\u", "BUTTON_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "res_", "==_", "vist", "rail", "s_", "._", "gui_", "._", "utils_", "._", "YE", "S", "\\u", "BUTTON_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "controller_", "._", "prune", "\\u", "versions_", "(_", "versions_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "qt", "\\u", "super_", "(_", "QV", "ersi", "on", "Tree", "Scene_", ",_", "self_", ")_", "._", "key", "Press", "Event_", "(_", "event_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "QV", "ersi", "on", "Tree", "Scene_", "(_", "QI", "nter", "active", "Graphic", "s", "Scene_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "selection", "Changed_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "not_", "self_", "._", "emit", "\\u", "selection_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "selecte", "d\\u", "items_", "=_", "self_", "._", "selecte", "d", "Items_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "len_", "(_", "selecte", "d\\u", "items_", ")_", "==_", "1_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "emit", " ", "version", "Select", "ed", " ", "selecte", "d\\u", "id_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "emit_", "(_", "Qt", "Core_", "._", "SIGNAL_", "(_", "'", "version", "Select", "ed", "(", "int", ",", "bool", ",", "bool", ",", "bool", ",", "bool", ")'_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "selecte", "d\\u", "items_", "[_", "0_", "]_", "._", "id_", ",_", "self_", "._", "select", "\\u", "by", "\\u", "click_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "True_", ",_", "False_", ",_", "False_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "emit", " ", "version", "Select", "ed", " ", "-1", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "for_", "item_", "in_", "selecte", "d\\u", "items_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "item_", "._", "text_", "._", "is", "Editable", "_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "item_", "._", "text_", "._", "set", "Editable", "_", "(_", "False_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "emit_", "(_", "Qt", "Core_", "._", "SIGNAL_", "(_", "'", "version", "Select", "ed", "(", "int", ",", "bool", ",", "bool", ",", "bool", ",", "bool", ")'_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "-_", "1_", ",_", "self_", "._", "select", "\\u", "by", "\\u", "click_", ",_", "True_", ",_", "False_", ",_", "False_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "len_", "(_", "selecte", "d\\u", "items_", ")_", "==_", "2_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "emit_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "Qt", "Core_", "._", "SIGNAL_", "(_", "'", "two", "Version", "s", "Select", "ed", "(", "int", ",", " ", "int", ")'_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "selecte", "d\\u", "items_", "[_", "0_", "]_", "._", "id_", ",_", "selecte", "d\\u", "items_", "[_", "1_", "]_", "._", "id_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "QV", "ersi", "on", "Tree", "Scene_", "(_", "QI", "nter", "active", "Graphic", "s", "Scene_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "double", "\\u", "click_", "(_", "self_", ",_", "version", "\\u", "id_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "mouse", "Grab", "ber", "Item_", "(_", ")_", "._", "ung", "rab", "Mouse", "_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "emit_", "(_", "Qt", "Core_", "._", "SIGNAL_", "(_", "'", "version", "Select", "ed", "(", "int", ",", "bool", ",", "bool", ",", "bool", ",", "bool", ")'_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "version", "\\u", "id_", ",_", "self_", "._", "select", "\\u", "by", "\\u", "click_", ",_", "True_", ",_", "False_", ",_", "True_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "class_", "QV", "ersi", "on", "Tree", "View_", "(_", "QI", "nter", "active", "Graphic", "s", "View_", ",_", "Base", "View_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "QV", "ersi", "on", "Tree", "View", " ", "inherits", " ", "from", " ", "QI", "nter", "active", "Graphic", "s", "View", " ", "tha", "t", " ", "will", "\\", "10", ";", " ", " ", " ", " ", "handle", " ", "drawing", " ", "of", " ", "version", "s", " ", "layout", " ", "output", " ", "from", " ", "Dot", "ty", "\\", "10", ";", " ", " ", " ", " ", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "[SEP]_", "class_", "QV", "ersi", "on", "Tree", "View_", "(_", "QI", "nter", "active", "Graphic", "s", "View_", ",_", "Base", "View_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "\\u\\u", "init\\u\\u_", "(_", "self_", ",_", "parent_", "=_", "None_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", " ", "QV", "ersi", "on", "Tree", "View", "(", "parent", ":", " ", "QW", "idge", "t", ")", " ", "->", " ", "QV", "ersi", "on", "Tree", "View", "\\", "10", ";", " ", " ", " ", " ", "Initializ", "e", " ", "the", " ", "graphic", "s", " ", "view", " ", "and", " ", "its", " ", "proper", "ties", "\\", "10", ";", " ", " ", " ", " ", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "QI", "nter", "active", "Graphic", "s", "View_", "._", "\\u\\u", "init\\u\\u_", "(_", "self_", ",_", "parent_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "Base", "View_", "._", "\\u\\u", "init\\u\\u_", "(_", "self_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "controller_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "set\\u", "title_", "(_", "'", "Version", " ", "Tree", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "set", "Scene_", "(_", "QV", "ersi", "on", "Tree", "Scene_", "(_", "self_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "version", "Prop_", "=_", "QV", "ersi", "on", "Prop", "Overla", "y_", "(_", "self_", ",_", "self_", "._", "viewport_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "version", "Prop_", "._", "hide_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "\\u", "view", "\\u", "fitted", "_", "=_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "QV", "ersi", "on", "Tree", "View_", "(_", "QI", "nter", "active", "Graphic", "s", "View_", ",_", "Base", "View_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "set\\u", "default", "\\u", "layout_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "from_", "vist", "rail", "s_", "._", "gui_", "._", "collection_", "._", "workspace_", "import_", "QW", "ork", "space", "Window_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "vist", "rail", "s_", "._", "gui_", "._", "version", "\\u", "prop_", "import_", "QV", "ersi", "on", "Prop_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "set\\u", "palette", "\\u", "layout_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "{_", "Qt", "Core_", "._", "Qt_", "._", "Le", "ft", "Dock", "Wid", "get", "Area_", ":_", "QW", "ork", "space", "Window_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "Qt", "Core_", "._", "Qt_", "._", "Rig", "ht", "Dock", "Wid", "get", "Area_", ":_", "QV", "ersi", "on", "Prop_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "}_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "QV", "ersi", "on", "Tree", "View_", "(_", "QI", "nter", "active", "Graphic", "s", "View_", ",_", "Base", "View_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "set\\u", "action", "\\u", "links_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "action", "\\u", "links_", "=_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "'", "publi", "sh", "Web", "'_", ":_", "(_", "'", "version", "\\u", "change", "d", "'_", ",_", "self_", "._", "check", "\\u", "publi", "sh", "\\u", "db_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "publi", "sh", "Pap", "er", "'_", ":_", "(_", "'", "version", "\\u", "change", "d", "'_", ",_", "self_", "._", "check", "\\u", "publish_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "redo", "'_", ":_", "(_", "'", "version", "\\u", "change", "d", "'_", ",_", "self_", "._", "can", "\\u", "redo", "_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "undo", "'_", ":_", "(_", "'", "version", "\\u", "change", "d", "'_", ",_", "self_", "._", "can", "\\u", "undo_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "execute", "'_", ":_", "(_", "'", "pipeline", "\\u", "change", "d", "'_", ",_", "self_", "._", "can", "\\u", "execute_", ")_", "\\u\\u\\uNL\\u\\u\\u_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "QV", "ersi", "on", "Tree", "View_", "(_", "QI", "nter", "active", "Graphic", "s", "View_", ",_", "Base", "View_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "set\\u", "action", "\\u", "defaults_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "action", "\\u", "defaults_", "[_", "'", "execute", "'_", "]_", "=_", "[_", "(_", "'", "set", "Enable", "d", "'_", ",_", "True_", ",_", "self_", "._", "set\\u", "action", "\\u", "execute", "\\u", "default_", ")_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "QV", "ersi", "on", "Tree", "View_", "(_", "QI", "nter", "active", "Graphic", "s", "View_", ",_", "Base", "View_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "set\\u", "action", "\\u", "execute", "\\u", "default_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "self_", "._", "controller_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "self_", "._", "controller_", "._", "current", "\\u", "pipeline_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "len_", "(_", "self_", "._", "controller_", "._", "current", "\\u", "pipeline_", "._", "modules_", ")_", ">_", "0_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "QV", "ersi", "on", "Tree", "View_", "(_", "QI", "nter", "active", "Graphic", "s", "View_", ",_", "Base", "View_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "check", "\\u", "publi", "sh", "\\u", "db_", "(_", "self_", ",_", "version", "Id_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "loc_", "=_", "self_", "._", "controller_", "._", "locator_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "result_", "=_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "hasattr_", "(_", "loc_", ",_", "'", "host", "'_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "result_", "=_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "result_", "and_", "self_", "._", "check", "\\u", "publish_", "(_", "version", "Id_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "QV", "ersi", "on", "Tree", "View_", "(_", "QI", "nter", "active", "Graphic", "s", "View_", ",_", "Base", "View_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "check", "\\u", "publish_", "(_", "self_", ",_", "version", "Id_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "version", "Id_", ">_", "0_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "QV", "ersi", "on", "Tree", "View_", "(_", "QI", "nter", "active", "Graphic", "s", "View_", ",_", "Base", "View_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "can", "\\u", "redo", "_", "(_", "self_", ",_", "version", "Id_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "self_", "._", "controller_", "and_", "self_", "._", "controller_", "._", "can", "\\u", "redo", "_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "QV", "ersi", "on", "Tree", "View_", "(_", "QI", "nter", "active", "Graphic", "s", "View_", ",_", "Base", "View_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "can", "\\u", "undo_", "(_", "self_", ",_", "version", "Id_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "self_", "._", "controller_", "and_", "self_", "._", "controller_", "._", "can", "\\u", "undo_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "QV", "ersi", "on", "Tree", "View_", "(_", "QI", "nter", "active", "Graphic", "s", "View_", ",_", "Base", "View_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "can", "\\u", "execute_", "(_", "self_", ",_", "pipeline_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "pipeline_", "is_", "not_", "None_", "and_", "len_", "(_", "pipeline_", "._", "modules_", ")_", ">_", "0_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "QV", "ersi", "on", "Tree", "View_", "(_", "QI", "nter", "active", "Graphic", "s", "View_", ",_", "Base", "View_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "execute_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "res_", "=_", "self_", "._", "controller_", "._", "execute", "\\u", "user", "\\u", "workflow_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "vist", "rail", "s_", "._", "gui_", "._", "vist", "rail", "s", "\\u", "window_", "import_", "\\u", "app_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "len_", "(_", "res_", "[_", "0_", "]_", "[_", "0_", "]_", "._", "errors_", ")_", ">_", "0_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\\u", "app_", "._", "qa", "ctions", "_", "[_", "'", "pipeline", "'_", "]_", "._", "trigger_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u", "app_", "._", "notify_", "(_", "'", "executi", "on", "\\u", "update", "d", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "QV", "ersi", "on", "Tree", "View_", "(_", "QI", "nter", "active", "Graphic", "s", "View_", ",_", "Base", "View_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "publi", "sh", "\\u", "to", "\\u", "web_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "from_", "vist", "rail", "s_", "._", "gui_", "._", "publishing", "_", "import_", "QV", "ersi", "on", "Embed_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "panel_", "=_", "QV", "ersi", "on", "Embed_", "._", "instance_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "panel_", "._", "switch", "Type_", "(_", "'", "Wiki", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "panel_", "._", "set\\u", "visible_", "(_", "True_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "QV", "ersi", "on", "Tree", "View_", "(_", "QI", "nter", "active", "Graphic", "s", "View_", ",_", "Base", "View_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "publi", "sh", "\\u", "to", "\\u", "paper_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "from_", "vist", "rail", "s_", "._", "gui_", "._", "publishing", "_", "import_", "QV", "ersi", "on", "Embed_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "panel_", "=_", "QV", "ersi", "on", "Embed_", "._", "instance_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "panel_", "._", "switch", "Type_", "(_", "'", "Latex", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "panel_", "._", "set\\u", "visible_", "(_", "True_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "QV", "ersi", "on", "Tree", "View_", "(_", "QI", "nter", "active", "Graphic", "s", "View_", ",_", "Base", "View_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "select", "Modules_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", " ", "select", "Modul", "es", "()", " ", "->", " ", "Non", "e", "\\", "10", ";", " ", " ", " ", " ", "Override", "s", " ", "parent", " ", "class", " ", "to", " ", "disable", " ", "text", " ", "items", " ", "if", " ", "you", " ", "click", " ", "on", " ", "background", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "self_", "._", "can", "Select", "Rectangle_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "br_", "=_", "self_", "._", "selection", "Box_", "._", "scen", "e", "Bound", "ing", "Rect_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "br_", "=_", "Qt", "Core_", "._", "QR", "ect", "F_", "(_", "self_", "._", "start", "Selecti", "ng", "Pos_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "start", "Selecti", "ng", "Pos_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "items_", "=_", "self_", "._", "scene_", "(_", ")_", "._", "items_", "(_", "br_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "len_", "(_", "items_", ")_", "==_", "0_", "or_", "items_", "==_", "[_", "self_", "._", "selection", "Box_", "]_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "for_", "item_", "in_", "self_", "._", "scene_", "(_", ")_", "._", "selecte", "d", "Items_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "isinstance_", "(_", "item_", ",_", "QG", "raph", "ics", "Version", "Item_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "item_", "._", "text_", "._", "clear", "Focus_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "qt", "\\u", "super_", "(_", "QV", "ersi", "on", "Tree", "View_", ",_", "self_", ")_", "._", "select", "Modules_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "QV", "ersi", "on", "Tree", "View_", "(_", "QI", "nter", "active", "Graphic", "s", "View_", ",_", "Base", "View_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "set\\u", "title_", "(_", "self_", ",_", "title_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "Base", "View_", "._", "set\\u", "title_", "(_", "self_", ",_", "title_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "set", "Window", "Title_", "(_", "title_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "QV", "ersi", "on", "Tree", "View_", "(_", "QI", "nter", "active", "Graphic", "s", "View_", ",_", "Base", "View_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "set\\u", "controller_", "(_", "self_", ",_", "controller_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "\\u", "view", "\\u", "fitted", "_", "=_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "old", "Controller_", "=_", "self_", "._", "controller_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "old", "Controller_", "!=_", "controller_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "old", "Controller_", "is_", "not_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "disconnect_", "(_", "old", "Controller_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "Qt", "Core_", "._", "SIGNAL_", "(_", "'", "vist", "rail", "Change", "d", "()'_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "vist", "rail", "Changed_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "disconnect_", "(_", "old", "Controller_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "Qt", "Core_", "._", "SIGNAL_", "(_", "'", "invalidate", "Sing", "le", "Node", "In", "Version", "Tree", "'_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "single", "\\u", "node", "\\u", "changed_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "disconnect_", "(_", "old", "Controller_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "Qt", "Core_", "._", "SIGNAL_", "(_", "'", "note", "s", "Change", "d", "()'_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "note", "s", "Changed_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "controller_", "=_", "controller_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "scene_", "(_", ")_", "._", "controller_", "=_", "controller_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "connect_", "(_", "controller_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "Qt", "Core_", "._", "SIGNAL_", "(_", "'", "vist", "rail", "Change", "d", "()'_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "vist", "rail", "Changed_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "connect_", "(_", "controller_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "Qt", "Core_", "._", "SIGNAL_", "(_", "'", "invalidate", "Sing", "le", "Node", "In", "Version", "Tree", "'_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "single", "\\u", "node", "\\u", "changed_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "connect_", "(_", "controller_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "Qt", "Core_", "._", "SIGNAL_", "(_", "\"", "note", "s", "Change", "d", "()\"_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "note", "s", "Changed_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "controller_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "version", "Prop_", "._", "update", "Controller_", "(_", "controller_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "scene_", "(_", ")_", "._", "setup", "Scene_", "(_", "controller_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "self", ".", "vist", "rail", "Change", "d", "()", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "self", ".", "version", "Prop", ".", "update", "Controlle", "r", "(", "controlle", "r", ")_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "self", ".", "version", "View", ".", "version", "Prop", ".", "update", "Controlle", "r", "(", "controlle", "r", ")_", "\\u\\u\\uNL\\u\\u\\u_", "[SEP]_", "class_", "QV", "ersi", "on", "Tree", "View_", "(_", "QI", "nter", "active", "Graphic", "s", "View_", ",_", "Base", "View_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "vist", "rail", "Changed_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", " ", "vist", "rail", "Change", "d", "()", " ", "->", " ", "Non", "e", "\\", "10", ";", " ", " ", " ", " ", "An", " ", "action", " ", "was", " ", "perform", "ed", " ", "on", " ", "the", " ", "current", " ", "vist", "rail", "\\", "10", ";", " ", " ", " ", " ", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "vist", "rail", "s_", "._", "gui_", "._", "vist", "rail", "s", "\\u", "window_", "import_", "\\u", "app_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "select", "\\u", "node_", "=_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "\\u", "app_", "._", "\\u", "previ", "ous", "\\u", "view_", "and_", "\\u", "app_", "._", "\\u", "previ", "ous", "\\u", "view_", "._", "window_", "(_", ")_", "!=_", "self_", "._", "window_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "select", "\\u", "node_", "=_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "scene_", "(_", ")_", "._", "setup", "Scene_", "(_", "self_", "._", "controller_", ",_", "select", "\\u", "node_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "self_", "._", "controller_", "and_", "self_", "._", "controller_", "._", "reset", "\\u", "version", "\\u", "view_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "scene_", "(_", ")_", "._", "fit", "To", "All", "Views_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "self_", "._", "controller_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "self", ".", "version", "Prop", ".", "update", "Version", "(", "self", ".", "controlle", "r", ".", "current", "\\u", "version", ")_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "version", "Prop_", "._", "update", "Version_", "(_", "self_", "._", "controller_", "._", "current", "\\u", "version_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "emit_", "(_", "Qt", "Core_", "._", "SIGNAL_", "(_", "\"", "vist", "rail", "Change", "d", "()\"_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "QV", "ersi", "on", "Tree", "View_", "(_", "QI", "nter", "active", "Graphic", "s", "View_", ",_", "Base", "View_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "single", "\\u", "node", "\\u", "changed_", "(_", "self_", ",_", "old", "\\u", "version_", ",_", "new", "\\u", "version_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", " ", "single", "\\u", "node", "\\u", "change", "d", "(", "old", "\\u", "version", ",", " ", "new", "\\u", "version", ")", "\\", "10", ";", " ", " ", " ", " ", "Handle", " ", "single", " ", "node", " ", "change", " ", "on", " ", "version", " ", "tree", " ", "by", " ", "not", " ", "recom", "put", "ing", "\\", "10", ";", " ", " ", " ", " ", "entire", " ", "scen", "e", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "scene_", "(_", ")_", "._", "update", "\\u", "scen", "e\\u", "single", "\\u", "node", "\\u", "change_", "(_", "self_", "._", "controller_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "old", "\\u", "version_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "new", "\\u", "version_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "self_", "._", "controller_", "and_", "self_", "._", "controller_", "._", "reset", "\\u", "version", "\\u", "view_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "scene_", "(_", ")_", "._", "fit", "To", "All", "Views_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "self_", "._", "controller_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "self", ".", "version", "Prop", ".", "update", "Version", "(", "self", ".", "controlle", "r", ".", "current", "\\u", "version", ")_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "version", "Prop_", "._", "update", "Version_", "(_", "self_", "._", "controller_", "._", "current", "\\u", "version_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "emit_", "(_", "Qt", "Core_", "._", "SIGNAL_", "(_", "\"", "vist", "rail", "Change", "d", "()\"_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "QV", "ersi", "on", "Tree", "View_", "(_", "QI", "nter", "active", "Graphic", "s", "View_", ",_", "Base", "View_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "note", "s", "Changed_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", " ", "note", "s", "Change", "d", "()", " ", "->", " ", "Non", "e", "\\", "10", ";", " ", " ", " ", " ", "The", " ", "note", "s", " ", "for", " ", "the", " ", "current", " ", "vist", "rail", " ", "version", " ", "change", "d", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "self_", "._", "controller_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "version", "Prop_", "._", "update", "Version_", "(_", "self_", "._", "controller_", "._", "current", "\\u", "version_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "QV", "ersi", "on", "Tree", "View_", "(_", "QI", "nter", "active", "Graphic", "s", "View_", ",_", "Base", "View_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "select", "\\u", "current", "\\u", "version_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "scene_", "(_", ")_", "._", "setup", "Scene_", "(_", "self_", "._", "controller_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "QV", "ersi", "on", "Tree", "View_", "(_", "QI", "nter", "active", "Graphic", "s", "View_", ",_", "Base", "View_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "view", "Selected_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "not_", "self_", "._", "\\u", "view", "\\u", "fitted", "_", "and_", "self_", "._", "is", "Visible_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "We", " ", "only", " ", "do", " ", "this", " ", "onc", "e", " ", "after", " ", "a", " ", "set\\u", "controlle", "r", "()", " ", "call_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "zoom", "To", "Fit_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "\\u", "view", "\\u", "fitted", "_", "=_", "True_" ]
[ 4, 4, 4, 4, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,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2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 ]
Testing equality to None
elmar-hinz/Python.Vii/tests/Dispatcher_Test.py
[ { "content": " def test__init__(self):\n fixture = Dispatcher()\n assert fixture.actionManager == None\n assert fixture.currentMode == None\n assert fixture.currentAction == None\n assert fixture.currentCommand == None\n assert fixture.forceTokenToString == False", "metadata": "root.Dispatcher_Test.test__init__", "header": "['class', 'Dispatcher_Test', ':', '___EOS___']", "index": 26 }, { "content": " def test_stepInit(self):\n assert self.fixture.currentMode == None\n assert self.fixture.currentAction == None\n self.fixture.stepInit(\"a\")\n assert self.fixture.currentMode == \"normal\"\n assert self.fixture.currentAction == self.action\n command = self.fixture.currentCommand\n assert command.__class__ == Command", "metadata": "root.Dispatcher_Test.test_stepInit", "header": "['class', 'Dispatcher_Test', ':', '___EOS___']", "index": 38 } ]
[ { "span": "fixture.actionManager == None", "start_line": 28, "start_column": 15, "end_line": 28, "end_column": 44 }, { "span": "fixture.currentMode == None", "start_line": 29, "start_column": 15, "end_line": 29, "end_column": 42 }, { "span": "fixture.currentAction == None", "start_line": 30, "start_column": 15, "end_line": 30, "end_column": 44 }, { "span": "fixture.currentCommand == None", "start_line": 31, "start_column": 15, "end_line": 31, "end_column": 45 }, { "span": "self.fixture.currentMode == None", "start_line": 39, "start_column": 15, "end_line": 39, "end_column": 47 }, { "span": "self.fixture.currentAction == None", "start_line": 40, "start_column": 15, "end_line": 40, "end_column": 49 } ]
[]
1
true
[ "[CLS]_", "Test", "ing_", "equality", "_", "to_", "None_", "[SEP]_", "class_", "Dispatcher", "\\u", "Test_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "\\u", "init\\u\\u_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "fixture_", "=_", "Dispatcher_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "assert_", "fixture_", "._", "action", "Manager_", "==_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "assert_", "fixture_", "._", "current", "Mode_", "==_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "assert_", "fixture_", "._", "current", "Action_", "==_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "assert_", "fixture_", "._", "current", "Command_", "==_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "assert_", "fixture_", "._", "force", "Token", "To", "String_", "==_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Dispatcher", "\\u", "Test_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "step", "Init_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "assert_", "self_", "._", "fixture_", "._", "current", "Mode_", "==_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "assert_", "self_", "._", "fixture_", "._", "current", "Action_", "==_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "fixture_", "._", "step", "Init_", "(_", "\"", "a", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "assert_", "self_", "._", "fixture_", "._", "current", "Mode_", "==_", "\"", "normal", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "assert_", "self_", "._", "fixture_", "._", "current", "Action_", "==_", "self_", "._", "action_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "command_", "=_", "self_", "._", "fixture_", "._", "current", "Command_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "assert_", "command_", "._", "\\u\\u", "class\\u\\u_", "==_", "Command_", "\\u\\u\\uNEWLINE\\u\\u\\u_" ]
[ 4, 4, 4, 4, 4, 4, 4, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 1, 1, 1, 1, 1, 2, 2, 0, 1, 1, 1, 1, 1, 2, 2, 0, 1, 1, 1, 1, 1, 2, 2, 0, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 1, 1, 1, 1, 1, 1, 1, 2, 2, 0, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 ]
Unreachable code
JoelBender/bacpypes/pcap_tools/WhoIsRouterToNetworkSummaryFilter.py
[ { "content": "#!/usr/bin/python\n\n\"\"\"\nSummarize Who-Is-Router-To-Network Notifications\n\"\"\"\n\nimport sys\nfrom collections import defaultdict\n\nfrom bacpypes.debugging import Logging, function_debugging, ModuleLogger\nfrom bacpypes.consolelogging import ConsoleLogHandler\n\nfrom bacpypes.pdu import Address\nfrom bacpypes.analysis import trace, strftimestamp, Tracer\nfrom bacpypes.npdu import WhoIsRouterToNetwork\n\n# some debugging\n_debug = 0\n_log = ModuleLogger(globals())\n\n# globals\nfilterSource = None\nfilterDestination = None\nfilterHost = None\n\n# dictionary of requests\nrequests = defaultdict(int)\nnetworks = defaultdict(list)\n\n#\n# Match\n#\n\n\n#\n# WhoIsRouterToNetworkSummary\n#\n\n\n#\n# __main__\n#\n\ntry:\n if ('--debug' in sys.argv):\n indx = sys.argv.index('--debug')\n for i in range(indx+1, len(sys.argv)):\n ConsoleLogHandler(sys.argv[i])\n del sys.argv[indx:]\n\n if _debug: _log.debug(\"initialization\")\n\n # check for src\n if ('--src' in sys.argv):\n i = sys.argv.index('--src')\n filterSource = Address(sys.argv[i+1])\n if _debug: _log.debug(\" - filterSource: %r\", filterSource)\n del sys.argv[i:i+2]\n\n # check for dest\n if ('--dest' in sys.argv):\n i = sys.argv.index('--dest')\n filterDestination = Address(sys.argv[i+1])\n if _debug: _log.debug(\" - filterDestination: %r\", filterDestination)\n del sys.argv[i:i+2]\n\n # check for host\n if ('--host' in sys.argv):\n i = sys.argv.index('--host')\n filterHost = Address(sys.argv[i+1])\n if _debug: _log.debug(\" - filterHost: %r\", filterHost)\n del sys.argv[i:i+2]\n\n # trace the file(s)\n for fname in sys.argv[1:]:\n trace(fname, [WhoIsRouterToNetworkSummary])\n\n # sort the result, descending order by count\n items = requests.items()\n items.sort(lambda x, y: cmp(y[1], x[1]))\n\n # print everything out\n print \"%-20s %5s\" % (\"Address\", \"Count\")\n for key, count in items:\n print \"%-20s %5d\" % (key, count)\n\n # count the number of times of each network\n net_count = defaultdict(int)\n for net in networks[key]:\n net_count[net] += 1\n\n # sort descending\n net_count = net_count.items()\n net_count.sort(lambda x, y: cmp(y[1], x[1]))\n\n for net, count in net_count:\n print \" %5d %5d\" % (net, count)\n\nexcept KeyboardInterrupt:\n pass\nexcept Exception, e:\n _log.exception(\"an error has occurred: %s\", e)\nfinally:\n if _debug: _log.debug(\"finally\")\n\n", "metadata": "root", "header": "['module', '___EOS___']", "index": 0 } ]
[ { "span": "_log.debug(\"initialization\")", "start_line": 105, "start_column": 15, "end_line": 105, "end_column": 43 }, { "span": "_log.debug(\" - filterSource: %r\", filterSource)", "start_line": 111, "start_column": 19, "end_line": 111, "end_column": 69 }, { "span": "_log.debug(\" - filterDestination: %r\", filterDestination)", "start_line": 118, "start_column": 19, "end_line": 118, "end_column": 79 }, { "span": "_log.debug(\" - filterHost: %r\", filterHost)", "start_line": 125, "start_column": 19, "end_line": 125, "end_column": 65 }, { "span": "_log.debug(\"finally\")", "start_line": 158, "start_column": 15, "end_line": 158, "end_column": 36 } ]
[]
1
true
[ "[CLS]_", "Unrea", "chab", "le_", "code_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "#!", "/", "usr", "/", "bin", "/", "python_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\"\"\"", "\\", "10", ";", "Summari", "ze", " ", "Who", "-", "Is", "-", "Route", "r", "-", "To", "-", "Network", " ", "Notifi", "cations", "\\", "10", ";\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "import_", "sys_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "collections_", "import_", "defaultdict_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "from_", "bac", "pype", "s_", "._", "debugg", "ing_", "import_", "Logging_", ",_", "function", "\\u", "debugg", "ing_", ",_", "Modul", "e", "Logger_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "bac", "pype", "s_", "._", "console", "logging_", "import_", "Cons", "ole", "Log", "Handler_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "from_", "bac", "pype", "s_", "._", "pdu_", "import_", "Address_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "bac", "pype", "s_", "._", "analysis_", "import_", "trace_", ",_", "strf", "timestamp_", ",_", "Tracer", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "bac", "pype", "s_", "._", "np", "du_", "import_", "Who", "Is", "Route", "r", "To", "Network_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "some", " ", "debugg", "ing_", "\\u\\u\\uNL\\u\\u\\u_", "\\u", "debug_", "=_", "0_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u", "log_", "=_", "Modul", "e", "Logger_", "(_", "globals_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "globals_", "\\u\\u\\uNL\\u\\u\\u_", "filter", "Source_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "filter", "Destination_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "filter", "Host_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "dictionar", "y", " ", "of", " ", "requests_", "\\u\\u\\uNL\\u\\u\\u_", "requests_", "=_", "defaultdict_", "(_", "int_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "networks_", "=_", "defaultdict_", "(_", "list_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", " ", " ", "Match_", "\\u\\u\\uNL\\u\\u\\u_", "#", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", " ", " ", "Who", "Is", "Route", "r", "To", "Network", "Summary_", "\\u\\u\\uNL\\u\\u\\u_", "#", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", " ", " ", "\\u\\u", "main\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "(_", "'--", "debug", "'_", "in_", "sys_", "._", "argv_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "indx_", "=_", "sys_", "._", "argv_", "._", "index_", "(_", "'--", "debug", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "i_", "in_", "range_", "(_", "indx_", "+_", "1_", ",_", "len_", "(_", "sys_", "._", "argv_", ")_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "Cons", "ole", "Log", "Handler_", "(_", "sys_", "._", "argv_", "[_", "i_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "del_", "sys_", "._", "argv_", "[_", "indx_", ":_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "\\u", "debug_", ":_", "\\u", "log_", "._", "debug_", "(_", "\"", "initialization", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "check", " ", "for", " ", "src_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "(_", "'--", "src", "'_", "in_", "sys_", "._", "argv_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "i_", "=_", "sys_", "._", "argv_", "._", "index_", "(_", "'--", "src", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "filter", "Source_", "=_", "Address_", "(_", "sys_", "._", "argv_", "[_", "i_", "+_", "1_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "\\u", "debug_", ":_", "\\u", "log_", "._", "debug_", "(_", "\"", " ", " ", " ", " ", "-", " ", "filter", "Sou", "rce", ":", " ", "%", "r", "\"_", ",_", "filter", "Source_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "del_", "sys_", "._", "argv_", "[_", "i_", ":_", "i_", "+_", "2_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "check", " ", "for", " ", "dest_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "(_", "'--", "dest", "'_", "in_", "sys_", "._", "argv_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "i_", "=_", "sys_", "._", "argv_", "._", "index_", "(_", "'--", "dest", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "filter", "Destination_", "=_", "Address_", "(_", "sys_", "._", "argv_", "[_", "i_", "+_", "1_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "\\u", "debug_", ":_", "\\u", "log_", "._", "debug_", "(_", "\"", " ", " ", " ", " ", "-", " ", "filter", "Dest", "ination", ":", " ", "%", "r", "\"_", ",_", "filter", "Destination_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "del_", "sys_", "._", "argv_", "[_", "i_", ":_", "i_", "+_", "2_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "check", " ", "for", " ", "host_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "(_", "'--", "host", "'_", "in_", "sys_", "._", "argv_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "i_", "=_", "sys_", "._", "argv_", "._", "index_", "(_", "'--", "host", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "filter", "Host_", "=_", "Address_", "(_", "sys_", "._", "argv_", "[_", "i_", "+_", "1_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "\\u", "debug_", ":_", "\\u", "log_", "._", "debug_", "(_", "\"", " ", " ", " ", " ", "-", " ", "filter", "Host", ":", " ", "%", "r", "\"_", ",_", "filter", "Host_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "del_", "sys_", "._", "argv_", "[_", "i_", ":_", "i_", "+_", "2_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "trace", " ", "the", " ", "file", "(", "s", ")_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "for_", "fname_", "in_", "sys_", "._", "argv_", "[_", "1_", ":_", "]_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "trace_", "(_", "fname_", ",_", "[_", "Who", "Is", "Route", "r", "To", "Network", "Summary_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "sort", " ", "the", " ", "result", ",", " ", "descend", "ing", " ", "order", " ", "by", " ", "count_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "items_", "=_", "requests_", "._", "items_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "items_", "._", "sort_", "(_", "lambda_", "x_", ",_", "y_", ":_", "cmp_", "(_", "y_", "[_", "1_", "]_", ",_", "x_", "[_", "1_", "]_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "print", " ", "every", "thing", " ", "out_", "\\u\\u\\uNL\\u\\u\\u_", "print_", "\"%", "-", "20", "s", " ", "%", "5", "s", "\"_", "%_", "(_", "\"", "Address", "\"_", ",_", "\"", "Count", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "key_", ",_", "count_", "in_", "items_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "print_", "\"%", "-", "20", "s", " ", "%", "5d", "\"_", "%_", "(_", "key_", ",_", "count_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "count", " ", "the", " ", "number", " ", "of", " ", "times", " ", "of", " ", "each", " ", "network_", "\\u\\u\\uNL\\u\\u\\u_", "net", "\\u", "count_", "=_", "defaultdict_", "(_", "int_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "net_", "in_", "networks_", "[_", "key_", "]_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "net", "\\u", "count_", "[_", "net_", "]_", "+=_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "sort", " ", "descend", "ing_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "net", "\\u", "count_", "=_", "net", "\\u", "count_", "._", "items_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "net", "\\u", "count_", "._", "sort_", "(_", "lambda_", "x_", ",_", "y_", ":_", "cmp_", "(_", "y_", "[_", "1_", "]_", ",_", "x_", "[_", "1_", "]_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "for_", "net_", ",_", "count_", "in_", "net", "\\u", "count_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "print_", "\"", " ", " ", " ", " ", "%", "5d", " ", "%", "5d", "\"_", "%_", "(_", "net_", ",_", "count_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "Key", "board", "Interrupt_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "pass_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "Exception_", ",_", "e_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\\u", "log_", "._", "exception_", "(_", "\"", "an", " ", "error", " ", "has", " ", "occur", "red", ":", " ", "%", "s", "\"_", ",_", "e_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "finally_", ":_", "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, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2 ]
Module is imported with 'import' and 'import from'
pydata/numexpr/setup.py
[ { "content": "#!/usr/bin/env python\n###################################################################\n# Numexpr - Fast numerical array expression evaluator for NumPy.\n#\n# License: MIT\n# Author: See AUTHORS.txt\n#\n# See LICENSE.txt and LICENSES/*.txt for details about copyright and\n# rights to use.\n####################################################################\n\nimport shutil\nimport os\nimport sys\nimport os.path as op\nfrom distutils.command.clean import clean\n\n\nif sys.version_info < (2, 6):\n raise RuntimeError(\"must use python 2.6 or greater\")\n\ntry:\n import setuptools\nexcept ImportError:\n setuptools = None\n\nwith open('requirements.txt') as f:\n requirements = f.read().splitlines()\n\n# Fetch the version for numexpr (will be put in variable `version`)\nwith open(os.path.join('numexpr', 'version.py')) as f:\n exec(f.read())\n\n\n\nif __name__ == '__main__':\n setup_package()\n", "metadata": "root", "header": "['module', '___EOS___']", "index": 0 } ]
[ { "span": "import setuptools", "start_line": 22, "start_column": 4, "end_line": 22, "end_column": 21 } ]
[]
1
true
[ "[CLS]_", "Module_", "is_", "imported_", "with_", "'", "import", "'_", "and_", "'", "import", " ", "from", "'_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "#!", "/", "usr", "/", "bin", "/", "env", " ", "python_", "\\u\\u\\uNL\\u\\u\\u_", "###########", "###########", "###########", "###########", "###########", "###########", "#", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", " ", "Num", "expr", " ", "-", " ", "Fast", " ", "numerical", " ", "array", " ", "express", "ion", " ", "evaluat", "or", " ", "for", " ", "Num", "Py", "._", "\\u\\u\\uNL\\u\\u\\u_", "#", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", " ", "License", ":", " ", "MIT", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", " ", "Author", ":", " ", " ", "See", " ", "AUTHOR", "S", ".", "txt_", "\\u\\u\\uNL\\u\\u\\u_", "#", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", " ", "See", " ", "LICENSE", ".", "txt", " ", "and", " ", "LICENSE", "S", "/*", ".", "txt", " ", "for", " ", "deta", "il", "s", " ", "abo", "ut", " ", "copyr", "ight", " ", "and_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", " ", "rights", " ", "to", " ", "use", "._", "\\u\\u\\uNL\\u\\u\\u_", "###########", "###########", "###########", "###########", "###########", "###########", "##", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "import_", "shutil_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "os_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "sys_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "os_", "._", "path_", "as_", "op_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "distutils_", "._", "command_", "._", "clean_", "import_", "clean_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "sys_", "._", "version", "\\u", "info_", "<_", "(_", "2_", ",_", "6_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "raise_", "Run", "time", "Error_", "(_", "\"", "must", " ", "use", " ", "python", " ", "2.6", " ", "or", " ", "great", "er", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "import_", "setuptools_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "Import", "Error_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "setuptools_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "with_", "open_", "(_", "'", "require", "ment", "s", ".", "txt", "'_", ")_", "as_", "f_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "requirements_", "=_", "f_", "._", "read_", "(_", ")_", "._", "splitlines_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Fe", "tch", " ", "the", " ", "version", " ", "for", " ", "nume", "xpr", " ", "(", "will", " ", "be", " ", "put", " ", "in", " ", "variab", "le", " ", "`", "version", "`)", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "with_", "open_", "(_", "os_", "._", "path_", "._", "join_", "(_", "'", "nume", "xpr", "'_", ",_", "'", "version", ".", "py", "'_", ")_", ")_", "as_", "f_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "exec_", "(_", "f_", "._", "read_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "\\u\\u", "name\\u\\u_", "==_", "'\\u", "\\u", "main", "\\u\\u'_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "setup", "\\u", "package_", "(_", ")_", "\\u\\u\\uDEDENT\\u\\u\\u_" ]
[ 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2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