def create_nested_marker(name, constraint):
    if constraint.is_any():
        return ''
    if isinstance(constraint, (MultiConstraint, UnionConstraint)):
        parts = []
        for c in constraint.constraints:
            multi = False
            if isinstance(c, (MultiConstraint, UnionConstraint)):
                multi = True
            parts.append((multi, create_nested_marker(name, c)))
        glue = ' and '
        if isinstance(constraint, UnionConstraint):
            parts = [('({})'.format(part[1]) if part[0] else part[1]) for part in parts]
            glue = ' or '
        else:
            parts = [part[1] for part in parts]
        marker = glue.join(parts)
    elif isinstance(constraint, Constraint):
        marker = '{} {} "{}"'.format(name, constraint.operator, constraint.version)
    elif isinstance(constraint, VersionUnion):
        parts = []
        for c in constraint.ranges:
            parts.append(create_nested_marker(name, c))
        glue = ' or '
        parts = ['({})'.format(part) for part in parts]
        marker = glue.join(parts)
    elif isinstance(constraint, Version):
        marker = '{} == "{}"'.format(name, constraint.text)
    else:
        if (constraint.min is not None):
            op = '>='
            if (not constraint.include_min):
                op = '>'
            version = constraint.min.text
            if (constraint.max is not None):
                text = '{} {} "{}"'.format(name, op, version)
                op = '<='
                if (not constraint.include_max):
                    op = '<'
                version = constraint.max
                text += ' and {} {} "{}"'.format(name, op, version)
                return text
        elif (constraint.max is not None):
            op = '<='
            if (not constraint.include_max):
                op = '<'
            version = constraint.max
        else:
            return ''
        marker = '{} {} "{}"'.format(name, op, version)
    return marker
def create_nested_marker(name, constraint):
    if constraint.is_any():
        return 
    if isinstance(constraint, (MultiConstraint, UnionConstraint)):
        parts = []
        for c in constraint.constraints:
            multi = False
            if isinstance(c, (MultiConstraint, UnionConstraint)):
                multi = True
            parts.append((multi, create_nested_marker(name, c)))
        glue = ' and '
        if isinstance(constraint, UnionConstraint):
            parts = [('({})'.format(part[1]) if part[0] else part[1]) for part in parts]
            glue = ' or '
        else:
            parts = [part[1] for part in parts]
        marker = glue.join(parts)
    elif isinstance(constraint, Constraint):
        marker = '{} {} "{}"'.format(name, constraint.operator, constraint.version)
    elif isinstance(constraint, VersionUnion):
        parts = []
        for c in constraint.ranges:
            parts.append(create_nested_marker(name, c))
        glue = ' or '
        parts = ['({})'.format(part) for part in parts]
        marker = glue.join(parts)
    elif isinstance(constraint, Version):
        marker = '{} == "{}"'.format(name, constraint.text)
    else:
        if (constraint.min is not None):
            op = '>='
            if (not constraint.include_min):
                op = '>'
            version = constraint.min.text
            if (constraint.max is not None):
                text = '{} {} "{}"'.format(name, op, version)
                op = '<='
                if (not constraint.include_max):
                    op = '<'
                version = constraint.max
                text += ' and {} {} "{}"'.format(name, op, version)
                return text
        elif (constraint.max is not None):
            op = '<='
            if (not constraint.include_max):
                op = '<'
            version = constraint.max
        else:
            return 
        marker = '{} {} "{}"'.format(name, op, version)
    return marker