MCPcopy Create free account
hub / github.com/Tencent/digitalhuman / write_file

Function write_file

SWF/src/utils.py:47–61  ·  view source on GitHub ↗
(filename, data)

Source from the content-addressed store, hash-verified

45
46
47def write_file(filename, data):
48 if filename.endswith('.jsonl'):
49 with open(filename, 'w') as f:
50 for line in data:
51 f.write(json.dumps(line) + '\n')
52 elif filename.endswith('.txt'):
53 with open(filename, 'w') as f:
54 for line in data:
55 f.write(line + '\n')
56
57 elif filename.endswith('.json'):
58 with open(filename, 'w') as f:
59 json.dump(data, f, indent=4)
60 else:
61 raise "no suitable function to write data"
62
63def _parse(outputs: str, tag="task"):
64 soup = BeautifulSoup(outputs, 'lxml')

Callers

nothing calls this directly

Calls 2

writeMethod · 0.80
dumpMethod · 0.45

Tested by

no test coverage detected