add new files as task files
[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   @Nullable
15   @Override
16   public String getDefaultTaskFileExtension() {
17     return "py";
18   }
19
20   @Nullable
21   @Override
22   public FileTemplate getTaskFileTemplateForExtension(@NotNull final Project project, String extension) {
23     if (!extension.equals("py")) {
24       return null;
25     }
26     return getInternalTemplateByName(project, "task.py");
27   }
28
29   @Nullable
30   @Override
31   public FileTemplate getTestsTemplate(@NotNull final Project project) {
32     return getInternalTemplateByName(project, EduNames.TESTS_FILE);
33   }
34
35   @Override
36   public boolean doNotPackFile(File pathname) {
37     String name = pathname.getName();
38     return name.contains("__pycache__") || name.contains(".pyc");
39   }
40
41   private static FileTemplate getInternalTemplateByName(@NotNull final Project project, String name) {
42     return FileTemplateManager.getInstance(project).getInternalTemplate(name);
43   }
44
45   @Override
46   public boolean isTestFile(VirtualFile file) {
47     return EduNames.TESTS_FILE.equals(file.getName());
48   }
49 }