Skip to content
Snippets Groups Projects
Commit d284b58a authored by Chris Lamb's avatar Chris Lamb :eyes:
Browse files

Tidy detection of JSON files due to missing call to File.recognizes that...

Tidy detection of JSON files due to missing call to File.recognizes that checks against the output of file(1) which I think (!) was also causing us to attempt to parse almost every file using json.loads. Whoops.
parent e10f111b
No related branches found
No related tags found
No related merge requests found
Pipeline #150053 passed
......@@ -38,10 +38,13 @@ except ImportError: # noqa
class JSONFile(File):
DESCRIPTION = "JSON files"
FILE_TYPE_RE = re.compile(r"JSON data") # Requires file 5.35+
FILE_TYPE_RE = re.compile(r"^JSON data") # Requires file 5.35+
@classmethod
def recognizes(cls, file):
if not super().recognizes(file):
return False
with open(file.path, "rb") as f:
try:
file.parsed = json.loads(
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment