2370
|
1 import string
|
|
2 import re
|
|
3 import os
|
|
4 import types
|
|
5
|
|
6 infile=open("xemacs.tmpl","r")
|
|
7
|
|
8 import version
|
|
9 import dirs
|
|
10 import filelist
|
|
11 import packages
|
|
12
|
|
13 def letter(package):
|
|
14 index = packages.all.index(package)
|
|
15 if index>29:
|
|
16 raise "WISE error: too many components"
|
|
17 return chr(ord("A")+index)
|
|
18
|
|
19 def letters(package_list):
|
|
20 ret = ""
|
|
21 for p in package_list:
|
|
22 ret = ret+letter(p)
|
|
23 return ret
|
|
24
|
|
25 def describe(package):
|
|
26 if package in packages.descriptions.keys():
|
|
27 return ": "+packages.descriptions[package]
|
|
28 else: return ""
|
|
29
|
|
30 def ifblock(var,val):
|
|
31 return("item: If/While Statement\n Variable=%s\n Value=%s\n Flags=00001010\nend\n" % (var,val))
|
|
32
|
|
33 def endblock():
|
|
34 return("item: End Block\nend\n")
|
|
35
|
|
36 def setvar(var,val):
|
|
37 return("item: Set Variable\n Variable=%s\n Value=%s\n Flags=10000000\nend\n" % (string.upper(var), val))
|
|
38
|
|
39 def default_letters_of_category(cat):
|
|
40 val = ""
|
|
41 for p in packages.default:
|
|
42 if packages.category_of_package(p) == cat:
|
|
43 val = val + packages.letter_of_package(p)
|
|
44 return val
|
|
45
|
|
46 def set_category_defaults():
|
|
47 ret = ""
|
|
48 for c in packages.category_names:
|
|
49 ret = ret + setvar(c, default_letters_of_category(c))
|
|
50 return ret
|
|
51
|
|
52 def do_category(cat):
|
|
53 ret = ifblock("COMPONENTS", packages.letter_of_category(cat))
|
|
54 for pkg in packages.packages_of_category(cat):
|
|
55 ret = ret + ifblock(string.upper(cat),packages.letter_of_package(pkg))
|
|
56 for f in files_of_package(pkg):
|
|
57 ret = ret+install_pkg_file(f)
|
|
58 ret = ret + endblock()
|
|
59 ret = ret + endblock()
|
|
60 return ret
|
|
61
|
|
62 def files_of_package(package):
|
|
63 manifest_file = dirs.packages + "\\pkginfo\\MANIFEST." + package
|
|
64 manifest = open(manifest_file,"r")
|
|
65 lines = manifest.readlines()
|
|
66 lines = map(lambda s:s[:-1], lines)
|
|
67 lines = map(lambda s:string.replace(s,'/','\\'), lines)
|
|
68 return lines
|
|
69
|
|
70 def category_dialog(cat):
|
|
71 npkg = len(packages.packages_of_category(cat))
|
|
72 ret=""
|
|
73 ret=ret+" item: Dialog\n Title="+packages.category_descriptions[cat]+" Packages\n"
|
|
74 ret=ret+" Width=210\n"
|
|
75 ret=ret+" Height=%d\n" % (45+npkg*10)
|
|
76 ret=ret+" Font Name=Helv\n"
|
|
77 ret=ret+" Font Size=8\n"
|
|
78 ret=ret+" item: Push Button\n"
|
|
79 ret=ret+" Rectangle=107 %d 147 %d\n" % (5+npkg*10+2, 5+npkg*10+17)
|
|
80 ret=ret+" Create Flags=01010000000000010000000000000001\n"
|
|
81 ret=ret+" Text=OK\n"
|
|
82 ret=ret+" end\n"
|
|
83 ret=ret+" item: Push Button\n"
|
|
84 ret=ret+" Rectangle=153 %d 193 %d\n" % (5+npkg*10+2, 5+npkg*10+17)
|
|
85 ret=ret+" Variable=%s\n" % string.upper(cat)
|
|
86 ret=ret+" Value=%%%s_SAVE%%\n" % string.upper(cat)
|
|
87 ret=ret+" Create Flags=01010000000000010000000000000000\n"
|
|
88 ret=ret+" Flags=0000000000000001\n"
|
|
89 ret=ret+" Text=Cancel\n"
|
|
90 ret=ret+" end\n"
|
|
91 ret=ret+" item: Checkbox\n"
|
|
92 ret=ret+" Rectangle=0 5 191 %d\n" % (10*npkg)
|
|
93 ret=ret+" Variable=%s\n"%string.upper(cat)
|
|
94 ret=ret+" Create Flags=01010000000000010000000000000011\n"
|
|
95 ret=ret+" Flags=0000000000000010\n"
|
|
96 for pkg in packages.packages_of_category(cat):
|
|
97 ret = ret+" Text=%s: %s\n"%( pkg, packages.package_descriptions[pkg])
|
|
98 ret=ret+" Text=\n"
|
|
99 ret=ret+" end\n"
|
|
100 ret=ret+" end\n"
|
|
101 return ret
|
|
102
|
|
103 def src_path(src,name):
|
|
104 return src + "\\" + name
|
|
105
|
|
106 def dst_path(dst,name):
|
|
107 return "%MAINDIR%"+"\\"+dst+"\\" + name
|
|
108
|
|
109 def install_file(name,src,dst):
|
|
110 return("item: Install File\n Source=%s\n Destination=%s\n Flags=0000000010000010\nend\n" % (src_path(src,name),dst_path(dst,name)))
|
|
111
|
|
112 def install_pkg_file(name):
|
|
113 return install_file(name,dirs.packages,dirs.pkg_dst)
|
|
114
|
|
115 def do_package(package):
|
|
116 return ifblock("COMPONENTS",letter(package)) + \
|
|
117 string.join(map(install_pkg_file,files(package)),"")+ \
|
|
118 endblock()
|
|
119
|
|
120 for line in infile.readlines():
|
|
121 left=string.find(line,"<<<")
|
|
122 if left>=0:
|
|
123 right=string.find(line,">>>")
|
|
124 expr=line[left+3:right]
|
|
125 val=eval(expr)
|
|
126 if type(val)==types.StringType:
|
|
127 print line[:left] + val + line[right+3:],
|
|
128 elif type(val)==types.ListType:
|
|
129 for v in val:
|
|
130 print line[:left] + v + line[right+3:],
|
|
131 else: print line,
|
|
132
|
|
133
|