/usr/lib/python3/dist-packages/cookiecutter/cleanup.py is in python3-cookiecutter 0.6.4-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
cookiecutter.cleanup
--------------------
Functions for cleaning up after Cookiecutter project generation occurs.
"""
from __future__ import unicode_literals
import logging
import os
import shutil
from .exceptions import MissingProjectDir
def remove_repo(repo_dir, generated_project):
"""
Move the generated project to the same level as `repo_dir`, then delete
`repo_dir`.
Called when Cookiecutter receives a repo as an argument instead of a
project template directory.
:param repo_dir: Local directory of the cloned repo.
:param generated_project: Name of project that Cookiecutter just
generated. All lowercase, no spaces or funny characters.
:returns: True if successful, else False.
"""
logging.debug('Moving {0} out of {1} and removing {1}'.format(generated_project, repo_dir))
parent_dir = os.path.dirname(os.path.abspath(repo_dir))
logging.debug('parent_dir is {0}'.format(parent_dir))
project_dir = os.path.join(repo_dir, generated_project)
logging.debug('project_dir is {0}'.format(project_dir))
if os.path.exists(project_dir):
shutil.move(project_dir, parent_dir)
shutil.rmtree(repo_dir)
return True
else:
raise MissingProjectDir(
'The project did not get generated. Please file an issue in '
'Cookiecutter with as much detail as possible about what happened.'
)
|