moved everything python dependent to language part of plugin
[idea/community.git] / python / edu / course-creator-python / src / com / jetbrains / edu / coursecreator / PyStudyLanguageManager.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 org.jetbrains.annotations.NotNull;
7 import org.jetbrains.annotations.Nullable;
8
9 import java.io.File;
10
11 public class PyStudyLanguageManager implements StudyLanguageManager {
12   @Nullable
13   @Override
14   public String getDefaultTaskFileExtension() {
15     return "py";
16   }
17
18   @Nullable
19   @Override
20   public FileTemplate getTaskFileTemplateForExtension(@NotNull final Project project, String extension) {
21     if (!extension.equals("py")) {
22       return null;
23     }
24     return getInternalTemplateByName(project, "task.answer.py");
25   }
26
27   @Nullable
28   @Override
29   public FileTemplate getTestsTemplate(@NotNull final Project project) {
30     return getInternalTemplateByName(project, "tests.py");
31   }
32
33   @Override
34   public boolean packFile(File pathname) {
35     String name = pathname.getName();
36     return !name.contains("__pycache__") && !name.contains(".pyc");
37   }
38
39   @Override
40   public String[] getAdditionalFilesToPack() {
41     return new String[]{"test_helper.py"};
42   }
43
44   private static FileTemplate getInternalTemplateByName(@NotNull final Project project, String name) {
45     return FileTemplateManager.getInstance(project).getInternalTemplate(name);
46   }
47 }