-
Notifications
You must be signed in to change notification settings - Fork 0
/
python_lib.py
56 lines (38 loc) · 1.39 KB
/
python_lib.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
#! /usr/bin/python
import os
import helpers
import copyright_notes
filename_help = "Output python name(s)"
template = """#! /usr/bin/python
\"\"\" $FILENAME \"\"\"
__date__ = "$DATE"
__author__ = "$AUTHOR"
__email__ = "$AUTHOREMAIL"
import unittest
def dummyFunc():
return 1
class DummyTest( unittest.TestCase ):
def testDummyFunc( self ):
self.assertEqual( 1 , dummyFunc() )
if __name__ == "__main__" :
unittest.main()
"""
class python_lib_template():
def __init__( self , name , description , path = [] ):
self.name = name
self.description = description
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 )
if hasattr( args , "filename" ) :
for filename in args.filename:
p = path
p.append( filename )
f = helpers.full_join( p )
helpers.add_filename_replacements( replacements , filename )
replacements[ "FILENAME" ] = f
helpers.default_processing( filename , replacements , template )