Did I find the right examples for you? yes no

All Samples(44)  |  Call(33)  |  Derive(0)  |  Import(11)

        def get_needed():
    needed = thread_local_needed_data.__dict__.get(NEEDED)
    if needed is None:
        # When no NeededResources have been set up, we inject a
        # DummyNeededResources object here.
        # We do this in order not to tax other code that may need()
        # a resource here and there but has not set up NeededResources.
        return DummyNeededResources()
    return needed
        


src/j/s/js.amcharts-3.3.1/js/amcharts/__init__.py   js.amcharts(Download)
from fanstatic import Library, Resource, get_needed
 
 
library = Library('amcharts', 'resources')
 
def find_images_url():
    needed = get_needed()
    library_url = needed.library_url(library)
    return '%s/images/' % library_url
 

src/s/i/silva.fanstatic-1.2/src/silva/fanstatic/__init__.py   silva.fanstatic(Download)
from silva.fanstatic.resources import ExternalResource, Snippet
from fanstatic import Group
from fanstatic import get_needed
 
__all__ = [

src/z/o/zope.fanstatic-0.12/src/zope/fanstatic/zopesupport.py   zope.fanstatic(Download)
    # on essential information for computing URLs. One example of such
    # information is that of the virtualhost namespace traversal.
    needed = fanstatic.get_needed()
    ensure_base_url(needed, event.request)
 
@adapter(IHandleExceptionEvent)
def clear_needed_resources(event):
    needed = fanstatic.get_needed()
    def __str__(self):
        needed = fanstatic.get_needed()
        if not isinstance(needed, fanstatic.NeededResources):
            # We cannot render a URL in this case, we just return some
            # fake url to indicate this.

src/s/i/silva.fanstatic-1.2/src/silva/fanstatic/support.py   silva.fanstatic(Download)
    def __str__(self):
        needed = fanstatic.get_needed()
        if not needed.has_base_url():
            needed.set_base_url(IVirtualSite(self.request).get_root_url())
        return needed.library_url(self.library) + self.name
def set_base_url(event):
    needed = fanstatic.get_needed()
    if not needed.has_resources():
        return
    if not needed.has_base_url():

src/f/a/fanstatic-1.0a5/tests/test_core.py   fanstatic(Download)
import pytest
 
from fanstatic import (Library,
                       Resource,
                       NeededResources,
    y1 = Resource(foo, 'c.js', depends=[x1, x2])
 
    dummy = get_needed()
    assert not isinstance(dummy, NeededResources)
 
    # We return a new dummy instance for every get_needed:
    dummy2 = get_needed()
def test_convenience_clear_not_initialized():
    # This test is put near the top of this module, or at least before
    # the very first time ``init_needed()`` is called.
    dummy = get_needed()
    with pytest.raises(NotImplementedError):
    # Initialize a needed resources object.
    needed = init_needed()
    assert get_needed() == needed
    assert thread_local_needed_data.__dict__[NEEDED] == needed
 

src/f/a/fanstatic-tools-0.2/fanstatic/test_core.py   fanstatic-tools(Download)
import six
 
from fanstatic import (Library,
                       Resource,
                       NeededResources,
    y1 = Resource(foo, 'c.js', depends=[x1, x2])
 
    dummy = get_needed()
    assert not isinstance(dummy, NeededResources)
 
    # We return a new dummy instance for every get_needed:
    dummy2 = get_needed()
def test_convenience_clear_not_initialized():
    # This test is put near the top of this module, or at least before
    # the very first time ``init_needed()`` is called.
    dummy = get_needed()
    with pytest.raises(NotImplementedError):
    # Initialize a needed resources object.
    needed = init_needed()
    assert get_needed() == needed
    assert thread_local_needed_data.__dict__[NEEDED] == needed
 

src/f/a/fanstatic-1.0a5/tests/test_wsgi.py   fanstatic(Download)
import pytest
import webob
 
from fanstatic import (Library, Resource,
                       get_needed, make_serf, compat)
    def app(environ, start_response):
        start_response('200 OK', [])
        needed = get_needed()
        needed.need(y1)
        return [b'<html><head></head><body</body></html>']
    def app(environ, start_response):
        start_response('200 OK', [])
        needed = get_needed()
        needed.need(y1)
        return [b'<html><head></head><body</body></html>']
    def app(environ, start_response):
        start_response('200 OK', [])
        needed = get_needed()
        needed.need(y1)
        return [b'<html><head></head><body</body></html>']

src/f/a/fanstatic-1.0a5/tests/test_injector.py   fanstatic(Download)
import pytest
import webob
 
from fanstatic import (Library, Resource, Injector, get_needed,
                       NEEDED)
    def app(environ, start_response):
        start_response('200 OK', [])
        needed = get_needed()
        needed.need(y1)
        needed.set_base_url('http://testapp')
    # There's no NeededResources object anymore after the request has
    # been done.
    dummy = get_needed()
    with pytest.raises(NotImplementedError):
        dummy.clear()
    # been done, even for response content types that would not have
    # been processed by fanstatic's inclusion rendering.
    dummy = get_needed()
    with pytest.raises(NotImplementedError):
        dummy.clear()
    def app(environ, start_response):
        start_response('200 OK', [('Content-Type', 'text/plain')])
        needed = get_needed()
        needed.need(y1)
        return [b'<html><head></head><body</body></html>']

src/v/o/voteit.core-HEAD/voteit/core/views/tests/test_api.py   voteit.core(Download)
        dummy_form = deform.Form(DummySchema())
 
        from fanstatic import get_needed
        from fanstatic import init_needed
        from fanstatic import NeededResources
        obj = self._cut(context, request)
        obj.register_form_resources(dummy_form)
        needed_resources = get_needed()
        self.assertIsInstance(needed_resources, NeededResources)
        filenames = [x.filename for x in needed_resources.resources()]

src/v/o/voteit.core-HEAD/voteit/core/tests/test_widgets.py   voteit.core(Download)
import deform
from pyramid import testing
from fanstatic import get_needed
from fanstatic import init_needed
from fanstatic import NeededResources

  1 | 2  Next