On 11/03/09 - 05:05, Luca wrote:
> There is standard or sugested way in python to read the content of a P7M file?
>
> I don't need no feature like verify sign, or sign using a certificate.
> I only need to extract the content file of the p7m (a doc, a pdf, ...)
For PDF files you can just remove the P7M content before %PDF and after
%%EOF.
The following snippet converts /tmp/test.p7m into PDF, saving the
resulting document into /tmp/test.pdf:
import re
from gzip import GzipFile
contents = GzipFile('/tmp/test.p7m').read()
contents_re = re.compile('%PDF-.*%%EOF', re.MULTILINE | re.DOTALL)
contents = contents_re.search(contents).group()
open('/tmp/test.pdf', 'w').write(contents)
HTH.
ciao,
ema
--
http://mail.python.org/mailman/listinfo/python-list