@@ -28,6 +28,7 @@ import re
28
28
import sys
29
29
30
30
from cookiecutter .main import cookiecutter
31
+ from titlecase import titlecase
31
32
from os .path import join as pjoin
32
33
33
34
@@ -51,6 +52,12 @@ def write_all_itk_headers(itk_source_dir):
51
52
output .write (f + u'\n ' )
52
53
return output
53
54
55
+ def get_all_itk_headers (itk_source_dir ):
56
+ output = []
57
+ for root , dirs , files in os .walk (pjoin (itk_source_dir , 'Modules' )):
58
+ for f in fnmatch .filter (files , 'itk*.h' ):
59
+ output .append (f )
60
+ return output
54
61
55
62
def words (text ):
56
63
temp = re .findall ('itk[A-Z][a-zA-Z_0-9]+' , text )
@@ -102,8 +109,14 @@ def itkcorrect(word, NWORDS, alphabet):
102
109
103
110
104
111
def space_out_camel_case (s ):
105
- return re .sub ('((?=[A-Z][a-z])|(?<=[a-z])(?=[A-Z]))' , ' ' , s )
112
+ return re .sub ('((?=[A-Z][a-z])|(?<=[a-z])(?=[A-Z]))' , ' ' , s ). strip ()
106
113
114
+ def itk_abbreviations (word ,** kwargs ):
115
+ if word .upper () in ('ITK' ,'VTK' ,'RGB' ,'VTP' ,'FFT' ,'FEM' ,'TIFF' ,'GMM' ,'EM' ,
116
+ 'CV' ,'GPU' ,'BMP' ,'CSV' ,'DCMTK' ,'GDCM' ,'GE' ,'GIPL' ,'HDF5' ,
117
+ 'IPL' ,'JPEG' ,'JPEG2000' ,'LSM' ,'BYU' ,'MINC' ,'MRC' ,'NIFTI' ,
118
+ 'NRRD' ,'REC' ,'PNG' ,'RAW' ,'XML' ,'RTK' ,'DICOM' ,'2D' ,'3D' ,'IO' ):
119
+ return word .upper ()
107
120
108
121
def get_group_and_module_from_class_name (itk_src , class_name ):
109
122
""" Get the ITK group and module a class belongs to.
@@ -189,7 +202,7 @@ def main():
189
202
or default_class_name
190
203
example_name = get_input ("example_name [" + default_example_name + "]: " )\
191
204
or default_example_name
192
- example_title = space_out_camel_case (example_name )
205
+ example_title = titlecase ( space_out_camel_case (example_name ), callback = itk_abbreviations )
193
206
example_synopsis = get_input ("example_synopsis [" + default_synopsis + "]: " )\
194
207
or default_synopsis
195
208
0 commit comments