/
odeint_header_template.py
80 lines (52 loc) · 2.3 KB
/
odeint_header_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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#! /usr/bin/python
import os
import helpers
import copyright_notes
filename_help = "Output file name(s)"
namespace_help = "Namespace definitions to be created."
class_help = "Class templates to be created"
template = """/*
[auto_generated]
$FILENAME
[begin_description]
tba.
[end_description]
Copyright 2009-2012 Karsten Ahnert
Copyright 2009-2012 Mario Mulansky
Distributed under the Boost Software License, Version 1.0.
(See accompanying file LICENSE_1_0.txt or
copy at http://www.boost.org/LICENSE_1_0.txt)
*/
#ifndef ${FILENAMECAP}_INCLUDED
#define ${FILENAMECAP}_INCLUDED
$NAMESPACE_OPENING
$CLASS_TEMPLATE
$NAMESPACE_CLOSING
#endif // ${FILENAMECAP}_INCLUDED
"""
class odeint_header_template():
def __init__( self ):
self.name = "OdeintHeader"
self.description = "Creates a header file with header guards and namespace defintions for odeint."
self.namespace = [ "boost" , "numeric" , "odeint" ]
self.path = [ "boost" , "numeric" , "odeint" ]
def register_in_arg_parser( self , subparsers ):
parser = helpers.create_subparser( self , subparsers )
parser.add_argument( "-f" , "--filename" , nargs = "+" , help = filename_help , required=True )
parser.add_argument( "-n" , "--namespace" , nargs = "*" , help = namespace_help )
parser.add_argument( "-c" , "--class" , nargs = "*" , help = class_help , dest = "classes" )
def do_work( self , args , replacements ):
print "Creating " + self.name + " template(s) ..."
path = helpers.find_path( self.path )
helpers.add_namespace_replacements( replacements , args , self.namespace )
helpers.add_class_replacements( replacements , args , helpers.default_class_template )
if hasattr( args , "filename" ) :
for filename in args.filename:
filename = helpers.check_filename_ending( filename , "h" )
p = path
p.append( filename )
f = helpers.full_join( p )
helpers.add_filename_replacements( replacements , filename )
replacements[ "FILENAME" ] = f
replacements[ "FILENAMECAP" ] = helpers.create_cap_filename_str( f )
helpers.default_processing( filename , replacements , template )