MCPcopy Create free account
hub / github.com/LabPy/lantz / write_file

Function write_file

docs/driversdoc.py:44–58  ·  view source on GitHub ↗

Write the output file for module/package .

(name, text, opts)

Source from the content-addressed store, hash-verified

42
43
44def write_file(name, text, opts):
45 """Write the output file for module/package <name>."""
46 fname = path.join(opts.destdir, '%s.%s' % (name, opts.suffix))
47 if opts.dryrun:
48 print('Would create file %s.' % fname)
49 return
50 if not opts.force and path.isfile(fname):
51 print('File %s already exists, skipping.' % fname)
52 else:
53 print('Creating file %s.' % fname)
54 f = open(fname, 'w')
55 try:
56 f.write(text)
57 finally:
58 f.close()
59
60
61def format_heading(level, text):

Callers 2

create_module_fileFunction · 0.85
create_modules_toc_fileFunction · 0.85

Calls 2

writeMethod · 0.45
closeMethod · 0.45

Tested by

no test coverage detected