-
-
Notifications
You must be signed in to change notification settings - Fork 44
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
Allow EDI file to have something before UNA or UNB. It can happens with files generated by the software SAGE COALA. #76
Conversation
…th files generated by the software SAGE COALA. Added a unit test with a file
Thank you for the time spent on this project. |
Ok, this is interesting, and I think it would be definitely a possibility to merge such a PR/idea.
I could think about accepting it because of use case 2, as I myself maybe would have use for that too. There is one thing I can see which could lead to a problem. If you use message.find("UNA"), this correctly finds ATM pydifact "identifies" a EDIFACT file using the UNA header, if present, and if not, it uses the default control characters and starts parsing. Let me think about it a few days, but I think I can accept that PR. Thanks for adding a test to it - maybe you could shorten the sample file a bit to speed up the testing, if that is ok for you - I think it is not necessary to use the whole file. |
|
You're right, UNA can be found in the string where it is not a "UNA". So may be we can look for a regexp that match a normal UNA !? What is the normal format, I can build the regexp... |
It's not easy, and maybe impossible. As it would be perfectly valid EDIFACT to use "ABCDEF" as control characters, a file could start with |
Ok so let's think differently. We want to improve the current behavior. Before, the code checks if it starts by "UNA". If I look at https://unece.org/fileadmin/DAM/trade/edifact/untdid/d422_s.htm.
I can improve the code in this way ? |
I made another branch with this suggestion that sounds better, this is the commit : pulse-mind@303cfd5 |
That looks better. And It is even better than the current solution. I think this is a useful addition and will maybe solve other "non-strictly" compatibility problems - maybe there are other forms of EDIFACT file implementations that start with another header. And it doesn't hurt current behaviour. So yes, please implement this change in this PR, and I will merge it! |
Just make sure you run "black" at the end, as the current patch is not accepted by the black format CI pre-commit hook! Thanks! |
cool @nerdoc . I closed this one and open a new pull request. I run black on the other branch, I hope I did it well.
|
fix #75