Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tweaks to python bindings #56

Closed
wants to merge 1 commit into from

Conversation

ztravis
Copy link

@ztravis ztravis commented Jun 6, 2018

Tweaks to libpff python bindings.

@ztravis ztravis closed this Jun 6, 2018
@joachimmetz joachimmetz mentioned this pull request Aug 15, 2018
4 tasks
@xvolte
Copy link

xvolte commented Aug 15, 2018

hello @ztravis
Can you explain a little bit what you did in this tweak ?
i'm trying to get the attachments from the libpff message.
it seems in the code that you removed part of the solution, and added it somewhere else.

Can you help ?

Basically, i'm trying to do that in python code :

def search_msg_content(msg, filename):
    msg_subject=msg.get_subject().encode("UTF-8")
    print msg_subject
    msg_plaintext=msg.get_plain_text_body().encode("UTF-8")
    print msg_plaintext
    print "This message '%s' has %s attachments" % (msg_subject, msg.get_number_of_attachments())
    for attachment in msg.get_attachments():
        print attachment

Of course, it throws an exception : "'pypff.message' object has no attribute 'get_attachments'"

Thanks in advance,

@ztravis
Copy link
Author

ztravis commented Aug 15, 2018

It looks like you're calling msg.get_attachments(), but no such method exists. You can iterate directly through msg.attachments:

for attachment in msg.attachments:
    print attachment

Or you can fetch individual attachments by index:

for i in range(msg.get_number_of_attachments()):
    print msg.get_attachment(i)

This should work on the main branch of this repo (i.e. without my tweaks, which I didn't mean to PR here in the first place...).

(FYI on markdown - you can add code blocks with triple-backquotes: "```")

@xvolte
Copy link

xvolte commented Aug 15, 2018

Thanks, i edited my question with the triple backquotes,

so, regarding what you are suggesting:

for the first one :

for attachment in msg.attachments:
    print attachment

i get a : 'pypff.message' object has no attribute 'attachments' while trying file test.pst

and for the second one :

for i in range(msg.get_number_of_attachments()):
    print msg.get_attachment(i)

i get a : 'pypff.message' object has no attribute 'get_attachment' while trying file test.pst

no more luck with get_attachment_by_index
'pypff.message' object has no attribute 'get_attachment_by_index' while trying file test.pst

So at the moment i don't see how to retreive the attachment.
Can you help ?

What does 'i didn't mean to PR' stands for ? (sorry, i'm french :) )

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants