comparison decoupage/formatters.py @ 51:8002dcdb8e82

add "-" to list of FilenameDescription separators
author Jeff Hammel <jhammel@mozilla.com>
date Wed, 03 Nov 2010 18:41:42 -0700
parents 650e1b62a628
children 9c15bde43ae6
comparison
equal deleted inserted replaced
50:d327dc7de14f 51:8002dcdb8e82
126 the file extension (if any) will be dropped and 126 the file extension (if any) will be dropped and
127 spaces will be substituted for underscores 127 spaces will be substituted for underscores
128 """ 128 """
129 # TODO : deal with CamelCaseFilenames 129 # TODO : deal with CamelCaseFilenames
130 130
131 separators = ['_', '-'] # space substitute separators
132
131 def __call__(self, request, data): 133 def __call__(self, request, data):
132 for f in data['files']: 134 for f in data['files']:
133 if f['description'] is None: 135 if f['description'] is None:
134 description = f['name'] 136 description = f['name']
135 if '.' in description: 137 if '.' in description:
136 description = description.rsplit('.', 1)[0] 138 description = description.rsplit('.', 1)[0]
137 decription = description.strip('_') 139 decription = description.strip('_')
138 if '_' in description: 140 for separator in self.separators:
139 description = ' '.join([i.title() for i in description.split('_')]) 141 if separator in description:
142 description = ' '.join([i.title() for i in description.split(separator)])
143
140 f['description'] = description 144 f['description'] = description
141 145
142 146
143 class TitleDescription(FormatterBase): 147 class TitleDescription(FormatterBase):
144 """ 148 """