Skip to content

Commit

Permalink
Merge pull request #142 from asottile/fixup
Browse files Browse the repository at this point in the history
Expose libsass_version in public api
  • Loading branch information
asottile committed Mar 23, 2016
2 parents 8ceeac8 + c59fd9b commit cb3aa0d
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 16 deletions.
19 changes: 11 additions & 8 deletions sass.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,20 @@

from six import string_types, text_type, PY2, PY3

from _sass import OUTPUT_STYLES, compile_filename, compile_string
import _sass

__all__ = ('MODES', 'OUTPUT_STYLES', 'SOURCE_COMMENTS', 'CompileError',
'SassColor', 'SassError', 'SassFunction', 'SassList', 'SassMap',
'SassNumber', 'SassWarning', 'and_join', 'compile')
__all__ = (
'MODES', 'OUTPUT_STYLES', 'SOURCE_COMMENTS', 'CompileError', 'SassColor',
'SassError', 'SassFunction', 'SassList', 'SassMap', 'SassNumber',
'SassWarning', 'and_join', 'compile', 'libsass_version',
)
__version__ = '0.10.1'
libsass_version = _sass.libsass_version


#: (:class:`collections.Mapping`) The dictionary of output styles.
#: Keys are output name strings, and values are flag integers.
OUTPUT_STYLES = OUTPUT_STYLES
OUTPUT_STYLES = _sass.OUTPUT_STYLES

#: (:class:`collections.Mapping`) The dictionary of source comments styles.
#: Keys are mode names, and values are corresponding flag integers.
Expand Down Expand Up @@ -226,7 +229,7 @@ def compile_dirname(
output_filename = os.path.join(output_path, relpath_to_file)
output_filename = re.sub('.s[ac]ss$', '.css', output_filename)
input_filename = input_filename.encode(fs_encoding)
s, v, _ = compile_filename(
s, v, _ = _sass.compile_filename(
input_filename, output_style, source_comments, include_paths,
precision, None, custom_functions, importers
)
Expand Down Expand Up @@ -584,7 +587,7 @@ def my_importer(path):
raise TypeError('indented must be bool, not ' +
repr(source_comments))
_check_no_remaining_kwargs(compile, kwargs)
s, v = compile_string(
s, v = _sass.compile_string(
string, output_style, source_comments, include_paths, precision,
custom_functions, indented, importers,
)
Expand All @@ -599,7 +602,7 @@ def my_importer(path):
elif isinstance(filename, text_type):
filename = filename.encode(fs_encoding)
_check_no_remaining_kwargs(compile, kwargs)
s, v, source_map = compile_filename(
s, v, source_map = _sass.compile_filename(
filename, output_style, source_comments, include_paths, precision,
source_map_filename, custom_functions, importers,
)
Expand Down
15 changes: 7 additions & 8 deletions sassc.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,22 +74,21 @@
import sys
import time

import _sass
from sass import __version__ as VERSION, OUTPUT_STYLES, CompileError, compile
import sass


def main(argv=sys.argv, stdout=sys.stdout, stderr=sys.stderr):
parser = optparse.OptionParser(
usage='%prog [options] SCSS_FILE [OUT_CSS_FILE]',
version='%prog {0} (sass/libsass {1})'.format(
VERSION, _sass.libsass_version,
sass.__version__, sass.libsass_version,
),
)
output_styles = list(OUTPUT_STYLES)
output_styles = list(sass.OUTPUT_STYLES)
output_styles = ', '.join(output_styles[:-1]) + ', or ' + output_styles[-1]
parser.add_option(
'-t', '--style', '-s', '--output-style', metavar='STYLE',
type='choice', choices=list(OUTPUT_STYLES), default='nested',
type='choice', choices=list(sass.OUTPUT_STYLES), default='nested',
help=(
'Coding style of the compiled result. Choose one of ' +
output_styles + '. [default: %default]'
Expand Down Expand Up @@ -144,7 +143,7 @@ def main(argv=sys.argv, stdout=sys.stdout, stderr=sys.stderr):
mtime = os.stat(filename).st_mtime
if options.source_map:
source_map_filename = args[1] + '.map' # FIXME
css, source_map = compile(
css, source_map = sass.compile(
filename=filename,
output_style=options.style,
source_comments=options.source_comments,
Expand All @@ -155,7 +154,7 @@ def main(argv=sys.argv, stdout=sys.stdout, stderr=sys.stderr):
else:
source_map_filename = None
source_map = None
css = compile(
css = sass.compile(
filename=filename,
output_style=options.style,
source_comments=options.source_comments,
Expand All @@ -165,7 +164,7 @@ def main(argv=sys.argv, stdout=sys.stdout, stderr=sys.stderr):
except (IOError, OSError) as e:
error(e)
return 3
except CompileError as e:
except sass.CompileError as e:
error(e)
if not options.watch:
return 1
Expand Down

0 comments on commit cb3aa0d

Please sign in to comment.