0

I have following code in js:

var poly_line_offset_f5 = L.polyline(
    [[41.716111, 20.722361], [41.7704754, 20.8381323]],
    {"bubblingMouseEvents": true, "color": "#FFA500", "dashArray": "", "dashOffset": null}
).addTo(feature_group_Under110kVLines);

var popup_6cc = L.popup({"maxWidth": "100%"});

var html_a1 = $(' <div id="html_a1" </div> ')[0];
popup_6cc.setContent(html_a1);

poly_line_offset_f5.bindPopup(popup_6cc)
;

poly_line_offset_f5.bindTooltip(
    '<div> VLKIJ_VRUGHTK_4_95:  </div>',
    {"sticky": true}
);

For purpose of this question, this code is going to be treated as plain text. I want to parse this to some kind of array or dataframe or dictionary ( any structured data ) with groups of datasets for each variable ( poly_line_offset_f5, popup_6cc, html_a1 ). Since I am familiar with python, I am exploring this approach, but it looks a bit complicated for me since I am new in parsing.

I need following outputs:

poly_line_offset_f5:

var x1  y1  x2  y2  dpoly   layer   bindpop html    dbind
poly_line_offset_f5 41.716111   20.722361   41.7704754  20.8381323  {"bubblingMouseEvents": true, "color": "#FFA500", "dashArray": "", "dashOffset": null}  feature_group_Under110kVLines   popup_6cc   <div> VLKIJ_VRUGHTK_4_95:  </div>'  {"sticky": true}

popup_6cc :

var dict    bind
popup_6cc   {"maxWidth": "100%"}    html_a1

html_a1:

var text
html_a1  ' <div id="html_a1" </div> '

If you have any ideas, guidelines for solving this it would be very helpfull.

1
  • Please show all text as text, not as pictures of text. Commented Feb 4, 2021 at 21:56

1 Answer 1

1

Look into using esprima. Here is PyPi page.

Example code:

from esprima import parseScript

with open("file.js", "r") as file:
    string = file.read()

script = parseScript(string)
print(script)

Not sure if you can accomplish everything you want, but it can give you variables and their values.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.