comparison licenser/licenses.py @ 25:8729685a2cf6

stub web interface
author Jeff Hammel <jhammel@mozilla.com>
date Fri, 25 Nov 2011 00:01:15 -0800
parents d3e3a506dd29
children 0faf3e7b593a
comparison
equal deleted inserted replaced
24:d3e3a506dd29 25:8729685a2cf6
72 def __call__(self, license): 72 def __call__(self, license):
73 73
74 if self.isempty(): 74 if self.isempty():
75 return # you're done 75 return # you're done
76 lines = self.lines() 76 lines = self.lines()
77 77
78 # open the file for writing 78 # open the file for writing
79 f = file(self.filename, 'w') 79 f = file(self.filename, 'w')
80 80
81 # print the license 81 # print the license
82 license_lines = license.splitlines() 82 license_lines = license.splitlines()
136 return True 136 return True
137 137
138 138
139 filetypes = [HashCommentsFile, AsteriskCommentsFile] 139 filetypes = [HashCommentsFile, AsteriskCommentsFile]
140 140
141 def filetypes_string(filetypes=filetypes[:]):
142 extensions = set()
143 for filetype in filetypes:
144 extensions.update(filetype.extensions)
145 return ', '.join([i for i in extensions])
146
141 class License(object): 147 class License(object):
142 """Abstract base class for a license""" 148 """Abstract base class for a license"""
143 149
144 variables = [] # required variables 150 variables = [] # required variables
145 151
149 self.template = os.path.join(os.path.dirname(__file__), 155 self.template = os.path.join(os.path.dirname(__file__),
150 'licenses', 156 'licenses',
151 self.template) 157 self.template)
152 assert os.path.exists(self.template) 158 assert os.path.exists(self.template)
153 self.filetypes = filetypes 159 self.filetypes = filetypes
154 160
155 def license(self): 161 def license(self):
156 return file(self.template).read() 162 return file(self.template).read()
157 163
158 def print_license(self): 164 def print_license(self):
159 print self.license() 165 print self.license()