Пример #1
0
def determine_personal_schemas(spec):
    personal_schemas = set()
    for role, config in spec.items():
        if config and common.parse_bool(
                config.get('has_personal_schema', False)):
            personal_schemas.add(role)

    return personal_schemas
Пример #2
0
def determine_superusers(spec):
    superusers = set()
    for role, config in spec.items():
        if not config:
            continue

        if common.parse_bool(config.get('is_superuser', False)):
            superusers.add(role)

    return superusers
Пример #3
0
def determine_personal_schemas(spec):
    """
    Returns:
        set: A set of ObjectName instances of personal schemas
    """
    personal_schemas = set()
    for role, config in spec.items():
        if config and common.parse_bool(
                config.get('has_personal_schema', False)):
            personal_schemas.add(common.ObjectName(role))

    return personal_schemas
Пример #4
0
def determine_schema_owners(spec):
    schema_owners = dict()
    for role, config in spec.items():
        if not config:
            continue

        if 'owns' in config:
            owned_schemas = config['owns'].get('schemas', ())
            for schema in owned_schemas:
                schema_owners[schema] = role

        if common.parse_bool(config.get('has_personal_schema', False)):
            schema_owners[role] = role

    return schema_owners
Пример #5
0
def determine_schema_owners(spec):
    """ Create a dict of {ObjectName(schema): owner} """
    schema_owners = dict()
    for role, config in spec.items():
        if not config:
            continue

        if 'owns' in config:
            owned_schemas = config['owns'].get('schemas', ())
            for schema in owned_schemas:
                schema_owners[schema] = role

        if common.parse_bool(config.get('has_personal_schema', False)):
            schema_owners[common.ObjectName(role)] = role

    return schema_owners
Пример #6
0
def test_parse_bool(value, expected):
    assert common.parse_bool(value) == expected