Mercurial > hg > decoupage
comparison decoupage/formatters.py @ 53:9c15bde43ae6
dont capitalize unimportant words
author | Jeff Hammel <jhammel@mozilla.com> |
---|---|
date | Thu, 04 Nov 2010 18:51:30 -0700 |
parents | 8002dcdb8e82 |
children | ac1dc088e37e |
comparison
equal
deleted
inserted
replaced
51:8002dcdb8e82 | 53:9c15bde43ae6 |
---|---|
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 | 131 separators = ['_', '-'] # space substitute separators |
132 lesser_words = [ 'or', 'a', 'the', 'on', 'of' ] # unimportant words | |
132 | 133 |
133 def __call__(self, request, data): | 134 def __call__(self, request, data): |
134 for f in data['files']: | 135 for f in data['files']: |
135 if f['description'] is None: | 136 if f['description'] is None: |
136 description = f['name'] | 137 description = f['name'] |
137 if '.' in description: | 138 if '.' in description: |
138 description = description.rsplit('.', 1)[0] | 139 description = description.rsplit('.', 1)[0] |
139 decription = description.strip('_') | 140 decription = description.strip('_') |
140 for separator in self.separators: | 141 for separator in self.separators: |
141 if separator in description: | 142 if separator in description: |
142 description = ' '.join([i.title() for i in description.split(separator)]) | 143 description = ' '.join([(i in self.lesser_words) and i or i.title() |
143 | 144 for i in description.split(separator)]) |
145 description = description[0].upper() + description[1:] | |
144 f['description'] = description | 146 f['description'] = description |
145 | 147 |
146 | 148 |
147 class TitleDescription(FormatterBase): | 149 class TitleDescription(FormatterBase): |
148 """ | 150 """ |