changeset 53:9c15bde43ae6

dont capitalize unimportant words
author Jeff Hammel <jhammel@mozilla.com>
date Thu, 04 Nov 2010 18:51:30 -0700
parents 8002dcdb8e82
children 0e2b9e0507c5
files decoupage/formatters.py
diffstat 1 files changed, 4 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/decoupage/formatters.py
+++ b/decoupage/formatters.py
@@ -124,28 +124,30 @@ class FilenameDescription(FormatterBase)
     """
     obtain the description from the filename
     the file extension (if any) will be dropped and
     spaces will be substituted for underscores
     """
     # TODO : deal with CamelCaseFilenames
 
     separators = ['_', '-'] # space substitute separators
+    lesser_words = [ 'or', 'a', 'the', 'on', 'of' ] # unimportant words
 
     def __call__(self, request, data):
         for f in data['files']:
             if f['description'] is None:
                 description = f['name']
                 if '.' in description:
                     description = description.rsplit('.', 1)[0]
                 decription = description.strip('_')
                 for separator in self.separators:
                     if separator in description:
-                        description = ' '.join([i.title() for i in description.split(separator)])
-                        
+                        description = ' '.join([(i in self.lesser_words) and i or i.title()
+                                                for i in description.split(separator)])
+                        description = description[0].upper() + description[1:]
                 f['description'] = description
 
 
 class TitleDescription(FormatterBase):
     """
     splits a description into a title and a description via a separator in 
     the description.  The template will now have an additional variable, 
     'title', per file