PayPal is really having fun in constantly changing the format of the email they send on a purchase.
I have a problem with the latest change.
The address portion can be:
Unconfirmed shipping address
Instructions to merchant:
JAN ONDERDIJK's UNCONFIRMED Address
Have you lifted your withdrawal and receiving limits?
There are actually a few more variations which I try to handle with this code (only showing snippets):
addLine = pyp.Combine((pyp.OneOrMore(alphanums) + pyp.restOfLine))
emptyLine = (pyp.Suppress("Thank you for using PayPal") |\
(pyp.Suppress("Have you lifted your withdrawal") + pyp.restOfLine) |\
(pyp.Suppress("Sincerely,") + pyp.restOfLine) |\
(pyp.Suppress(pyp.OneOrMore('-')) + pyp.Suppress("Have you lifted your withdrawal") + pyp.restOfLine) |\
(pyp.Suppress("Instructions to") + pyp.restOfLine))
str_address = (((pyp.Suppress("UNCONFIRMED Address") |\
pyp.Suppress("CONFIRMED Address") |\
pyp.Suppress("unconfirmed address")) |\
pyp.Suppress("Unconfirmed shipping address") + pyp.Suppress(pyp.Word("-"))) +\
((addLine + addLine + addLine + addLine + emptyLine.suppress()) |\
(addLine + addLine + addLine + addLine + addLine + emptyLine.suppress()) |\
(addLine + addLine + addLine + addLine + addLine + addLine + emptyLine.suppress()) ))
I tried to use pyp.Optional instead of:
But I can not get this to work.
Another question I have can I make things case insensitive in some way, e.g. just look for "confirmed address" or "unconfirmed" + anyword or something similar.
Appreciate a few tips on how I could go about this.
CaselessLiteral("confirmed address") should handle case-insensitive matching.
All I can suggest is you try adding setName and setDebug() calls on some of your key expressions, and see where expected matches fail.
(Sorry to be so slow in responding - I've had a difficult couple of months both health and job-wise - thanks for your patience.)
Thanks for the response. I should actually have gotten back to the list as I found a solution, similar approach to your suggestion, i.e. using OneOf and caseless=True.
Sorry to hear about your health problems etc, hope you got that back "under control".
All the best
addressStart = pyp.oneOf("unconfirmed shipping address;"
"confirmed shipping address;"
"adresse de livraison :;"
"ship-to address: - unconfirmed".split(';'), caseless=True) +\
Sign up for the SourceForge newsletter:
You seem to have CSS turned off.
Please don't fill out this field.