From d240301956af3195f816974d84213444e6228b7f Mon Sep 17 00:00:00 2001 From: Alexander Skvortsov Date: Mon, 31 Dec 2018 00:36:34 -0500 Subject: [PATCH 1/4] Added option to not scan .py files --- sass_processor/management/commands/compilescss.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/sass_processor/management/commands/compilescss.py b/sass_processor/management/commands/compilescss.py index 8b1c5c0..823a2ee 100644 --- a/sass_processor/management/commands/compilescss.py +++ b/sass_processor/management/commands/compilescss.py @@ -79,11 +79,18 @@ def add_arguments(self, parser): ) parser.add_argument( '--sass-precision', + action='store_true', dest='sass_precision', type=int, help=_( "Set the precision for numeric computations in the SASS processor. Default: settings.SASS_PRECISION.") ) + parser.add_argument( + '--scan-py', + dest='include_py', + default=True, + help=_("Scan python files?") + ) def get_loaders(self): template_source_loaders = [] @@ -148,6 +155,7 @@ def handle(self, *args, **options): self.processed_files = [] + if options['include_py']: # find all Python files making up this project; They might invoke `sass_processor` for py_source in self.find_sources(): if self.verbosity > 1: From b502fce00e85b8e0df24ff35792a959381d7fdbd Mon Sep 17 00:00:00 2001 From: Alexander Skvortsov Date: Mon, 31 Dec 2018 00:36:34 -0500 Subject: [PATCH 2/4] Added option to not scan .py files --- sass_processor/management/commands/compilescss.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/sass_processor/management/commands/compilescss.py b/sass_processor/management/commands/compilescss.py index 8b1c5c0..823a2ee 100644 --- a/sass_processor/management/commands/compilescss.py +++ b/sass_processor/management/commands/compilescss.py @@ -79,11 +79,18 @@ def add_arguments(self, parser): ) parser.add_argument( '--sass-precision', + action='store_true', dest='sass_precision', type=int, help=_( "Set the precision for numeric computations in the SASS processor. Default: settings.SASS_PRECISION.") ) + parser.add_argument( + '--scan-py', + dest='include_py', + default=True, + help=_("Scan python files?") + ) def get_loaders(self): template_source_loaders = [] @@ -148,6 +155,7 @@ def handle(self, *args, **options): self.processed_files = [] + if options['include_py']: # find all Python files making up this project; They might invoke `sass_processor` for py_source in self.find_sources(): if self.verbosity > 1: From 6493b4c50116e3d8879357d2a44858a5a402492d Mon Sep 17 00:00:00 2001 From: Alexander Skvortsov Date: Mon, 31 Dec 2018 00:47:34 -0500 Subject: [PATCH 3/4] Fixed indentation --- .../management/commands/compilescss.py | 39 ++++++++++--------- 1 file changed, 20 insertions(+), 19 deletions(-) diff --git a/sass_processor/management/commands/compilescss.py b/sass_processor/management/commands/compilescss.py index 823a2ee..ecbbbbe 100644 --- a/sass_processor/management/commands/compilescss.py +++ b/sass_processor/management/commands/compilescss.py @@ -78,18 +78,19 @@ def add_arguments(self, parser): help=_("Set templating engine used (django, jinja2). Default: django.") ) parser.add_argument( - '--sass-precision', action='store_true', + '--sass-precision', dest='sass_precision', type=int, help=_( "Set the precision for numeric computations in the SASS processor. Default: settings.SASS_PRECISION.") ) parser.add_argument( - '--scan-py', - dest='include_py', - default=True, - help=_("Scan python files?") + '--exclude-py', + action='store_true', + dest='exclude_py', + default=False, + help=_("Exclude python files from scan?") ) def get_loaders(self): @@ -155,20 +156,20 @@ def handle(self, *args, **options): self.processed_files = [] - if options['include_py']: - # find all Python files making up this project; They might invoke `sass_processor` - for py_source in self.find_sources(): - if self.verbosity > 1: - self.stdout.write("Parsing file: %s" % py_source) - elif self.verbosity == 1: - self.stdout.write(".", ending="") - try: - self.parse_source(py_source) - except SyntaxError as e: - self.stderr.write("Syntax error encountered processing %s" % py_source) - self.stderr.write("Aborting compilation") - raise - + if not options['exclude_py']: + # find all Python files making up this project; They might invoke `sass_processor` + for py_source in self.find_sources(): + if self.verbosity > 1: + self.stdout.write("Parsing file: %s" % py_source) + elif self.verbosity == 1: + self.stdout.write(".", ending="") + try: + self.parse_source(py_source) + except SyntaxError as e: + self.stderr.write("Syntax error encountered processing %s" % py_source) + self.stderr.write("Aborting compilation") + raise + # find all Django/Jinja2 templates making up this project; They might invoke `sass_src` templates = self.find_templates() From bb18c226be12253320786f3db0d992daeedae2d1 Mon Sep 17 00:00:00 2001 From: Alexander Skvortsov Date: Mon, 31 Dec 2018 00:55:15 -0500 Subject: [PATCH 4/4] Removed unnecssary argument from sass-precision definition --- sass_processor/management/commands/compilescss.py | 1 - 1 file changed, 1 deletion(-) diff --git a/sass_processor/management/commands/compilescss.py b/sass_processor/management/commands/compilescss.py index ecbbbbe..14621b5 100644 --- a/sass_processor/management/commands/compilescss.py +++ b/sass_processor/management/commands/compilescss.py @@ -78,7 +78,6 @@ def add_arguments(self, parser): help=_("Set templating engine used (django, jinja2). Default: django.") ) parser.add_argument( - action='store_true', '--sass-precision', dest='sass_precision', type=int,