MCPcopy Create free account
hub / github.com/fa0311/TwitterInternalAPIDocument / js

Class js

lib/js_parser/js_parser.py:5–34  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3
4
5class js:
6 def __init__(self, script: str):
7 self.script = script
8 self.length = len(self.script)
9 self.key = 0
10
11 def parser(self, init=True):
12 output = js_data()
13 value = ""
14 while self.length > self.key:
15 char = self.script[self.key]
16 self.key += 1
17 if char == "{":
18 output.children.append(value)
19 value = ""
20 output.children.append(self.parser(init=False))
21 output.children[-1].parent = output
22 output.children[-1].before = output.children[-2]
23 elif char == "}":
24 if value != "":
25 output.children.append(value)
26 if init:
27 value = ""
28 else:
29 return output
30 else:
31 value += char
32 if value != "":
33 output.children.append(value)
34 return output
35
36
37class js_data:

Callers 1

generator.pyFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected