Skip to content

Commit cb3aa0d

Browse files
committed
Merge pull request #142 from asottile/fixup
Expose libsass_version in public api
2 parents 8ceeac8 + c59fd9b commit cb3aa0d

File tree

2 files changed

+18
-16
lines changed

2 files changed

+18
-16
lines changed

sass.py

+11-8
Original file line numberDiff line numberDiff line change
@@ -24,17 +24,20 @@
2424

2525
from six import string_types, text_type, PY2, PY3
2626

27-
from _sass import OUTPUT_STYLES, compile_filename, compile_string
27+
import _sass
2828

29-
__all__ = ('MODES', 'OUTPUT_STYLES', 'SOURCE_COMMENTS', 'CompileError',
30-
'SassColor', 'SassError', 'SassFunction', 'SassList', 'SassMap',
31-
'SassNumber', 'SassWarning', 'and_join', 'compile')
29+
__all__ = (
30+
'MODES', 'OUTPUT_STYLES', 'SOURCE_COMMENTS', 'CompileError', 'SassColor',
31+
'SassError', 'SassFunction', 'SassList', 'SassMap', 'SassNumber',
32+
'SassWarning', 'and_join', 'compile', 'libsass_version',
33+
)
3234
__version__ = '0.10.1'
35+
libsass_version = _sass.libsass_version
3336

3437

3538
#: (:class:`collections.Mapping`) The dictionary of output styles.
3639
#: Keys are output name strings, and values are flag integers.
37-
OUTPUT_STYLES = OUTPUT_STYLES
40+
OUTPUT_STYLES = _sass.OUTPUT_STYLES
3841

3942
#: (:class:`collections.Mapping`) The dictionary of source comments styles.
4043
#: Keys are mode names, and values are corresponding flag integers.
@@ -226,7 +229,7 @@ def compile_dirname(
226229
output_filename = os.path.join(output_path, relpath_to_file)
227230
output_filename = re.sub('.s[ac]ss$', '.css', output_filename)
228231
input_filename = input_filename.encode(fs_encoding)
229-
s, v, _ = compile_filename(
232+
s, v, _ = _sass.compile_filename(
230233
input_filename, output_style, source_comments, include_paths,
231234
precision, None, custom_functions, importers
232235
)
@@ -584,7 +587,7 @@ def my_importer(path):
584587
raise TypeError('indented must be bool, not ' +
585588
repr(source_comments))
586589
_check_no_remaining_kwargs(compile, kwargs)
587-
s, v = compile_string(
590+
s, v = _sass.compile_string(
588591
string, output_style, source_comments, include_paths, precision,
589592
custom_functions, indented, importers,
590593
)
@@ -599,7 +602,7 @@ def my_importer(path):
599602
elif isinstance(filename, text_type):
600603
filename = filename.encode(fs_encoding)
601604
_check_no_remaining_kwargs(compile, kwargs)
602-
s, v, source_map = compile_filename(
605+
s, v, source_map = _sass.compile_filename(
603606
filename, output_style, source_comments, include_paths, precision,
604607
source_map_filename, custom_functions, importers,
605608
)

sassc.py

+7-8
Original file line numberDiff line numberDiff line change
@@ -74,22 +74,21 @@
7474
import sys
7575
import time
7676

77-
import _sass
78-
from sass import __version__ as VERSION, OUTPUT_STYLES, CompileError, compile
77+
import sass
7978

8079

8180
def main(argv=sys.argv, stdout=sys.stdout, stderr=sys.stderr):
8281
parser = optparse.OptionParser(
8382
usage='%prog [options] SCSS_FILE [OUT_CSS_FILE]',
8483
version='%prog {0} (sass/libsass {1})'.format(
85-
VERSION, _sass.libsass_version,
84+
sass.__version__, sass.libsass_version,
8685
),
8786
)
88-
output_styles = list(OUTPUT_STYLES)
87+
output_styles = list(sass.OUTPUT_STYLES)
8988
output_styles = ', '.join(output_styles[:-1]) + ', or ' + output_styles[-1]
9089
parser.add_option(
9190
'-t', '--style', '-s', '--output-style', metavar='STYLE',
92-
type='choice', choices=list(OUTPUT_STYLES), default='nested',
91+
type='choice', choices=list(sass.OUTPUT_STYLES), default='nested',
9392
help=(
9493
'Coding style of the compiled result. Choose one of ' +
9594
output_styles + '. [default: %default]'
@@ -144,7 +143,7 @@ def main(argv=sys.argv, stdout=sys.stdout, stderr=sys.stderr):
144143
mtime = os.stat(filename).st_mtime
145144
if options.source_map:
146145
source_map_filename = args[1] + '.map' # FIXME
147-
css, source_map = compile(
146+
css, source_map = sass.compile(
148147
filename=filename,
149148
output_style=options.style,
150149
source_comments=options.source_comments,
@@ -155,7 +154,7 @@ def main(argv=sys.argv, stdout=sys.stdout, stderr=sys.stderr):
155154
else:
156155
source_map_filename = None
157156
source_map = None
158-
css = compile(
157+
css = sass.compile(
159158
filename=filename,
160159
output_style=options.style,
161160
source_comments=options.source_comments,
@@ -165,7 +164,7 @@ def main(argv=sys.argv, stdout=sys.stdout, stderr=sys.stderr):
165164
except (IOError, OSError) as e:
166165
error(e)
167166
return 3
168-
except CompileError as e:
167+
except sass.CompileError as e:
169168
error(e)
170169
if not options.watch:
171170
return 1

0 commit comments

Comments
 (0)