Skip to content

Commit 70464cc

Browse files
committed
Remove deprecated --watch
1 parent d02e788 commit 70464cc

File tree

1 file changed

+39
-80
lines changed

1 file changed

+39
-80
lines changed

sassc.py

Lines changed: 39 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -35,18 +35,6 @@
3535
3636
.. versionadded:: 0.4.0
3737
38-
.. option:: -w, --watch
39-
40-
Watch file for changes. Requires the second argument (output CSS
41-
filename).
42-
43-
.. note:: Note that ``--watch`` does not understand imports. Due to this, the
44-
option is scheduled for removal in a future version. It is suggested to
45-
use a third party tool which implements intelligent watching functionality.
46-
47-
.. versionadded:: 0.4.0
48-
.. deprecated:: 0.11.2
49-
5038
.. option:: -p, --precision
5139
5240
Set the precision for numbers. Default is 5.
@@ -107,9 +95,6 @@ def main(argv=sys.argv, stdout=sys.stdout, stderr=sys.stderr):
10795
dest='include_paths', action='append',
10896
help='Path to find "@import"ed (S)CSS source files. '
10997
'Can be multiply used.')
110-
parser.add_option('-w', '--watch', action='store_true',
111-
help='Watch file for changes. Requires the second '
112-
'argument (output css filename).')
11398
parser.add_option(
11499
'-p', '--precision', action='store', type='int', default=5,
115100
help='Set the precision for numbers. [default: %default]'
@@ -136,73 +121,47 @@ def main(argv=sys.argv, stdout=sys.stdout, stderr=sys.stderr):
136121
error('-m/-g/--sourcemap requires the second argument, the output '
137122
'css filename.')
138123
return 2
139-
elif options.watch and len(args) < 2:
140-
parser.print_usage(stderr)
141-
error('-w/--watch requires the second argument, the output css '
142-
'filename.')
143-
return 2
144-
else:
145-
pass
146-
while True:
147-
try:
148-
mtime = os.stat(filename).st_mtime
149-
if options.source_map:
150-
source_map_filename = args[1] + '.map' # FIXME
151-
css, source_map = sass.compile(
152-
filename=filename,
153-
output_style=options.style,
154-
source_comments=options.source_comments,
155-
source_map_filename=source_map_filename,
156-
output_filename_hint=args[1],
157-
include_paths=options.include_paths,
158-
precision=options.precision
159-
)
160-
else:
161-
source_map_filename = None
162-
source_map = None
163-
css = sass.compile(
164-
filename=filename,
165-
output_style=options.style,
166-
source_comments=options.source_comments,
167-
include_paths=options.include_paths,
168-
precision=options.precision
169-
)
170-
except (IOError, OSError) as e:
171-
error(e)
172-
return 3
173-
except sass.CompileError as e:
174-
error(e)
175-
if not options.watch:
176-
return 1
177-
except KeyboardInterrupt:
178-
break
124+
125+
try:
126+
mtime = os.stat(filename).st_mtime
127+
if options.source_map:
128+
source_map_filename = args[1] + '.map' # FIXME
129+
css, source_map = sass.compile(
130+
filename=filename,
131+
output_style=options.style,
132+
source_comments=options.source_comments,
133+
source_map_filename=source_map_filename,
134+
output_filename_hint=args[1],
135+
include_paths=options.include_paths,
136+
precision=options.precision
137+
)
179138
else:
180-
if len(args) < 2:
181-
print(css, file=stdout)
182-
else:
183-
with io.open(args[1], 'w', encoding='utf-8', newline='') as f:
184-
f.write(css)
185-
if options.watch:
186-
print(filename, 'is just compiled to', args[1],
187-
file=stdout)
188-
if source_map_filename:
189-
with io.open(
190-
source_map_filename, 'w', encoding='utf-8', newline='',
191-
) as f:
192-
f.write(source_map)
193-
if options.watch: # pragma: no cover
194-
# FIXME: we should utilize inotify on Linux, and FSEvents on Mac
195-
while True:
196-
try:
197-
st = os.stat(filename)
198-
if st.st_mtime > mtime:
199-
print(filename, 'changed; recompile...', file=stdout)
200-
break
201-
time.sleep(0.5)
202-
except KeyboardInterrupt:
203-
return 0
139+
source_map_filename = None
140+
source_map = None
141+
css = sass.compile(
142+
filename=filename,
143+
output_style=options.style,
144+
source_comments=options.source_comments,
145+
include_paths=options.include_paths,
146+
precision=options.precision
147+
)
148+
except (IOError, OSError) as e:
149+
error(e)
150+
return 3
151+
except sass.CompileError as e:
152+
error(e)
153+
return 1
154+
else:
155+
if len(args) < 2:
156+
print(css, file=stdout)
204157
else:
205-
break
158+
with io.open(args[1], 'w', encoding='utf-8', newline='') as f:
159+
f.write(css)
160+
if source_map_filename:
161+
with io.open(
162+
source_map_filename, 'w', encoding='utf-8', newline='',
163+
) as f:
164+
f.write(source_map)
206165
return 0
207166

208167

0 commit comments

Comments
 (0)