Kronuz / pyScss

pyScss, a Scss compiler for Python
MIT License
582 stars 141 forks source link

Small bug fixes #310

Closed jrcartee closed 10 years ago

jrcartee commented 10 years ago

I was just trying pyScss out for the first time, but hit a couple of issues.

When running this command: pyscss client/scss/index.scss -o client/css/index.css

I received this traceback

Traceback (most recent call last):
  File "/home/user/github/know_your/.env/bin/pyscss", line 9, in <module>
    load_entry_point('pyScss==1.3.1', 'console_scripts', 'pyscss')()
  File "/home/user/github/know_your/.env/local/lib/python2.7/site-packages/scss/tool.py", line 145, in main
    do_build(options, args)
  File "/home/user/github/know_your/.env/local/lib/python2.7/site-packages/scss/tool.py", line 181, in do_build
    source = SourceFile.from_filename(path, is_sass=options.is_sass)
  File "/home/user/github/know_your/.env/local/lib/python2.7/site-packages/scss/source.py", line 182, in from_path
    origin, relpath = cls._key_from_path(path, origin)
  File "/home/user/github/know_your/.env/local/lib/python2.7/site-packages/scss/source.py", line 155, in _key_from_path
    origin = path.parent.resolve()
AttributeError: 'str' object has no attribute 'parent'

and when running with the watchdog feature like so: pyscss -r -w client/scss/ -o client/css/ I received this one:

Exception in thread Thread-1:
Traceback (most recent call last):
  File "/usr/lib/python2.7/threading.py", line 810, in __bootstrap_inner
    self.run()
  File "/home/user/github/know_your/.env/local/lib/python2.7/site-packages/watchdog/observers/api.py", line 236, in run
    self.dispatch_events(self.event_queue, self.timeout)
  File "/home/user/github/know_your/.env/local/lib/python2.7/site-packages/watchdog/observers/api.py", line 406, in dispatch_events
    self._dispatch_event(event, watch)
  File "/home/user/github/know_your/.env/local/lib/python2.7/site-packages/watchdog/observers/api.py", line 401, in _dispatch_event
    handler.dispatch(event)
  File "/home/user/github/know_your/.env/local/lib/python2.7/site-packages/watchdog/events.py", line 468, in dispatch
    _method_map[event_type](event)
  File "/home/user/github/know_your/.env/local/lib/python2.7/site-packages/scss/tool.py", line 258, in on_moved
    self.process(event.dest_path)
  File "/home/user/github/know_your/.env/local/lib/python2.7/site-packages/scss/tool.py", line 234, in process
    self.compile(path)
  File "/home/user/github/know_your/.env/local/lib/python2.7/site-packages/scss/tool.py", line 254, in compile
    dest_file.write(self.css.compile(scss_file=src_path))
  File "/home/user/github/know_your/.env/local/lib/python2.7/site-packages/scss/legacy.py", line 174, in compile
    is_sass=is_sass,
  File "/home/user/github/know_your/.env/local/lib/python2.7/site-packages/scss/source.py", line 199, in from_file
    contents = f.read()
AttributeError: 'str' object has no attribute 'read'

These two commits fix the two separate issues for me. I'm not very familiar with your code base, so I'm not sure if these changes affect anything elsewhere.

Thanks for all your hard work on this project :)

eevee commented 10 years ago

Whoops; pathlib was sort of added at the last minute in an attempt to fix something else. Thanks for this! :)