diff --git a/js/DataGridRenderer.js b/js/DataGridRenderer.js index 1af1a44..6bef1c7 100755 --- a/js/DataGridRenderer.js +++ b/js/DataGridRenderer.js @@ -534,5 +534,81 @@ var DataGridRenderer = { return outputText; }, + + //--------------------------------------- + // Python LIST + //--------------------------------------- + + pythonlist: function (dataGrid, headerNames, headerTypes, indent, newLine) { + //inits... + // appending headers into datagrid as its not a Dictioary + dataGrid.splice(0,0,headerNames) + var commentLine = "//"; + var commentLineEnd = ""; + var outputText = "["; + var numRows = dataGrid.length; + var numColumns = headerNames.length; + //begin render loop + for (var i=0; i < numRows; i++) { + var row = dataGrid[i]; + + for (var j=0; j < numColumns; j++) { + if ((headerTypes[j] == "int")||(headerTypes[j] == "float")) { + var rowOutput = row[j] || "None"; + } else { + var rowOutput = '"'+(row[j] || "")+'"'; + }; + + outputText += (rowOutput ); + + if (j < (numColumns-1)) {outputText+=","}; + }; + + if (i < (numRows-1)) {outputText += ","}; + }; + outputText += "]"; + + return outputText; + }, + + //--------------------------------------- + // Python SET LIST + //--------------------------------------- + + pythonsetlist: function (dataGrid, headerNames, headerTypes, indent, newLine) { + // appending headers into datagrid as its not a Dictioary + dataGrid.splice(0,0,headerNames) + //inits... + var commentLine = "//"; + var commentLineEnd = ""; + var outputText = "["; + var numRows = dataGrid.length; + var numColumns = headerNames.length; + + //begin render loop + for (var i=0; i < numRows; i++) { + var row = dataGrid[i]; + outputText += "("; + for (var j=0; j < numColumns; j++) { + if ((headerTypes[j] == "int")||(headerTypes[j] == "float")) { + var rowOutput = row[j] || "None"; + } else { + var rowOutput = '"'+(row[j] || "")+'"'; + }; + + outputText += (rowOutput); + + if (j < (numColumns-1)) {outputText+=","}; + }; + outputText += ")"; + if (i < (numRows-1)) {outputText += ","+newLine}; + }; + outputText += "]"; + + return outputText; + }, + + + } \ No newline at end of file diff --git a/js/converter.js b/js/converter.js index e9c3820..cf6d660 100755 --- a/js/converter.js +++ b/js/converter.js @@ -16,7 +16,7 @@ function DataConverter(nodeId) { this.nodeId = nodeId; this.node = $("#"+nodeId); - this.outputDataTypes = [ + this.outputDataTypes = [ {"text":"Actionscript", "id":"as", "notes":""}, {"text":"ASP/VBScript", "id":"asp", "notes":""}, {"text":"HTML", "id":"html", "notes":""}, @@ -30,7 +30,10 @@ function DataConverter(nodeId) { {"text":"Ruby", "id":"ruby", "notes":""}, {"text":"XML - Properties", "id":"xmlProperties", "notes":""}, {"text":"XML - Nodes", "id":"xml", "notes":""}, - {"text":"XML - Illustrator", "id":"xmlIllustrator", "notes":""}]; + {"text":"XML - Illustrator", "id":"xmlIllustrator", "notes":""}, + {"text":"Python - List", "id":"pythonlist", "notes":""}, + {"text":"Python - SET", "id":"pythonsetlist", "notes":""}, + ]; this.outputDataType = "json"; this.columnDelimiter = "\t";