Ejemplo n.º 1
0
 def test_sanity(self):
     print Format.get_formats()
     for format in Format.get_formats():
         st = dumps(self.some_data, format)
         print st
         self.assertTrue(isinstance(st, (unicode, str)))
         self.assertEqual(self.some_data, loads(st, format))
Ejemplo n.º 2
0
def get_format_filter(multi_options=False):
    formats = Format.get_formats()
    if multi_options:
        res = []
        for f in formats:
            res.append("{} ({})".format(f.description, " ".join(("*.{}".format(ext) for ext in f.extensions))))
        result = ";;".join(res)
        return result
    else:
        all_exts = ()
        for f in formats:
            all_exts += f.extensions
        return "Any data file ({})".format(" ".join(("*.{}".format(ext) for ext in all_exts)))