Esempio n. 1
0
def test_includes_dir(python_namespace, expected):
    assert expected == convert_py_namespace_to_includes_dir(python_namespace)
Esempio n. 2
0
if len(python_sub_dir_parts) > 2:
    for i in range(1, len(python_sub_dir_parts) - 1):
        package_dirname = os.path.join('python',
                                       *python_sub_dir_parts[0:i + 1])
        if not os.path.exists(package_dirname):
            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))
Esempio n. 3
0
stack_name = '{{ cookiecutter.stack_name }}'
python_namespace = '{{ cookiecutter.python_module }}'
python_sub_dirs = '{{ cookiecutter.python_sub_dirs }}'
uses_cpp = True if ('{{ cookiecutter.uses_cpp }}' is True
                    or '{{ cookiecutter.uses_cpp }}' == 'True') else False
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))