Esempio n. 1
0
def index():
    response = None
    format = "json"
    if request.method == "POST":
        format = request.form["format"]
        data = request.form["data"]

        try:
            if format == "vdf":
                response = json.dumps(
                    vdf.loads(data),
                    indent=4
                )

            elif format == "json":
                _response = json.loads(data)
                response = vdf.dumps(_response).decode("utf-16")

        except ValueError:
            flash("ValueError:  Your {} may not be valid.".format(format), "danger")
            response = "{}" if format == "json" else ""

    return render_template("vdfjson.html", response=response, format=format, title="vdfjson")
Esempio n. 2
0
 def test_macro_quoted(self):
     self.assertEqual(self.EXPECTED_DICT, vdf.loads(self.MACRO_QUOTED_VDF))
Esempio n. 3
0
 def test_quoted(self):
     self.assertEqual(self.EXPECTED_DICT, vdf.loads(self.QUOTED_VDF))
Esempio n. 4
0
 def test_multikey_knode(self):
     self.maxDiff = 80 * 80
     self.assertEqual(self.EXPECTED_MULTIKEY_KNODE, vdf.loads(self.MULTIKEY_KNODE))
Esempio n. 5
0
 def test_numerical_dict(self):
     self.assertEqual(self.EXPECTED_NUMERICAL_DICT, vdf.loads(vdf.dumps(self.NUMERICAL_DICT)))
Esempio n. 6
0
 def test_subnode_dict(self):
     self.assertEqual(self.EXPECTED_SUBNODE_DICT, vdf.loads(vdf.dumps(self.SUBNODE_DICT)))
Esempio n. 7
0
 def test_multikey_knode(self):
     self.maxDiff = 80*80
     self.assertEqual(self.EXPECTED_MULTIKEY_KNODE, vdf.loads(self.MULTIKEY_KNODE))
Esempio n. 8
0
 def test_mixed(self):
     self.assertEqual(self.EXPECTED_MIXED_DICT, vdf.loads(self.MIXED_VDF))
Esempio n. 9
0
 def test_simple_dict(self):
     self.assertEqual(self.EXPECTED_SIMPLE_DICT, vdf.loads(vdf.dumps(self.SIMPLE_DICT)))
Esempio n. 10
0
 def test_mixed(self):
     self.assertEqual(self.EXPECTED_MIXED_DICT, vdf.loads(self.MIXED_VDF))
Esempio n. 11
0
 def test_subnode_quoted(self):
     self.assertEqual(self.EXPECTED_SUBNODE_DICT, vdf.loads(self.SUBNODE_QUOTED_VDF))
Esempio n. 12
0
 def test_comment_quoted(self):
     self.assertEqual(self.EXPECTED_DICT, vdf.loads(self.COMMENT_QUOTED_VDF))
Esempio n. 13
0
 def test_macro_quoted(self):
     self.assertEqual(self.EXPECTED_DICT, vdf.loads(self.MACRO_QUOTED_VDF))
Esempio n. 14
0
 def test_quoted(self):
     self.assertEqual(self.EXPECTED_DICT, vdf.loads(self.QUOTED_VDF))
Esempio n. 15
0
 def test_comment_quoted(self):
     self.assertEqual(self.EXPECTED_DICT, vdf.loads(self.COMMENT_QUOTED_VDF))
Esempio n. 16
0
 def test_subnode_quoted(self):
     self.assertEqual(self.EXPECTED_SUBNODE_DICT, vdf.loads(self.SUBNODE_QUOTED_VDF))
Esempio n. 17
0
 def test_subnode_dict(self):
     self.assertEqual(self.EXPECTED_SUBNODE_DICT, vdf.loads(vdf.dumps(self.SUBNODE_DICT)))
Esempio n. 18
0
 def test_multikey_kv(self):
     self.assertEqual(self.EXPECTED_MULTIKEY_KV, vdf.loads(self.MULTIKEY_KV))
Esempio n. 19
0
 def test_array_dict(self):
     self.assertEqual(self.EXPECTED_ARRAY_DICT, vdf.loads(vdf.dumps(self.ARRAY_DICT)))
Esempio n. 20
0
 def test_simple_dict(self):
     self.assertEqual(self.EXPECTED_SIMPLE_DICT, vdf.loads(vdf.dumps(self.SIMPLE_DICT)))
Esempio n. 21
0
 def test_numerical_dict(self):
     self.assertEqual(self.EXPECTED_NUMERICAL_DICT, vdf.loads(vdf.dumps(self.NUMERICAL_DICT)))
Esempio n. 22
0
 def test_array_dict(self):
     self.assertEqual(self.EXPECTED_ARRAY_DICT, vdf.loads(vdf.dumps(self.ARRAY_DICT)))
Esempio n. 23
0
 def test_combination_dict(self):
     self.assertEqual(self.EXPECTED_COMBINATION_DICT, vdf.loads(vdf.dumps(self.COMBINATION_DICT)))
Esempio n. 24
0
 def test_combination_dict(self):
     self.assertEqual(self.EXPECTED_COMBINATION_DICT, vdf.loads(vdf.dumps(self.COMBINATION_DICT)))
Esempio n. 25
0
 def test_multikey_kv(self):
     self.assertEqual(self.EXPECTED_MULTIKEY_KV, vdf.loads(self.MULTIKEY_KV))