Skip to content

Commit 22a870f

Browse files
committed
Abstract syntax tree: disable tree construction due to max recursion
depth errors
1 parent c3aba12 commit 22a870f

File tree

2 files changed

+28
-25
lines changed

2 files changed

+28
-25
lines changed

files/javascript_file.py

+28-24
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import logging
22
from typing import Union
33

4-
import pyjsparser
5-
from pyjsparser import JsSyntaxError
4+
# import pyjsparser
5+
# from pyjsparser import JsSyntaxError
66

77
from base.utils import normalize_data
88
from files.file import File
@@ -31,25 +31,29 @@ def normalized_content(self) -> Union[bytes, None]:
3131
"""
3232
The content of this static file normalized for this file type.
3333
"""
34-
try:
35-
content = self.raw_content.decode()
36-
except UnicodeDecodeError:
37-
return None
38-
39-
if not self.has_usual_file_name_extension:
40-
# skip parsing if file extension does not indicate javascript
41-
return None
42-
43-
try:
44-
parsed = pyjsparser.parse(content)
45-
46-
return normalize_data(parsed)
47-
except (JsSyntaxError, TypeError, ValueError):
48-
logging.warning(
49-
'failed to parse javascript file %s. Skipping abstract syntax tree construction',
50-
self.file_name)
51-
parsed = content
52-
try:
53-
return normalize_data(parsed)
54-
except (TypeError, ValueError):
55-
return None
34+
# TODO: fix abstract syntax tree issues and reuse code
35+
return self.raw_content
36+
37+
# TODO: max recursion depth reached easily
38+
# try:
39+
# content = self.raw_content.decode()
40+
# except UnicodeDecodeError:
41+
# return None
42+
43+
# if not self.has_usual_file_name_extension:
44+
# # skip parsing if file extension does not indicate javascript
45+
# return None
46+
47+
# try:
48+
# parsed = pyjsparser.parse(content)
49+
50+
# return normalize_data(parsed)
51+
# except (JsSyntaxError, TypeError, ValueError):
52+
# logging.warning(
53+
# 'failed to parse javascript file %s. Skipping abstract syntax tree construction',
54+
# self.file_name)
55+
# parsed = content
56+
# try:
57+
# return normalize_data(parsed)
58+
# except (TypeError, ValueError):
59+
# return None

update_index.py

-1
Original file line numberDiff line numberDiff line change
@@ -50,4 +50,3 @@ def index(arguments: Namespace):
5050
)
5151

5252
index(parser.parse_args())
53-

0 commit comments

Comments
 (0)