MCPcopy Create free account
hub / github.com/GothenburgBitFactory/taskwarrior / parse_datafile

Function parse_datafile

test/basetest/utils.py:363–378  ·  view source on GitHub ↗

Parse .data files on the client and server treating files as JSON

(file)

Source from the content-addressed store, hash-verified

361
362
363def parse_datafile(file):
364 """Parse .data files on the client and server treating files as JSON"""
365 data = []
366 with open(file) as fh:
367 for line in fh:
368 line = line.rstrip("\n")
369
370 # Turn [] strings into {} to be treated properly as JSON hashes
371 if line.startswith("[") and line.endswith("]"):
372 line = "{" + line[1:-1] + "}"
373
374 if line.startswith("{"):
375 data.append(json.loads(line))
376 else:
377 data.append(line)
378 return data
379
380
381def mkstemp(data):

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected