docs/support/requirements_to_rst.py
def ops_to_words(item):
    """Translate requirement specification to words."""
    unsupp_ops = ["~=", "==="]
    # Ordered for  "pleasant" word specification
    supp_ops = [">=", ">", "==", "<=", "<", "!="]
    tokens = sorted(item.split(","), reverse=True)
    actual_tokens = []
    for req in tokens:
        for op in unsupp_ops:
            if req.startswith(op):
                raise RuntimeError("Unsupported version specification: {0}".format(op))
        for op in supp_ops:
            if req.startswith(op):
                actual_tokens.append(op)
                break
        else:
            raise RuntimeError("Illegal comparison operator: {0}".format(op))
    if len(list(set(actual_tokens))) != len(actual_tokens):
        raise RuntimeError("Multiple comparison operators of the same type")
    if "!=" in actual_tokens:
        return (
            " and ".join([op_to_words(token) for token in tokens[:-1]])
            + " "
            + op_to_words(tokens[-1])
        )
    return " and ".join([op_to_words(token) for token in tokens])
def ops_to_words(item):
    unsupp_ops = ["~=", "==="]
    # Ordered for  "pleasant" word specification
    supp_ops = [">=", ">", "==", "<=", "<", "!="]
    tokens = sorted(item.split(","), reverse=True)
    actual_tokens = []
    for req in tokens:
        for op in unsupp_ops:
            if req.startswith(op):
                raise RuntimeError("Unsupported version specification: {0}".format(op))
        for op in supp_ops:
            if req.startswith(op):
                actual_tokens.append(op)
                break
        else:
            raise RuntimeError("Illegal comparison operator: {0}".format(op))
    if len(list(set(actual_tokens))) != len(actual_tokens):
        raise RuntimeError("Multiple comparison operators of the same type")
    if "!=" in actual_tokens:
        return (
            " and ".join([op_to_words(token) for token in tokens[:-1]])
            + " "
            + op_to_words(tokens[-1])
        )
    return " and ".join([op_to_words(token) for token in tokens])
def ops_to_words ( item ) : unsupp_ops = [ "~=" , "===" ] # Ordered for  "pleasant" word specification supp_ops = [ ">=" , ">" , "==" , "<=" , "<" , "!=" ] tokens = sorted ( item . split ( "," ) , reverse = True ) actual_tokens = [ ] for req in tokens : for op in unsupp_ops : if req . startswith ( op ) : raise RuntimeError ( "Unsupported version specification: {0}" . format ( op ) ) for op in supp_ops : if req . startswith ( op ) : actual_tokens . append ( op ) break else : raise RuntimeError ( "Illegal comparison operator: {0}" . format ( op ) ) if len ( list ( set ( actual_tokens ) ) ) != len ( actual_tokens ) : raise RuntimeError ( "Multiple comparison operators of the same type" ) if "!=" in actual_tokens : return ( " and " . join ( [ op_to_words ( token ) for token in tokens [ : - 1 ] ] ) + " " + op_to_words ( tokens [ - 1 ] ) ) return " and " . join ( [ op_to_words ( token ) for token in tokens ] )
Translate requirement specification to words.
Translate requirement specification to words .