Write the output file for module/package .
(name, text, opts)
| 42 | |
| 43 | |
| 44 | def 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 | |
| 61 | def format_heading(level, text): |
no test coverage detected