Example #1
0
def test_header_name(python_namespace, expected):
    assert expected == convert_py_namespace_to_header_filename(
        python_namespace)  # noqa E501
Example #2
0
            os.makedirs(package_dirname)
        init_path = os.path.join(package_dirname, '__init__.py')
        shutil.copy(root_init_path, init_path)
        print('(post-gen hook) Copied {0} to {1}'.format(
            root_init_path, init_path))

# Move include/root.h to a directory and name based on the namespace.
initial_header_path = os.path.join('include', 'root.h')
if os.path.exists(initial_header_path):
    new_include_dir = os.path.join(
        'include', convert_py_namespace_to_includes_dir(python_namespace))
    if not os.path.exists(new_include_dir):
        os.makedirs(new_include_dir)
    new_header_filename = os.path.join(
        new_include_dir,
        convert_py_namespace_to_header_filename(python_namespace))
    if os.path.exists(new_header_filename):
        os.remove(new_header_filename)
    shutil.move(initial_header_path, new_header_filename)
    print('(post-gen hook) Moved root.h to {}'.format(new_header_filename))

# Remove C++ directories if cookiecutter.uses_cpp is False
if not uses_cpp:
    cpp_dirnames = ('lib', 'src', 'include')
    for dirname in cpp_dirnames:
        print('(post-gen hook) Removing {0} directory'.format(dirname))
        shutil.rmtree(dirname, ignore_errors=True)

# Remove Python-specific directories and files if cookiecutter.uses_python
# is False
if not uses_python:
Example #3
0
uses_python = True if ('{{ cookiecutter.uses_python }}' is True
                       or '{{ cookiecutter.uses_python }}' == 'True') else False  # noqa: E501

python_sub_dir_parts = python_sub_dirs.split('/')

# Move include/root.h to a directory and name based on the namespace.
initial_header_path = os.path.join('include', 'root.h')
if os.path.exists(initial_header_path):
    new_include_dir = os.path.join(
        'include',
        convert_py_namespace_to_includes_dir(python_namespace))
    if not os.path.exists(new_include_dir):
        os.makedirs(new_include_dir)
    new_header_filename = os.path.join(
        new_include_dir,
        convert_py_namespace_to_header_filename(python_namespace))
    if os.path.exists(new_header_filename):
        os.remove(new_header_filename)
    shutil.move(initial_header_path, new_header_filename)
    print('(post-gen hook) Moved root.h to {}'.format(new_header_filename))

if not uses_cpp:
    # Remove C++ directories if cookiecutter.uses_cpp is False
    cpp_dirnames = ('lib', 'src', 'include')
    for dirname in cpp_dirnames:
        print('(post-gen hook) Removing {0} directory'.format(dirname))
        shutil.rmtree(dirname, ignore_errors=True)

    # Remove C++ -related documentation files
    doc_files = [os.path.join('doc', n)
                 for n in ('SConscript', 'doxygen.conf.in')]