99import os
1010import os .path
1111import re
12+ import warnings
1213
1314from six import string_types
1415
@@ -86,7 +87,8 @@ class Manifest(object):
8687 :param css_path: the path of the directory to store compiled CSS
8788 files
8889 :type css_path: :class:`str`, :class:`basestring`
89-
90+ :param strip_extension: whether to remove the original file extension
91+ :type strip_extension: :class:`bool`
9092 """
9193
9294 @classmethod
@@ -106,6 +108,8 @@ def normalize_manifests(cls, manifests):
106108 continue
107109 elif isinstance (manifest , tuple ):
108110 manifest = Manifest (* manifest )
111+ elif isinstance (manifest , collections .Mapping ):
112+ manifest = Manifest (** manifest )
109113 elif isinstance (manifest , string_types ):
110114 manifest = Manifest (manifest )
111115 else :
@@ -117,7 +121,13 @@ def normalize_manifests(cls, manifests):
117121 manifests [package_name ] = manifest
118122 return manifests
119123
120- def __init__ (self , sass_path , css_path = None , wsgi_path = None ):
124+ def __init__ (
125+ self ,
126+ sass_path ,
127+ css_path = None ,
128+ wsgi_path = None ,
129+ strip_extension = None ,
130+ ):
121131 if not isinstance (sass_path , string_types ):
122132 raise TypeError ('sass_path must be a string, not ' +
123133 repr (sass_path ))
@@ -131,9 +141,23 @@ def __init__(self, sass_path, css_path=None, wsgi_path=None):
131141 elif not isinstance (wsgi_path , string_types ):
132142 raise TypeError ('wsgi_path must be a string, not ' +
133143 repr (wsgi_path ))
144+ if strip_extension is None :
145+ warnings .warn (
146+ '`strip_extension` was not specified, defaulting to `False`.\n '
147+ 'In the future, `strip_extension` will default to `True`.' ,
148+ DeprecationWarning ,
149+ )
150+ strip_extension = False
151+ elif not isinstance (strip_extension , bool ):
152+ raise TypeError (
153+ 'strip_extension must be bool not {!r}' .format (
154+ strip_extension ,
155+ ),
156+ )
134157 self .sass_path = sass_path
135158 self .css_path = css_path
136159 self .wsgi_path = wsgi_path
160+ self .strip_extension = strip_extension
137161
138162 def resolve_filename (self , package_dir , filename ):
139163 """Gets a proper full relative path of Sass source and
@@ -149,6 +173,8 @@ def resolve_filename(self, package_dir, filename):
149173
150174 """
151175 sass_path = os .path .join (package_dir , self .sass_path , filename )
176+ if self .strip_extension :
177+ filename , _ = os .path .splitext (filename )
152178 css_filename = filename + '.css'
153179 css_path = os .path .join (package_dir , self .css_path , css_filename )
154180 return sass_path , css_path
0 commit comments