Closed Donnnno closed 1 year ago
Hey there, coming over from Mastodon and not knowing your product: could you provide a workflow to reproduce the problem you're encountering? Like: "put this text in a file, pass it to this script and the result needs to look like this" 😀
Hi @S1SYPHOS ! Thanks for the help.
It's a script that takes lines from icon request emails and put's it in a large request file.
The mails look like this:
and like this in the request list:
This is the command I use to run the script
python email_parser.py ./mail appfilter.xml requests.txt
""" Script Usage: python (or python3) delta_email_parser.py ./path/to/emlFolder ./path/to/appfilter.xml (./path/to/requests.txt)
Arguments 0: Path to folder containing .eml files of requests 1: Path to existing appfilter.xml to recognize potentially updatable appfilters 3 (optional): existing requests.txt file to augment with new info
Output If only two arguments are given the script will generate 'requests.txt' and 'updatable.txt'. If the third argument is given the file will be overwritten with the updated info. """
Alright, so basically I'd need a proton mail eml
file :smiley: see Mastodon!
Thanks, I've just looked at some different emails, but a problem is that they all are slightly different in the way they're formatted..
(removed the eml files here because of privacy)
I'm onto something, but will look at it again later - looks like fun :rofl:
Haha thanks a lot!
Looks more like hell to me 🙃
Alright, it's a bit weird, but I tried not using external dependencies for further parsing:
around line 80, when checking if parsed is None
, I did this:
if parsed is None:
parsed = msg.get_body().get_content()
emailBody = "\n".join([TAG_RE.sub('', string) for string in parsed.split('<br>')])
else:
emailBody = parsed.get_content()
.. which gives me this - and no further errors:
-------------------------------------------------------
3 Requested Apps Pending (Updated 24 August 2022)
-------------------------------------------------------
<!-- Action Blocks -->
<item component="ComponentInfo{com.google.android.apps.accessibility.maui.actionblocks/com.google.android.apps.accessibility.maui.actionblocks.home.HomeActivity}" drawable="action_blocks" />
https://play.google.com/store/apps/details?id=com.google.android.apps.accessibility.maui.actionblocks
https://f-droid.org/en/packages/com.google.android.apps.accessibility.maui.actionblocks/
Requested 1 times
Last requested 1659958279.0
.. which is cat
output for an empty requests.txt
:grin:
woah sounds great! but I'm getting this message right now:
"TAG_RE" is not defined
where should I put that tag?
Sorry, it's the compiled regex, just at the top, line 47 or so:
TAG_RE = re.compile(r'<[^<]+?>') # or maybe some other name, something more descriptive
YESSS GREAT!!! it works again, thank you so much!
edit: okay it almost works haaha
It seems to me that this script is used throughout many "icon" pack android apps, correct? 🙃
Yeah, that's correct. There are other projects using it too :-)
Well, if it were my project, I'd harden the parser by adding tests - and probably using third party libraries for special cases (mangled HTML being such a special case) 😃
Thanks! I'm gonna loon into that :+)
If you need anything , let me know / give a ping!
Just checked, 10 out of 627 mails weren't working, so that's a huge win!
With the mail provider change to proton mail, I've encountered an issue with our email parser:
The parser doesn't know where to look for the right lines of code...
This is how a normal mails body looks:
And this is proton: