<commit_before>#!/usr/bin/env python
import errno
import os
import shutil
import subprocess
from typing import List, Tuple


def cleanup():
    cwd = os.getcwd()
    print('cleanup paths in %s' % cwd)

    cleanup_paths = []
    rename_paths: List[Tuple[str, str]] = []  # Tuples of old -> new path
    symlinks = []

    dockerfiles = [
        'Dockerfile-django',
        'Dockerfile-django.production',
        'Dockerfile-node',
        'Dockerfile-node.production',
        'Dockerfile-poetry',
    ]

    if '{{ cookiecutter.docker_base_image }}' == 'alpine':
        cleanup_paths += [
            f'{dockerfile}.debian'
            for dockerfile in dockerfiles
        ]
    elif '{{ cookiecutter.docker_base_image }}' == 'debian':
        rename_paths += [
            (f'{dockerfile}.debian', dockerfile)
            for dockerfile in dockerfiles
        ]

    if '{{ cookiecutter.include_celery}}' == 'no':
        cleanup_paths += [
            '{{ cookiecutter.repo_name }}/{{ cookiecutter.repo_name }}/celery.py',
            '{{ cookiecutter.repo_name }}/{{ cookiecutter.repo_name }}/celery_settings.py',
            '{{ cookiecutter.repo_name }}/{{ cookiecutter.repo_name }}/tasks.py',
        ]

    if '{{ cookiecutter.frontend_style }}' == 'webapp':
        cleanup_paths += [
            'app',
            'Dockerfile-node.production',
            '{{cookiecutter.repo_name}}/accounts/api_urls.py',
            '{{cookiecutter.repo_name}}/accounts/jwt',
            '{{cookiecutter.repo_name}}/accounts/rest',
            '{{cookiecutter.repo_name}}/templates/emails/base.txt',
            '{{cookiecutter.repo_name}}/templates/emails/password_reset.txt',
            '{{cookiecutter.repo_name}}/{{cookiecutter.repo_name}}/rest/',
            '{{cookiecutter.repo_name}}/static/502.html',
            '{{cookiecutter.repo_name}}/static/robots.txt',
            'ansible/roles/deploy/templates/razzle.env',
            'ansible/roles/deploy/templates/nginx/conf.d/common.node.include',
            'ansible/roles/deploy/templates/nginx/conf.d/app.proxy_node.include',
            'deploy/nginx/app.{{cookiecutter.repo_name}}.proxy_node.include',
            'deploy/nginx/common.{{cookiecutter.repo_name}}.node.include',
        ]
    elif '{{ cookiecutter.frontend_style }}' == 'spa':
        cleanup_paths += [
            'webapp',
            '{{cookiecutter.repo_name}}/accounts/emails.py',
            '{{cookiecutter.repo_name}}/accounts/forms.py',
            '{{cookiecutter.repo_name}}/accounts/urls.py',
            '{{cookiecutter.repo_name}}/accounts/views.py',
            '{{cookiecutter.repo_name}}/templates/accounts/',
            '{{cookiecutter.repo_name}}/templates/base.html',
            '{{cookiecutter.repo_name}}/templates/home.html',
            '{{cookiecutter.repo_name}}/templates/registration/',
        ]

    if '{{ cookiecutter.webapp_include_storybook }}' == 'no':
        cleanup_paths += [
            'webapp/webapp/src/.storybook',
            'webapp/webapp/src/storyshots.test.js',
            'webapp/webapp/src/components/Counter/Counter.stories.js',
            'webapp/webapp/src/components/HelloWorld/HelloWorld.stories.js',
            'webapp/webapp/src/components/NavigationBar/NavigationBar.stories.js',
        ]

    if '{{ cookiecutter.thorgate }}' == 'no':
        cleanup_paths += ['utils/terraform', 'tg-repository.yml']
    else:
        cleanup_paths += [
            'ansible/roles/deploy/tasks/nginx_shared.yml',
            'ansible/roles/deploy/tasks/files/nginx-shared',
        ]

    for old_path, new_path in rename_paths:
        old_full_path = os.path.join(cwd, old_path)
        new_full_path = os.path.join(cwd, new_path)

        os.rename(old_full_path, new_full_path)

    for path in cleanup_paths:
        full_path = os.path.join(cwd, path)

        if not os.path.exists(full_path):
            res = 'NO FILE'
        else:
            if os.path.isdir(full_path):
                fn = shutil.rmtree
            else:
                fn = os.remove

            try:
                fn(full_path)<commit_msg>Rename tg-repository.yml to tg-project.yaml in hooks<commit_after>#!/usr/bin/env python
import errno
import os
import shutil
import subprocess
from typing import List, Tuple


def cleanup():
    cwd = os.getcwd()
    print('cleanup paths in %s' % cwd)

    cleanup_paths = []
    rename_paths: List[Tuple[str, str]] = []  # Tuples of old -> new path
    symlinks = []

    dockerfiles = [
        'Dockerfile-django',
        'Dockerfile-django.production',
        'Dockerfile-node',
        'Dockerfile-node.production',
        'Dockerfile-poetry',
    ]

    if '{{ cookiecutter.docker_base_image }}' == 'alpine':
        cleanup_paths += [
            f'{dockerfile}.debian'
            for dockerfile in dockerfiles
        ]
    elif '{{ cookiecutter.docker_base_image }}' == 'debian':
        rename_paths += [
            (f'{dockerfile}.debian', dockerfile)
            for dockerfile in dockerfiles
        ]

    if '{{ cookiecutter.include_celery}}' == 'no':
        cleanup_paths += [
            '{{ cookiecutter.repo_name }}/{{ cookiecutter.repo_name }}/celery.py',
            '{{ cookiecutter.repo_name }}/{{ cookiecutter.repo_name }}/celery_settings.py',
            '{{ cookiecutter.repo_name }}/{{ cookiecutter.repo_name }}/tasks.py',
        ]

    if '{{ cookiecutter.frontend_style }}' == 'webapp':
        cleanup_paths += [
            'app',
            'Dockerfile-node.production',
            '{{cookiecutter.repo_name}}/accounts/api_urls.py',
            '{{cookiecutter.repo_name}}/accounts/jwt',
            '{{cookiecutter.repo_name}}/accounts/rest',
            '{{cookiecutter.repo_name}}/templates/emails/base.txt',
            '{{cookiecutter.repo_name}}/templates/emails/password_reset.txt',
            '{{cookiecutter.repo_name}}/{{cookiecutter.repo_name}}/rest/',
            '{{cookiecutter.repo_name}}/static/502.html',
            '{{cookiecutter.repo_name}}/static/robots.txt',
            'ansible/roles/deploy/templates/razzle.env',
            'ansible/roles/deploy/templates/nginx/conf.d/common.node.include',
            'ansible/roles/deploy/templates/nginx/conf.d/app.proxy_node.include',
            'deploy/nginx/app.{{cookiecutter.repo_name}}.proxy_node.include',
            'deploy/nginx/common.{{cookiecutter.repo_name}}.node.include',
        ]
    elif '{{ cookiecutter.frontend_style }}' == 'spa':
        cleanup_paths += [
            'webapp',
            '{{cookiecutter.repo_name}}/accounts/emails.py',
            '{{cookiecutter.repo_name}}/accounts/forms.py',
            '{{cookiecutter.repo_name}}/accounts/urls.py',
            '{{cookiecutter.repo_name}}/accounts/views.py',
            '{{cookiecutter.repo_name}}/templates/accounts/',
            '{{cookiecutter.repo_name}}/templates/base.html',
            '{{cookiecutter.repo_name}}/templates/home.html',
            '{{cookiecutter.repo_name}}/templates/registration/',
        ]

    if '{{ cookiecutter.webapp_include_storybook }}' == 'no':
        cleanup_paths += [
            'webapp/webapp/src/.storybook',
            'webapp/webapp/src/storyshots.test.js',
            'webapp/webapp/src/components/Counter/Counter.stories.js',
            'webapp/webapp/src/components/HelloWorld/HelloWorld.stories.js',
            'webapp/webapp/src/components/NavigationBar/NavigationBar.stories.js',
        ]

    if '{{ cookiecutter.thorgate }}' == 'no':
        cleanup_paths += ['utils/terraform', 'tg-project.yaml']
    else:
        cleanup_paths += [
            'ansible/roles/deploy/tasks/nginx_shared.yml',
            'ansible/roles/deploy/tasks/files/nginx-shared',
        ]

    for old_path, new_path in rename_paths:
        old_full_path = os.path.join(cwd, old_path)
        new_full_path = os.path.join(cwd, new_path)

        os.rename(old_full_path, new_full_path)

    for path in cleanup_paths:
        full_path = os.path.join(cwd, path)

        if not os.path.exists(full_path):
            res = 'NO FILE'
        else:
            if os.path.isdir(full_path):
                fn = shutil.rmtree
            else:
                fn = os.remove

            try:
                fn(full_path)
{'fraction_non_alphanumeric': 0.14823785878648418, 'fraction_numerical': 0.0007266561705219813, 'mean_word_length': 2.256309148264984, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '740606', 'n_tokens_mistral': 2729, 'n_tokens_neox': 2607, 'n_words': 322}