-
Notifications
You must be signed in to change notification settings - Fork 0
/
basic_source_template.py
48 lines (35 loc) · 1.3 KB
/
basic_source_template.py
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#! /usr/bin/python
import helpers
import copyright_notes
filename_help = "Output file name(s)"
template = """/*
* $FILENAME
* Date: $DATE
* Author: $AUTHOR ($AUTHOREMAIL)
* Copyright: $AUTHOR
*
$LICENSE
*/
#include <iostream>
"""
class basic_source_template():
def __init__( self , name , description , path = [] , license = copyright_notes.boost_copyright_for_header ):
self.name = name
self.description = description
self.license = license
self.path = path
def register_in_arg_parser( self , subparsers ):
parser = helpers.create_subparser( self , subparsers )
parser.add_argument( "filename" , nargs = "+" , help = filename_help )
def do_work( self , args , replacements ):
print "Creating " + self.name + " template(s) ..."
path = helpers.find_path( self.path )
replacements[ "LICENSE" ] = self.license
if hasattr( args , "filename" ) :
for filename in args.filename:
filename = helpers.check_filename_ending( filename , "cpp" )
p = path
p.append( filename )
f = helpers.full_join( p );
replacements[ "FILENAME" ] = f
helpers.default_processing( filename , replacements , template )