add subtasks to placeholder inner representation
[idea/community.git] / python / educational-python / course-creator-python / src / com / jetbrains / edu / coursecreator / PyCCLanguageManager.java
1 package com.jetbrains.edu.coursecreator;
2
3 import com.intellij.ide.fileTemplates.FileTemplate;
4 import com.intellij.ide.fileTemplates.FileTemplateManager;
5 import com.intellij.openapi.project.Project;
6 import com.intellij.openapi.vfs.VirtualFile;
7 import com.jetbrains.edu.learning.core.EduNames;
8 import org.jetbrains.annotations.NotNull;
9 import org.jetbrains.annotations.Nullable;
10
11 import java.io.File;
12
13 public class PyCCLanguageManager implements CCLanguageManager {
14
15   @Nullable
16   @Override
17   public String getDefaultTaskFileExtension() {
18     return "py";
19   }
20
21   @Nullable
22   @Override
23   public FileTemplate getTaskFileTemplateForExtension(@NotNull final Project project, String extension) {
24     if (!extension.equals("py")) {
25       return null;
26     }
27     return getInternalTemplateByName(project, "task.py");
28   }
29
30   @Nullable
31   @Override
32   public FileTemplate getTestsTemplate(@NotNull final Project project) {
33     return getInternalTemplateByName(project, EduNames.TESTS_FILE);
34   }
35
36   @Override
37   public boolean doNotPackFile(File pathname) {
38     String name = pathname.getName();
39     return name.contains("__pycache__") || name.contains(".pyc");
40   }
41
42   private static FileTemplate getInternalTemplateByName(@NotNull final Project project, String name) {
43     return FileTemplateManager.getInstance(project).getInternalTemplate(name);
44   }
45
46   @Override
47   public boolean isTestFile(VirtualFile file) {
48     return EduNames.TESTS_FILE.equals(file.getName());
49   }
50 }