Parse .data files on the client and server treating files as JSON
(file)
| 361 | |
| 362 | |
| 363 | def 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 | |
| 381 | def mkstemp(data): |
nothing calls this directly
no outgoing calls
no test coverage detected