Did I find the right examples for you? yes no

All Samples(5)  |  Call(4)  |  Derive(0)  |  Import(1)

        def loader(string, allowed=None):
    allowed = allowed or delgado.config.get('allowed', [])
    try:
        obj = loads(string)
        for exe in obj.keys():
            if exe not in allowed:
                raise Forbidden('Executable %s, is not allowed' % exe)

        return format_command(obj)
    except ValueError:
        msg = 'unable to parse unexpected input: %s' % repr(string)
        raise InvalidFormat(msg)
        


src/d/e/delgado-0.0.1/delgado/server.py   delgado(Download)
from tambo import Transport
import delgado
from delgado.loader import loader
from delgado.exceptions import Forbidden, InvalidFormat, Reconnect
from delgado import logger
            if not raw_data:
                raise Reconnect
            data = loader(raw_data)
            logger.info("Running command: %s" % data)
            call(data)

src/d/e/delgado-0.0.1/delgado/tests/test_loader.py   delgado(Download)
    def test_loader_simplest_obj(self):
        result = loader.loader("""{"foo": []}""", allowed=['foo'])
        assert result == ['foo']
 
    def test_loader_not_allowed(self):
        with raises(Forbidden):
            loader.loader("""{"foo": []}""")
    def test_unable_to_parse(self):
        with raises(InvalidFormat):
            loader.loader("""foo": []}""", allowed=['foo'])