]> gitweb.michael.orlitzky.com - dead/pictar.git/blob - Mime/SupportedType.py
Initial commit.
[dead/pictar.git] / Mime / SupportedType.py
1
2 """
3 Wrapper class for the 'filetype' elements in the config file. Nothing
4 tricky here, except that the accessor for the template should
5 intelligently determine which of the two fields (template_file,
6 template_data) is used as the template source.
7 """
8
9 class SupportedType:
10
11 def __init__(self,
12 name = "",
13 description = "",
14 extensions = [],
15 template_file = "",
16 template_data = ""):
17
18 self.__name = name
19 self.__description = description
20 self.__extensions = extensions
21 self.__template_file = template_file
22 self.__template_data = template_data
23
24 return
25
26
27
28 def GetName(self):
29 return self.__name
30
31
32 def GetDescription(self):
33 return self.__description
34
35
36 def GetExtensions(self):
37 return self.__extensions
38
39
40 def GetTemplate(self):
41 if (self.__template_data == None or self.__template_data == ""):
42 # The data is not given explicitly, so rely on the
43 # template file to provide it.
44 template_file = open(self.__template_file, "r")
45 template = template_file.read()
46 template_file.close()
47 return template
48 else:
49 return self.__template_data
50
51
52
53 def SetName(self, name):
54 self.__name = name
55 return
56
57
58 def SetDescription(self, description):
59 self.__description = description
60 return
61
62
63 def SetExtensions(self, extensions):
64 self.__extensions = extensions
65 return
66
67
68 def SetTemplateData(self, template_data):
69 self.__template_data = template_data
70 return
71
72
73 def SetTemplateFile(self, template_file):
74 self.__template_file = template_file
75 return
76