compression_suffix = _createrepo_c.compression_suffix
detect_compression = _createrepo_c.detect_compression
+compression_type = _createrepo_c.compression_type
return PyLong_FromLong(type);
}
+PyObject *
+py_compression_type(PyObject *self, PyObject *args)
+{
+ char *name;
+
+ CR_UNUSED(self);
+
+ if (!PyArg_ParseTuple(args, "z:py_compression_type", &name))
+ return NULL;
+
+ return PyLong_FromLong((long) cr_compression_type(name));
+}
+
/*
* CrFile object
*/
PyObject *py_detect_compression(PyObject *self, PyObject *args);
+PyDoc_STRVAR(compression_type__doc__,
+"compression_type(string) -> int\n\n"
+"Compression type value");
+
+PyObject *py_compression_type(PyObject *self, PyObject *args);
+
+
#endif
METH_VARARGS, compression_suffix__doc__},
{"detect_compression", (PyCFunction)py_detect_compression,
METH_VARARGS, detect_compression__doc__},
+ {"compression_type", (PyCFunction)py_compression_type,
+ METH_VARARGS, compression_type__doc__},
{ NULL }
};
comtype = cr.detect_compression(path)
self.assertEqual(comtype, cr.XZ)
+ def test_compression_type(self):
+ self.assertEqual(cr.compression_type(None), cr.UNKNOWN_COMPRESSION)
+ self.assertEqual(cr.compression_type(""), cr.UNKNOWN_COMPRESSION)
+ self.assertEqual(cr.compression_type("gz"), cr.GZ)
+ self.assertEqual(cr.compression_type("bz2"), cr.BZ2)
+ self.assertEqual(cr.compression_type("xz"), cr.XZ)
+ self.assertEqual(cr.compression_type("XZ"), cr.XZ)