mongo-python-driver/validate.py
2009-01-12 11:55:15 -05:00

24 lines
376 B
Python

import sys
from bson import BSON
from son import SON
def main():
xml_file = sys.argv[1]
out_file = sys.argv[2]
f = open(xml_file, "r")
xml = f.read()
f.close()
f = open(out_file, "w")
doc = SON.from_xml(xml)
bson = BSON.from_dict(doc)
f.write(bson)
f.close()
assert doc == bson.to_dict()
if __name__ == "__main__":
main()