Closed KiudLyrl closed 6 years ago
It sounds like your PAC file is complicated enough that Js2Py generates Python with too much indentation. Unfortunately I don't have a solution for you at the moment.
It would be interesting if you could share your PAC file in order to get a better idea of what kind of JavaScript triggers this problem.
Yup, I understood that too later. I don't think I can share it, I think it could get me in trouble, but I can tell you why it's not working.
Inside you can find :
if [}
else {
if {}
else {
17 levels totals
}
}
Python has an indentation limit (but 17 imbricated if/else is still permitted, the limit is 100 I think) so apparently J2sPy generates a python file with much more levels of imbrication than the original pac file.
I could change it, but that would defeat the purpose because I want my user to directly be able to use my script.
I can't ask the guys behind the PAC file to change it (big corporation)
Well I don't know what to do, write my own pac parser maybe. I'm very unfamilliar with PAC files, I discovered them yesterday.
Inside there is only "shExpMatch()", "dnsDomainIs()" and "isInNet()" methods, is that the only kind of method you can find in a PAC file? I could easily write a python converter for that.
The 3 functions in the PAC file that you mention probably cover the vast majority of use cases. Here's the complete list of PAC functions. PyPAC is trying to be comprehensive by implementing all the functions in the specification, and also using a full JavaScript engine to interpret the PAC file.
I'll experiment with some ideas to resolve your problem.
I've just released PyPAC 0.10.0, which should solve this issue. Please let me know.
It works :D
Hi,
I just installed pypac with pip and replaced my Session by a PACSession, and I get :
code is the following :