xpgdiff.py
def print_grants_migration_ddl(source_object, target_object):
    """
    Prints the migration DDL for grants on an object.

    :param source_object: The object in the source schema.
    :param target_object: The object in the target schema.
    """
    next_source_grant = next_or_none(sorted(source_object.grants, key=lambda g: g.role))
    next_target_grant = next_or_none(sorted(target_object.grants, key=lambda g: g.role))

    source_grant = next_source_grant()
    target_grant = next_target_grant()

    while source_grant or target_grant:
        if not target_grant:
            print(f'{source_grant.revokestr()}')
            source_grant = next_source_grant()
            continue

        if not source_grant:
            print(f'{str(target_grant)}')
            target_grant = next_target_grant()
            continue

        if source_grant.role < target_grant.role:
            print(f'{source_grant.revokestr()}')
            source_grant = next_source_grant()
            continue

        if source_grant.role > target_grant.role:
            print(f'{str(target_grant)}')
            target_grant = next_target_grant()
            continue

        print_grant_migration_ddl(source_object, source_grant, target_grant)
        source_grant = next_source_grant()
        target_grant = next_target_grant()

    Prints the migration DDL for grants on an object.

    :param source_object: The object in the source schema.
    :param target_object: The object in the target schema.
    
Prints the migration DDL for grants on an object.
Prints the migration DDL for grants on an object .
def print_grants_migration_ddl(source_object, target_object):
    next_source_grant = next_or_none(sorted(source_object.grants, key=lambda g: g.role))
    next_target_grant = next_or_none(sorted(target_object.grants, key=lambda g: g.role))
    source_grant = next_source_grant()
    target_grant = next_target_grant()
    while source_grant or target_grant:
        if not target_grant:
            print(f'{source_grant.revokestr()}')
            source_grant = next_source_grant()
            continue
        if not source_grant:
            print(f'{str(target_grant)}')
            target_grant = next_target_grant()
            continue
        if source_grant.role < target_grant.role:
            print(f'{source_grant.revokestr()}')
            source_grant = next_source_grant()
            continue
        if source_grant.role > target_grant.role:
            print(f'{str(target_grant)}')
            target_grant = next_target_grant()
            continue
        print_grant_migration_ddl(source_object, source_grant, target_grant)
        source_grant = next_source_grant()
        target_grant = next_target_grant()
def print_grants_migration_ddl ( source_object , target_object ) : next_source_grant = next_or_none ( sorted ( source_object . grants , key = lambda g : g . role ) ) next_target_grant = next_or_none ( sorted ( target_object . grants , key = lambda g : g . role ) ) source_grant = next_source_grant ( ) target_grant = next_target_grant ( ) while source_grant or target_grant : if not target_grant : print ( f'{source_grant.revokestr()}' ) source_grant = next_source_grant ( ) continue if not source_grant : print ( f'{str(target_grant)}' ) target_grant = next_target_grant ( ) continue if source_grant . role < target_grant . role : print ( f'{source_grant.revokestr()}' ) source_grant = next_source_grant ( ) continue if source_grant . role > target_grant . role : print ( f'{str(target_grant)}' ) target_grant = next_target_grant ( ) continue print_grant_migration_ddl ( source_object , source_grant , target_grant ) source_grant = next_source_grant ( ) target_grant = next_target_grant ( )
Prints the migration DDL for grants on an object.
Prints the migration DDL for grants on an object .
"""
    Prints the migration DDL for grants on an object.

    :param source_object: The object in the source schema.
    :param target_object: The object in the target schema.
    """
source_object
The object in the source schema.
The object in the source schema .
target_object
The object in the target schema.
The object in the target schema .