File: fileToDoxPage.py

package info (click to toggle)
sleuthkit 4.6.5-1%2Bdeb10u1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 39,264 kB
  • sloc: ansic: 171,812; cpp: 44,216; sh: 31,364; java: 17,674; makefile: 1,241; xml: 838; perl: 797; python: 707; sed: 16
file content (28 lines) | stat: -rwxr-xr-x 945 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
from __future__ import with_statement

import os
from optparse import OptionParser
                 
"""
Creates a Doxygen page that displays the contents of a file.
"""
if __name__ == "__main__":
    parser = OptionParser(usage = 'usage: %prog <src_file_path> <output_dir> <page_name> <page_title>')
    (options, args) = parser.parse_args()
    if len(args) != 4:
        parser.error("incorrect number of arguments")

    with open(args[0], 'r') as srcFile:
        srcFileContents = srcFile.read()
        
    (fileName, fileExt) = os.path.splitext(args[0])
        
    with open(os.path.join(args[1], args[2] + '.dox'), 'w') as doxFile:
        doxFile.write('/*! \\page ' + args[2] + '_page ' + args[3] + '\n\n')
        if fileExt is None:
            doxFile.write('\\code\n\n')
        else:
            doxFile.write('\\code{' + fileExt + '}\n\n')
        doxFile.write(srcFileContents)
        doxFile.write('\n\n\\endcode\n\n*/')