Conditions | 6 |
Total Lines | 22 |
Code Lines | 13 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | # -*- coding: utf-8 -*- |
||
13 | def find_template(repo_dir): |
||
14 | """Determine which child directory of `repo_dir` is the project template. |
||
15 | |||
16 | :param repo_dir: Local directory of newly cloned repo. |
||
17 | :returns project_template: Relative path to project template. |
||
18 | """ |
||
19 | logger.debug('Searching %s for the project template.', repo_dir) |
||
20 | |||
21 | repo_dir_contents = os.listdir(repo_dir) |
||
22 | |||
23 | project_template = None |
||
24 | for item in repo_dir_contents: |
||
25 | if 'cookiecutter' in item and '{{' in item and '}}' in item: |
||
26 | project_template = item |
||
27 | break |
||
28 | |||
29 | if project_template: |
||
30 | project_template = os.path.join(repo_dir, project_template) |
||
31 | logger.debug('The project template appears to be %s', project_template) |
||
32 | return project_template |
||
33 | else: |
||
34 | raise NonTemplatedInputDirException |
||
35 |