How to use the funcy.omit function in funcy

To help you get started, we’ve selected a few funcy examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github jsmesami / naovoce / tests / api / v1 / test_signup.py View on Github external
def test_signup_missing_args(client, signup_email_request_data, missing_arg, error_msg):
    response = client.post(
        reverse('api:signup'),
        funcy.omit(signup_email_request_data(), [missing_arg]),
        content_type='application/json',
    )

    assert response.status_code == status.HTTP_400_BAD_REQUEST
    assert response.json() == error_msg
github jsmesami / naovoce / tests / api / v1 / test_fruit.py View on Github external
def test_fruit_create_missing_args(client, random_password, new_user, fruit_request_data, missing_arg, error_msg):
    password = random_password()
    user = new_user(password=password)

    assert client.login(username=user.username, password=password)

    response = client.post(
        reverse('api:fruit-list'),
        funcy.omit(fruit_request_data(), [missing_arg]),
        content_type='application/json',
    )

    assert response.status_code == status.HTTP_400_BAD_REQUEST
    assert response.json() == error_msg
github remorses / skema / skema / fake_data / hypo_schema.py View on Github external
def get_generator(prop, customs={}):
    disp = {"string": gen_string,
            "integer": gen_int,
            "number": gen_int,
            "boolean": gen_bool,
            
    }
    if prop.get('title') != None:
        title = prop.get('title', '') # .strip()
        if title in customs:
            return hs.builds(lambda x: customs[title](), hs.integers())
    if not omit(prop, ['title', 'description']):
        return gen_anything()

    enum = prop.get("enum", None)
    if enum is not None:
        return gen_enum(prop)

    if 'const' in prop:
        return gen_const(prop)

    one_of = prop.get("oneOf", None)
    if one_of is not None:
        return gen_one_of(prop, customs)

    any_of = prop.get("anyOf", None)
    if any_of is not None:
        return gen_any_of(prop, customs)
github Suor / django-cacheops / cacheops / redis.py View on Github external
def redis_client():
    if settings.CACHEOPS_REDIS and settings.CACHEOPS_SENTINEL:
        raise ImproperlyConfigured("CACHEOPS_REDIS and CACHEOPS_SENTINEL are mutually exclusive")

    client_class = CacheopsRedis
    if settings.CACHEOPS_CLIENT_CLASS:
        client_class = import_string(settings.CACHEOPS_CLIENT_CLASS)

    if settings.CACHEOPS_SENTINEL:
        if not {'locations', 'service_name'} <= set(settings.CACHEOPS_SENTINEL):
            raise ImproperlyConfigured("Specify locations and service_name for CACHEOPS_SENTINEL")

        sentinel = Sentinel(
            settings.CACHEOPS_SENTINEL['locations'],
            **omit(settings.CACHEOPS_SENTINEL, ('locations', 'service_name', 'db')))
        return sentinel.master_for(
            settings.CACHEOPS_SENTINEL['service_name'],
            redis_class=client_class,
            db=settings.CACHEOPS_SENTINEL.get('db', 0)
        )

    # Allow client connection settings to be specified by a URL.
    if isinstance(settings.CACHEOPS_REDIS, six.string_types):
        return client_class.from_url(settings.CACHEOPS_REDIS)
    else:
        return client_class(**settings.CACHEOPS_REDIS)
github remorses / mongoke / mongoke / skema_support.py View on Github external
def is_scalar(type_body):
    SCALARS = ["string", "number", "integer", "boolean"]
    # print(omit(type_body, ['description', 'title', '$schema']))
    return (
        type_body.get("type", "") in SCALARS
        # TODO add aliases, not only Type: Any
        or not omit(type_body, ["description", "title", "$schema"])
    )
github remorses / mongoke / example_generated_code / generated / resolvers / task_events.py View on Github external
def filter_nodes_by_guard(nodes, fields, jwt):
    for x in nodes:
        try:
            
            yield omit(x or dict(), fields)
        except Exception:
            pass
github remorses / mongoke / generated / generated / resolvers / human.py View on Github external
fields += []
    
    collection = ctx['db']['humans']
    x = await mongodb_streams.find_one(collection, match=where, pipeline=pipeline)
    if not (session['role'] == 'admin'):
        raise Exception("guard `session['role'] == 'admin'` not satisfied")
    else:
        fields += []
    
    if (x['type'] == 'user'):
        x['_typename'] = 'User'
    elif (x['type'] == 'guest'):
        x['_typename'] = 'Guest'
    
    if fields:
        x = omit(x or dict(), fields)
    return x
github remorses / mongoke / example_generated_code / generated / resolvers / task_events.py View on Github external
def filter_nodes_by_guard(nodes, fields, jwt):
    for x in nodes:
        try:
            
            yield omit(x or dict(), fields)
        except Exception:
            pass
github remorses / mongoke / play / play copy 2.py View on Github external
from funcy import omit

print(omit({'x': ''}, ['x']))