def dedent(content):
    content = force_text(content)
    whitespace_counts = [len(line) - len(line.lstrip(' '))
                         for line in content.splitlines()[1:] if line.lstrip()]

    # unindent the content if needed
    if whitespace_counts:
        whitespace_pattern = '^' + (' ' * min(whitespace_counts))
        content = re.sub(re.compile(whitespace_pattern, re.MULTILINE), '', content)

    return content.strip()
Explicitly cleanup caches based on their priority (if required).
dataset/ETHPy150Open tomchristie/django-rest-framework/rest_framework/utils/formatting.py/dedent--crossover with--dataset/ETHPy150Open openstack/ironic/ironic/drivers/modules/image_cache.py/clean_up_caches