From bb95df8d25a55a2ececf17feb903d5915fa2baa3 Mon Sep 17 00:00:00 2001 From: Sven Slootweg Date: Wed, 25 Dec 2013 11:50:30 +0100 Subject: [PATCH] Some test code for XML generation with ElementMaker --- test-xml.py | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 test-xml.py diff --git a/test-xml.py b/test-xml.py new file mode 100644 index 0000000..f9f49a2 --- /dev/null +++ b/test-xml.py @@ -0,0 +1,33 @@ +from lxml.builder import ElementMaker +from lxml import etree + +NSMAP = {None: "http://doc.s3.amazonaws.com/2006-03-01", "tahoe": "http://doc.cryto.net/xml/tahoe-s3"} + +E = ElementMaker(namespace="http://doc.s3.amazonaws.com/2006-03-01", nsmap=NSMAP) +Et = ElementMaker(namespace="http://doc.cryto.net/xml/tahoe-s3", nsmap=NSMAP) + +buckets = ( + E.Bucket( + E.Name("quotes"), + E.CreationDate("2006-02-03T16:45:09.000Z"), + Et.ReadCapability("ABC23423346"), + Et.WriteCapability("H98NG3040S"), + Et.VerifyCapability("3148J15990JE"), + ), + E.Bucket( + E.Name("samples"), + E.CreationDate("2006-02-03T16:41:58.000Z") + ) +) + +doc = E.ListAllMyBucketsResult( + E.Owner( + E.Id("bcaf1ffd86f461ca5fb16fd081034f"), + E.DisplayName("webfile") + ), + E.Buckets( + *buckets + ) +) + +print etree.tostring(doc, pretty_print=True)