def translate(patterns, flags):
    """Translate patterns."""

    positive = []
    negative = []
    if isinstance(patterns, (str, bytes)):
        patterns = [patterns]

    flags |= _TRANSLATE

    for pattern in patterns:
        for expanded in expand_braces(pattern, flags):
            (negative if is_negative(expanded, flags) else positive).append(
                WcParse(expanded, flags & FLAG_MASK).parse()
            )

    if patterns and flags & REALPATH and negative and not positive:
        positive.append(_compile(b'**' if isinstance(patterns[0], bytes) else '**', flags))

    return positive, negative
def translate ( patterns , flags ) : positive = [ ] negative = [ ] if isinstance ( patterns , ( str , bytes ) ) : patterns = [ patterns ] flags |= _TRANSLATE for pattern in patterns : for expanded in expand_braces ( pattern , flags ) : ( negative if is_negative ( expanded , flags ) else positive ) . append ( WcParse ( expanded , flags & FLAG_MASK ) . parse ( ) ) if patterns and flags & REALPATH and negative and not positive : positive . append ( _compile ( b'**' if isinstance ( patterns [ 0 ] , bytes ) else '**' , flags ) ) return positive , negative
Translate patterns.