Kronuz / pyScss

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

Formalize importers (like Ruby) #326

Open eevee opened 9 years ago

eevee commented 9 years ago

It's fairly common to want to keep the usual file path importing semantics that the core extension implements, but to actually look for those files in places that are not just the filesystem — for example, a Pyramid plugin may want to support filenames of the form some.python.module:assets/sass/foo, keeping in line with Pyramid "asset specifications".

Right now there's some undocumented and underspecified stuff implemented that lets you write a class sorta-kinda like pathlib.Path, and use that as a search dir.

It'd be nice to have a more formal interface for importer objects, and just wrap plain filesystem paths in such objects. This is what Ruby does.

eevee commented 9 years ago

Something that might be nice to provide out of the box is a faux filesystem that maps path names to strings of content. Would be helpful for testing, too.

rockymeza commented 9 years ago

Hi @eevee,

I tried to do the importer using an Extension, just to compare with the DjangoOrigin thing you did.

Do you have an idea for how we would override the filesystem stuff for things like the compass image extensions?

rockymeza commented 9 years ago

Would it possible for the image functions get access to the compilation object?

It might be difficult to rewrite all of the functions to accept a new argument. We could do it sort of like this:

ns.declare(takes_compilation=True)
def myfunc(compilation, myarg, myarg2):
    pass

I'm not sure what that would involve though.