Mercurial > forge
annotate www/build-www.py @ 2668:67c5fe4fd3f0 octave-forge
Use alphabetic contents of package rather than categories page that might include functions from octaev itself
author | adb014 |
---|---|
date | Thu, 12 Oct 2006 20:27:30 +0000 |
parents | 4ea46b848cf2 |
children | 3f938458f716 |
rev | line source |
---|---|
2429
768fc6540e8a
Added a basic script for creating webpages from DESCRIPTION files
hauberg
parents:
diff
changeset
|
1 #!/usr/bin/env python |
768fc6540e8a
Added a basic script for creating webpages from DESCRIPTION files
hauberg
parents:
diff
changeset
|
2 |
2513 | 3 import sys |
2429
768fc6540e8a
Added a basic script for creating webpages from DESCRIPTION files
hauberg
parents:
diff
changeset
|
4 import os |
2513 | 5 import shutil |
2651
4ea46b848cf2
No longer have global OCTAVE_PACKAGE_PREFIX. Use the 'prefix' directive to pkg to replae it
adb014
parents:
2646
diff
changeset
|
6 import time |
2429
768fc6540e8a
Added a basic script for creating webpages from DESCRIPTION files
hauberg
parents:
diff
changeset
|
7 |
768fc6540e8a
Added a basic script for creating webpages from DESCRIPTION files
hauberg
parents:
diff
changeset
|
8 ## This function parses a DESCRIPTION file |
768fc6540e8a
Added a basic script for creating webpages from DESCRIPTION files
hauberg
parents:
diff
changeset
|
9 def parse_description(filename): |
768fc6540e8a
Added a basic script for creating webpages from DESCRIPTION files
hauberg
parents:
diff
changeset
|
10 try: |
768fc6540e8a
Added a basic script for creating webpages from DESCRIPTION files
hauberg
parents:
diff
changeset
|
11 fid = open(filename, 'r'); |
768fc6540e8a
Added a basic script for creating webpages from DESCRIPTION files
hauberg
parents:
diff
changeset
|
12 keyword = ""; |
768fc6540e8a
Added a basic script for creating webpages from DESCRIPTION files
hauberg
parents:
diff
changeset
|
13 desc = {}; |
768fc6540e8a
Added a basic script for creating webpages from DESCRIPTION files
hauberg
parents:
diff
changeset
|
14 line = fid.readline(); |
768fc6540e8a
Added a basic script for creating webpages from DESCRIPTION files
hauberg
parents:
diff
changeset
|
15 while (line != ""): |
768fc6540e8a
Added a basic script for creating webpages from DESCRIPTION files
hauberg
parents:
diff
changeset
|
16 ## Comments |
768fc6540e8a
Added a basic script for creating webpages from DESCRIPTION files
hauberg
parents:
diff
changeset
|
17 if (line[0] == "#"): |
768fc6540e8a
Added a basic script for creating webpages from DESCRIPTION files
hauberg
parents:
diff
changeset
|
18 # Do nothing |
768fc6540e8a
Added a basic script for creating webpages from DESCRIPTION files
hauberg
parents:
diff
changeset
|
19 print("Skip"); |
768fc6540e8a
Added a basic script for creating webpages from DESCRIPTION files
hauberg
parents:
diff
changeset
|
20 ## Continuation lines |
768fc6540e8a
Added a basic script for creating webpages from DESCRIPTION files
hauberg
parents:
diff
changeset
|
21 elif (line[0].isspace()): |
768fc6540e8a
Added a basic script for creating webpages from DESCRIPTION files
hauberg
parents:
diff
changeset
|
22 if (keyword != "" & desc.has_key(keyword)): |
768fc6540e8a
Added a basic script for creating webpages from DESCRIPTION files
hauberg
parents:
diff
changeset
|
23 desc[keyword] += line; |
768fc6540e8a
Added a basic script for creating webpages from DESCRIPTION files
hauberg
parents:
diff
changeset
|
24 ## Keyword/value pair |
768fc6540e8a
Added a basic script for creating webpages from DESCRIPTION files
hauberg
parents:
diff
changeset
|
25 else: |
768fc6540e8a
Added a basic script for creating webpages from DESCRIPTION files
hauberg
parents:
diff
changeset
|
26 colon = line.find(":"); |
768fc6540e8a
Added a basic script for creating webpages from DESCRIPTION files
hauberg
parents:
diff
changeset
|
27 if (colon == -1): |
768fc6540e8a
Added a basic script for creating webpages from DESCRIPTION files
hauberg
parents:
diff
changeset
|
28 print "Skipping line"; |
768fc6540e8a
Added a basic script for creating webpages from DESCRIPTION files
hauberg
parents:
diff
changeset
|
29 else: |
768fc6540e8a
Added a basic script for creating webpages from DESCRIPTION files
hauberg
parents:
diff
changeset
|
30 keyword = line[0:colon].strip().lower(); |
768fc6540e8a
Added a basic script for creating webpages from DESCRIPTION files
hauberg
parents:
diff
changeset
|
31 value = line[colon+1:]; |
768fc6540e8a
Added a basic script for creating webpages from DESCRIPTION files
hauberg
parents:
diff
changeset
|
32 if (len(value) == 0): |
768fc6540e8a
Added a basic script for creating webpages from DESCRIPTION files
hauberg
parents:
diff
changeset
|
33 print("The keyword " + keyword + " has an empty value\n."); |
768fc6540e8a
Added a basic script for creating webpages from DESCRIPTION files
hauberg
parents:
diff
changeset
|
34 fid.close(); |
768fc6540e8a
Added a basic script for creating webpages from DESCRIPTION files
hauberg
parents:
diff
changeset
|
35 return; |
768fc6540e8a
Added a basic script for creating webpages from DESCRIPTION files
hauberg
parents:
diff
changeset
|
36 desc[keyword] = value.strip(); |
768fc6540e8a
Added a basic script for creating webpages from DESCRIPTION files
hauberg
parents:
diff
changeset
|
37 line = fid.readline(); |
768fc6540e8a
Added a basic script for creating webpages from DESCRIPTION files
hauberg
parents:
diff
changeset
|
38 fid.close(); |
768fc6540e8a
Added a basic script for creating webpages from DESCRIPTION files
hauberg
parents:
diff
changeset
|
39 return desc; |
2573 | 40 except Exception, e: |
41 print(e); | |
2429
768fc6540e8a
Added a basic script for creating webpages from DESCRIPTION files
hauberg
parents:
diff
changeset
|
42 print("Couldn't parse the DESCRIPTION file " + filename); |
768fc6540e8a
Added a basic script for creating webpages from DESCRIPTION files
hauberg
parents:
diff
changeset
|
43 raise |
768fc6540e8a
Added a basic script for creating webpages from DESCRIPTION files
hauberg
parents:
diff
changeset
|
44 |
2541
4ff100278d10
Add what will probably be the real path to download the packages. First attempt at adding local documentation if it exists
adb014
parents:
2517
diff
changeset
|
45 def local_documentation(outdir, packdir): |
4ff100278d10
Add what will probably be the real path to download the packages. First attempt at adding local documentation if it exists
adb014
parents:
2517
diff
changeset
|
46 try: |
4ff100278d10
Add what will probably be the real path to download the packages. First attempt at adding local documentation if it exists
adb014
parents:
2517
diff
changeset
|
47 ## Copy any local documentation to packdir/local |
2558 | 48 cmd = 'find ' + packdir + ' -name "[hH][tT][mM][lL]" -type d -print; find ' + packdir + ' -name "[hH][tT][mM]" -type d -print' |
49 docdir = None; | |
2541
4ff100278d10
Add what will probably be the real path to download the packages. First attempt at adding local documentation if it exists
adb014
parents:
2517
diff
changeset
|
50 for file in os.popen(cmd).readlines(): |
2558 | 51 name = file[:-1]; |
52 docdir = 1; | |
2541
4ff100278d10
Add what will probably be the real path to download the packages. First attempt at adding local documentation if it exists
adb014
parents:
2517
diff
changeset
|
53 if (not os.path.exists(outdir + "/local")): |
4ff100278d10
Add what will probably be the real path to download the packages. First attempt at adding local documentation if it exists
adb014
parents:
2517
diff
changeset
|
54 os.mkdir(outdir + "/local"); |
2558 | 55 for root, dirs, files in os.walk(name, topdown=False): |
56 for file2 in files: | |
57 shutil.copy2(root + "/" + file2, outdir + "/local/"); | |
58 | |
59 if (not docdir): | |
60 cmd = 'find ' + packdir + ' -name "*.[hH][tT][mM][lL]" -print; find ' + packdir + ' -name "*.[hH][tT][mM]" -print' | |
61 for file in os.popen(cmd).readlines(): | |
62 if (not os.path.exists(outdir + "/local")): | |
63 os.mkdir(outdir + "/local"); | |
64 name = file[:-1]; | |
65 shutil.copy2(name, outdir + "/local/"); | |
2541
4ff100278d10
Add what will probably be the real path to download the packages. First attempt at adding local documentation if it exists
adb014
parents:
2517
diff
changeset
|
66 |
4ff100278d10
Add what will probably be the real path to download the packages. First attempt at adding local documentation if it exists
adb014
parents:
2517
diff
changeset
|
67 if (os.path.exists(outdir + "/local/index.html")): |
4ff100278d10
Add what will probably be the real path to download the packages. First attempt at adding local documentation if it exists
adb014
parents:
2517
diff
changeset
|
68 return "local/index.html"; |
4ff100278d10
Add what will probably be the real path to download the packages. First attempt at adding local documentation if it exists
adb014
parents:
2517
diff
changeset
|
69 elif (os.path.exists(outdir + "/local/index.htm")): |
4ff100278d10
Add what will probably be the real path to download the packages. First attempt at adding local documentation if it exists
adb014
parents:
2517
diff
changeset
|
70 return "local/index.htm"; |
4ff100278d10
Add what will probably be the real path to download the packages. First attempt at adding local documentation if it exists
adb014
parents:
2517
diff
changeset
|
71 elif (os.path.exists(outdir + "/local")): |
4ff100278d10
Add what will probably be the real path to download the packages. First attempt at adding local documentation if it exists
adb014
parents:
2517
diff
changeset
|
72 ## This could really be improved as it only returns the first |
4ff100278d10
Add what will probably be the real path to download the packages. First attempt at adding local documentation if it exists
adb014
parents:
2517
diff
changeset
|
73 ## html page that find returns. |
2558 | 74 cmd2 = 'cd ' + outdir + '; find local -name "*.[hH][tT][mM][lL]" -print; find local -name "*.[hH][tT][mM]" -print'; |
75 for file in os.popen(cmd2).readlines(): | |
2541
4ff100278d10
Add what will probably be the real path to download the packages. First attempt at adding local documentation if it exists
adb014
parents:
2517
diff
changeset
|
76 name = file[:-1]; |
2558 | 77 return name; |
78 return None; | |
2541
4ff100278d10
Add what will probably be the real path to download the packages. First attempt at adding local documentation if it exists
adb014
parents:
2517
diff
changeset
|
79 else: |
4ff100278d10
Add what will probably be the real path to download the packages. First attempt at adding local documentation if it exists
adb014
parents:
2517
diff
changeset
|
80 return None; |
2573 | 81 except Exception, e: |
82 print(e); | |
2541
4ff100278d10
Add what will probably be the real path to download the packages. First attempt at adding local documentation if it exists
adb014
parents:
2517
diff
changeset
|
83 print("Bad copy " + packdir); |
4ff100278d10
Add what will probably be the real path to download the packages. First attempt at adding local documentation if it exists
adb014
parents:
2517
diff
changeset
|
84 return None; |
4ff100278d10
Add what will probably be the real path to download the packages. First attempt at adding local documentation if it exists
adb014
parents:
2517
diff
changeset
|
85 |
2558 | 86 def create_INDEX(desc, packdir, p): |
2513 | 87 try: |
88 wd = os.getcwd(); | |
2541
4ff100278d10
Add what will probably be the real path to download the packages. First attempt at adding local documentation if it exists
adb014
parents:
2517
diff
changeset
|
89 name_version = desc['name'].lower() + "-" + desc['version']; |
2513 | 90 |
91 ## Create a tarball to be installed | |
92 install_dir = wd + "/install/"; | |
2541
4ff100278d10
Add what will probably be the real path to download the packages. First attempt at adding local documentation if it exists
adb014
parents:
2517
diff
changeset
|
93 tarball = name_version + ".tar.gz"; |
2558 | 94 if (os.system("tar -zcf " + tarball + " -C " + packdir + "/.. " + p) != 0): |
2517
b18fa83aa9c4
Autogenerated INDEX files in build-www are now generated in a sandbox
hauberg
parents:
2515
diff
changeset
|
95 os.system("rm -rf " + tarball); |
2513 | 96 raise Exception("Can't create tarball"); |
97 | |
98 ## Run octave installation | |
2651
4ea46b848cf2
No longer have global OCTAVE_PACKAGE_PREFIX. Use the 'prefix' directive to pkg to replae it
adb014
parents:
2646
diff
changeset
|
99 command = 'pkg("prefix","' + install_dir + '"); '; |
2513 | 100 command = command + 'pkg("install", "-nodeps", "' + tarball + '");'; |
2558 | 101 if (os.system("HOME=" + wd + "; octave -H -q --no-site-file --no-init-file --eval '" + command + "' > /dev/null 2>&1") != 0): |
102 os.system("ls -la " + install_dir); | |
2517
b18fa83aa9c4
Autogenerated INDEX files in build-www are now generated in a sandbox
hauberg
parents:
2515
diff
changeset
|
103 os.system("rm -rf " + install_dir + " " + tarball); |
2513 | 104 raise Exception("Can't run Octave"); |
105 | |
2558 | 106 ## Copy the INDEX file to local INDEX file |
107 index = open(install_dir + name_version + "/packinfo/INDEX", "r"); | |
108 local_index = open("INDEX","a"); | |
109 local_index.writelines(index.readlines()); | |
110 local_index.close(); | |
111 index.close(); | |
2651
4ea46b848cf2
No longer have global OCTAVE_PACKAGE_PREFIX. Use the 'prefix' directive to pkg to replae it
adb014
parents:
2646
diff
changeset
|
112 |
2513 | 113 ## Clean up |
2651
4ea46b848cf2
No longer have global OCTAVE_PACKAGE_PREFIX. Use the 'prefix' directive to pkg to replae it
adb014
parents:
2646
diff
changeset
|
114 command = 'pkg("prefix","' + install_dir + '"); '; |
2558 | 115 command = command + 'pkg("uninstall", "-nodeps", "' + desc['name'].lower() + '");'; |
116 if (os.system("HOME=" + wd + "; octave -H -q --no-site-file --no-init-file --eval '" + command + "' > /dev/null 2>&1") != 0): | |
2517
b18fa83aa9c4
Autogenerated INDEX files in build-www are now generated in a sandbox
hauberg
parents:
2515
diff
changeset
|
117 os.system("rm -rf " + install_dir + " " + tarball); |
2513 | 118 raise Exception("Can't run Octave"); |
119 os.system("rm -rf " + install_dir + " " + tarball); | |
120 except: | |
121 raise; | |
122 | |
2429
768fc6540e8a
Added a basic script for creating webpages from DESCRIPTION files
hauberg
parents:
diff
changeset
|
123 ## Creates the index.html files for a package in packdir. |
768fc6540e8a
Added a basic script for creating webpages from DESCRIPTION files
hauberg
parents:
diff
changeset
|
124 ## The result is placed in outdir. |
2558 | 125 def create_index_html(packdir, outdir, p): |
2429
768fc6540e8a
Added a basic script for creating webpages from DESCRIPTION files
hauberg
parents:
diff
changeset
|
126 try: |
768fc6540e8a
Added a basic script for creating webpages from DESCRIPTION files
hauberg
parents:
diff
changeset
|
127 desc = parse_description(packdir + "/DESCRIPTION"); |
768fc6540e8a
Added a basic script for creating webpages from DESCRIPTION files
hauberg
parents:
diff
changeset
|
128 except: |
768fc6540e8a
Added a basic script for creating webpages from DESCRIPTION files
hauberg
parents:
diff
changeset
|
129 raise; |
2558 | 130 |
2429
768fc6540e8a
Added a basic script for creating webpages from DESCRIPTION files
hauberg
parents:
diff
changeset
|
131 ## Write header |
2461 | 132 fid = open(outdir + "/index.in", "w"); |
2486 | 133 fid.write("__HEADER__([[[The " + desc['name'] + " package]]])"); |
2497 | 134 |
2429
768fc6540e8a
Added a basic script for creating webpages from DESCRIPTION files
hauberg
parents:
diff
changeset
|
135 ## Write important data |
768fc6540e8a
Added a basic script for creating webpages from DESCRIPTION files
hauberg
parents:
diff
changeset
|
136 fid.write(' <table id="main_package_table">\n'); |
768fc6540e8a
Added a basic script for creating webpages from DESCRIPTION files
hauberg
parents:
diff
changeset
|
137 fid.write(' <tr><td>Package Name:</td><td>' + desc["name"] + "</td></tr>\n"); |
768fc6540e8a
Added a basic script for creating webpages from DESCRIPTION files
hauberg
parents:
diff
changeset
|
138 fid.write(' <tr><td>Package Version:</td><td>' + desc["version"] + "</td></tr>\n"); |
768fc6540e8a
Added a basic script for creating webpages from DESCRIPTION files
hauberg
parents:
diff
changeset
|
139 fid.write(' <tr><td>Last Release Date:</td><td>' + desc["date"] + "</td></tr>\n"); |
768fc6540e8a
Added a basic script for creating webpages from DESCRIPTION files
hauberg
parents:
diff
changeset
|
140 fid.write(' <tr><td>Package Author:</td><td>' + desc["author"] + "</td></tr>\n"); |
768fc6540e8a
Added a basic script for creating webpages from DESCRIPTION files
hauberg
parents:
diff
changeset
|
141 fid.write(' <tr><td>Package Maintainer:</td><td>' + desc["maintainer"] + "</td></tr>\n"); |
2497 | 142 fid.write(' <tr><td colspan="2"><img src="../download.png" alt="Download"/>'); |
2651
4ea46b848cf2
No longer have global OCTAVE_PACKAGE_PREFIX. Use the 'prefix' directive to pkg to replae it
adb014
parents:
2646
diff
changeset
|
143 fid.write('<a href="__PACKAGE__/' + desc['name'].lower() + '-' + desc['version'] + '.tar.gz?download">Download this package</a></td></tr>\n'); |
2541
4ff100278d10
Add what will probably be the real path to download the packages. First attempt at adding local documentation if it exists
adb014
parents:
2517
diff
changeset
|
144 fid.write(' <tr><td colspan="2"><img src="../doc.png" alt="Function Reference"/>'); |
2668
67c5fe4fd3f0
Use alphabetic contents of package rather than categories page that might include functions from octaev itself
adb014
parents:
2651
diff
changeset
|
145 fid.write('<a href="../doc/funref_' + desc['name'].lower() + '.html">Read package function reference</a></td></tr>\n'); |
2541
4ff100278d10
Add what will probably be the real path to download the packages. First attempt at adding local documentation if it exists
adb014
parents:
2517
diff
changeset
|
146 local = local_documentation(outdir, packdir); |
4ff100278d10
Add what will probably be the real path to download the packages. First attempt at adding local documentation if it exists
adb014
parents:
2517
diff
changeset
|
147 if (local): |
4ff100278d10
Add what will probably be the real path to download the packages. First attempt at adding local documentation if it exists
adb014
parents:
2517
diff
changeset
|
148 fid.write(' <tr><td colspan="2"><img src="../doc.png" alt="Documentation"/>'); |
4ff100278d10
Add what will probably be the real path to download the packages. First attempt at adding local documentation if it exists
adb014
parents:
2517
diff
changeset
|
149 fid.write('<a href="' + local + '">Documentation</a></td></tr>\n'); |
4ff100278d10
Add what will probably be the real path to download the packages. First attempt at adding local documentation if it exists
adb014
parents:
2517
diff
changeset
|
150 |
2429
768fc6540e8a
Added a basic script for creating webpages from DESCRIPTION files
hauberg
parents:
diff
changeset
|
151 fid.write(" </table>\n"); |
768fc6540e8a
Added a basic script for creating webpages from DESCRIPTION files
hauberg
parents:
diff
changeset
|
152 fid.write(' <div id="description_box">\n'); |
768fc6540e8a
Added a basic script for creating webpages from DESCRIPTION files
hauberg
parents:
diff
changeset
|
153 if (desc.has_key("html-file")): |
768fc6540e8a
Added a basic script for creating webpages from DESCRIPTION files
hauberg
parents:
diff
changeset
|
154 html_fid = open(packdir + "/" + desc["html-file"].strip(), "r"); |
768fc6540e8a
Added a basic script for creating webpages from DESCRIPTION files
hauberg
parents:
diff
changeset
|
155 fid.write(" " + html_fid.read() + "\n"); |
768fc6540e8a
Added a basic script for creating webpages from DESCRIPTION files
hauberg
parents:
diff
changeset
|
156 html_fid.close(); |
768fc6540e8a
Added a basic script for creating webpages from DESCRIPTION files
hauberg
parents:
diff
changeset
|
157 else: |
768fc6540e8a
Added a basic script for creating webpages from DESCRIPTION files
hauberg
parents:
diff
changeset
|
158 fid.write(" " + desc["description"] + "\n"); |
768fc6540e8a
Added a basic script for creating webpages from DESCRIPTION files
hauberg
parents:
diff
changeset
|
159 fid.write(' </div>\n\n'); |
768fc6540e8a
Added a basic script for creating webpages from DESCRIPTION files
hauberg
parents:
diff
changeset
|
160 |
768fc6540e8a
Added a basic script for creating webpages from DESCRIPTION files
hauberg
parents:
diff
changeset
|
161 ## Write less important data |
768fc6540e8a
Added a basic script for creating webpages from DESCRIPTION files
hauberg
parents:
diff
changeset
|
162 keys = desc.keys(); |
2461 | 163 fid.write(" <h3>Other information</h3>\n"); |
164 fid.write(' <table id="extra_package_table">\n'); | |
165 ## License | |
166 fid.write(' <tr><td>License: </td><td><a href="license.html">'); | |
167 if (desc.has_key("license")): | |
168 fid.write(desc['license']); | |
169 else: | |
170 fid.write('details'); | |
171 fid.write('</a></td></tr>\n'); | |
172 ## URL | |
173 if (desc.has_key("url")): | |
174 fid.write(' <tr><td>Web page: </td><td><a href="' + desc['url'] + '">'); | |
175 fid.write(desc['url']); | |
176 fid.write('</a></td></tr>\n'); | |
177 ## Dependencies | |
178 if (desc.has_key("depends")): | |
179 fid.write(' <tr><td>Dependencies: </td><td>'); | |
180 fid.write(desc['depends']); | |
181 fid.write('</td></tr>\n'); | |
182 ## Everything else | |
183 already_shown_keys = ["title", "name", "version", "date", "author", | |
184 "maintainer", "description", "html-file", | |
185 "license", "url", "depends"]; | |
186 for k in keys: | |
187 if (already_shown_keys.count(k) == 0): | |
188 value = desc[k]; | |
189 fid.write(" <tr><td>" + k + ":</td><td>" + value + "</td></tr>\n"); | |
190 fid.write(" </table>\n"); | |
2429
768fc6540e8a
Added a basic script for creating webpages from DESCRIPTION files
hauberg
parents:
diff
changeset
|
191 |
768fc6540e8a
Added a basic script for creating webpages from DESCRIPTION files
hauberg
parents:
diff
changeset
|
192 ## Write footer |
2461 | 193 fid.write("__TRAILER__\n"); |
194 fid.close(); | |
2513 | 195 |
196 ## Check if the package has an INDEX file (if not create one) | |
197 INDEX_file = packdir + "/INDEX"; | |
198 if (not os.path.isfile(INDEX_file)): | |
2558 | 199 create_INDEX(desc, packdir, p); |
2513 | 200 |
2461 | 201 return desc; |
202 | |
203 def create_license_html(package_name, packdir, outdir): | |
204 ## Read License | |
205 filename = packdir + "/COPYING"; | |
206 fid = open(filename, 'r'); | |
207 license = fid.readlines(); | |
2429
768fc6540e8a
Added a basic script for creating webpages from DESCRIPTION files
hauberg
parents:
diff
changeset
|
208 fid.close(); |
768fc6540e8a
Added a basic script for creating webpages from DESCRIPTION files
hauberg
parents:
diff
changeset
|
209 |
2461 | 210 ## Write output |
211 fid = open(outdir + "/license.in", "w"); | |
2486 | 212 fid.write("__HEADER__([[[The " + package_name + " package]]])\n"); |
2461 | 213 fid.write("<h3>The license terms for the " + package_name + " package are as follows</h3>\n"); |
214 fid.write('<p><textarea rows="20" cols="80" readonly>'); | |
215 for c in license: | |
216 fid.write(c) | |
217 fid.write('</textarea></p>\n'); | |
218 fid.write('<p><a href="index.html">Back to the package page</a></p>\n'); | |
219 fid.write("__TRAILER__\n"); | |
220 fid.close(); | |
221 | |
222 | |
2429
768fc6540e8a
Added a basic script for creating webpages from DESCRIPTION files
hauberg
parents:
diff
changeset
|
223 def rm_rf(p): |
2461 | 224 #print("Deleting " + p); |
2463 | 225 if (p == "./CVS"): |
226 return; | |
2429
768fc6540e8a
Added a basic script for creating webpages from DESCRIPTION files
hauberg
parents:
diff
changeset
|
227 for root, dirs, files in os.walk(p, topdown=False): |
768fc6540e8a
Added a basic script for creating webpages from DESCRIPTION files
hauberg
parents:
diff
changeset
|
228 for name in files: |
768fc6540e8a
Added a basic script for creating webpages from DESCRIPTION files
hauberg
parents:
diff
changeset
|
229 os.remove(os.path.join(root, name)); |
768fc6540e8a
Added a basic script for creating webpages from DESCRIPTION files
hauberg
parents:
diff
changeset
|
230 for name in dirs: |
768fc6540e8a
Added a basic script for creating webpages from DESCRIPTION files
hauberg
parents:
diff
changeset
|
231 os.rmdir(os.path.join(root, name)); |
768fc6540e8a
Added a basic script for creating webpages from DESCRIPTION files
hauberg
parents:
diff
changeset
|
232 os.rmdir(p); |
768fc6540e8a
Added a basic script for creating webpages from DESCRIPTION files
hauberg
parents:
diff
changeset
|
233 |
2558 | 234 def handle_package(packdir, outdir, p): |
2429
768fc6540e8a
Added a basic script for creating webpages from DESCRIPTION files
hauberg
parents:
diff
changeset
|
235 if (os.path.isdir(packdir)): |
2668
67c5fe4fd3f0
Use alphabetic contents of package rather than categories page that might include functions from octaev itself
adb014
parents:
2651
diff
changeset
|
236 if (not os.path.exists(packdir + "/NOINSTALL")): |
67c5fe4fd3f0
Use alphabetic contents of package rather than categories page that might include functions from octaev itself
adb014
parents:
2651
diff
changeset
|
237 if (os.path.exists(outdir)): |
67c5fe4fd3f0
Use alphabetic contents of package rather than categories page that might include functions from octaev itself
adb014
parents:
2651
diff
changeset
|
238 rm_rf(outdir); |
67c5fe4fd3f0
Use alphabetic contents of package rather than categories page that might include functions from octaev itself
adb014
parents:
2651
diff
changeset
|
239 os.mkdir(outdir); |
67c5fe4fd3f0
Use alphabetic contents of package rather than categories page that might include functions from octaev itself
adb014
parents:
2651
diff
changeset
|
240 try: |
67c5fe4fd3f0
Use alphabetic contents of package rather than categories page that might include functions from octaev itself
adb014
parents:
2651
diff
changeset
|
241 desc = create_index_html(packdir, outdir, p); |
67c5fe4fd3f0
Use alphabetic contents of package rather than categories page that might include functions from octaev itself
adb014
parents:
2651
diff
changeset
|
242 create_license_html(desc['name'], packdir, outdir); |
67c5fe4fd3f0
Use alphabetic contents of package rather than categories page that might include functions from octaev itself
adb014
parents:
2651
diff
changeset
|
243 return desc; |
67c5fe4fd3f0
Use alphabetic contents of package rather than categories page that might include functions from octaev itself
adb014
parents:
2651
diff
changeset
|
244 except Exception, e: |
67c5fe4fd3f0
Use alphabetic contents of package rather than categories page that might include functions from octaev itself
adb014
parents:
2651
diff
changeset
|
245 print(e); |
67c5fe4fd3f0
Use alphabetic contents of package rather than categories page that might include functions from octaev itself
adb014
parents:
2651
diff
changeset
|
246 rm_rf(outdir); |
67c5fe4fd3f0
Use alphabetic contents of package rather than categories page that might include functions from octaev itself
adb014
parents:
2651
diff
changeset
|
247 raise Exception("Can't create index.html"); |
67c5fe4fd3f0
Use alphabetic contents of package rather than categories page that might include functions from octaev itself
adb014
parents:
2651
diff
changeset
|
248 else: |
67c5fe4fd3f0
Use alphabetic contents of package rather than categories page that might include functions from octaev itself
adb014
parents:
2651
diff
changeset
|
249 raise Exception("Package marked NOINSTALL"); |
2497 | 250 raise Exception('not packdir'); |
2429
768fc6540e8a
Added a basic script for creating webpages from DESCRIPTION files
hauberg
parents:
diff
changeset
|
251 |
768fc6540e8a
Added a basic script for creating webpages from DESCRIPTION files
hauberg
parents:
diff
changeset
|
252 def main(): |
2461 | 253 ## Start the package file |
254 index = open("packages.in", "w"); | |
2486 | 255 index.write("__HEADER__([[[Packages]]])"); |
2461 | 256 index.write('<p>The following packages are currently available in the repository.\n'); |
257 index.write("If you don't know how to install the packages please read the\n"); | |
258 index.write('relevant part of the <a href="FAQ.html#install">FAQ</a>.\n</p>'); | |
2468
a640288875d9
build-www now creates pages for package in extra and nonfree as well
hauberg
parents:
2463
diff
changeset
|
259 index.write('<p>Currently Octave-Forge is divided into seperate repositories\n'); |
a640288875d9
build-www now creates pages for package in extra and nonfree as well
hauberg
parents:
2463
diff
changeset
|
260 index.write('<ul><li><a href="#main">Main repository</a> contains packages that\n'); |
a640288875d9
build-www now creates pages for package in extra and nonfree as well
hauberg
parents:
2463
diff
changeset
|
261 index.write('are well tested and suited for most users.</li>\n'); |
a640288875d9
build-www now creates pages for package in extra and nonfree as well
hauberg
parents:
2463
diff
changeset
|
262 index.write('<li><a href="#extra">Extra packages</a> contains packages that\n'); |
a640288875d9
build-www now creates pages for package in extra and nonfree as well
hauberg
parents:
2463
diff
changeset
|
263 index.write("for various reasons aren't suited for everybody.</li>\n"); |
a640288875d9
build-www now creates pages for package in extra and nonfree as well
hauberg
parents:
2463
diff
changeset
|
264 index.write('<li><a href="#nonfree">Non-free packages</a> contains packages\n'); |
a640288875d9
build-www now creates pages for package in extra and nonfree as well
hauberg
parents:
2463
diff
changeset
|
265 index.write('that have license issues. Usually the packages themselves are\n'); |
a640288875d9
build-www now creates pages for package in extra and nonfree as well
hauberg
parents:
2463
diff
changeset
|
266 index.write('Free Software that depend on non-free libraries.</li></ul>\n'); |
2558 | 267 if (os.path.exists("INDEX")): |
268 os.system("rm -f INDEX"); | |
269 | |
2468
a640288875d9
build-www now creates pages for package in extra and nonfree as well
hauberg
parents:
2463
diff
changeset
|
270 main_dirs = ["main", "extra", "nonfree"]; |
a640288875d9
build-www now creates pages for package in extra and nonfree as well
hauberg
parents:
2463
diff
changeset
|
271 headers = ["Main repository", "Extra packages", "Non-free packages"]; |
a640288875d9
build-www now creates pages for package in extra and nonfree as well
hauberg
parents:
2463
diff
changeset
|
272 for i in range(len(main_dirs)): |
a640288875d9
build-www now creates pages for package in extra and nonfree as well
hauberg
parents:
2463
diff
changeset
|
273 name = main_dirs[i]; |
a640288875d9
build-www now creates pages for package in extra and nonfree as well
hauberg
parents:
2463
diff
changeset
|
274 main_dir = "../" + name + "/"; |
a640288875d9
build-www now creates pages for package in extra and nonfree as well
hauberg
parents:
2463
diff
changeset
|
275 header = headers[i]; |
a640288875d9
build-www now creates pages for package in extra and nonfree as well
hauberg
parents:
2463
diff
changeset
|
276 packages = os.listdir(main_dir); |
2609 | 277 packages.sort(key=str.lower); |
2468
a640288875d9
build-www now creates pages for package in extra and nonfree as well
hauberg
parents:
2463
diff
changeset
|
278 |
a640288875d9
build-www now creates pages for package in extra and nonfree as well
hauberg
parents:
2463
diff
changeset
|
279 index.write('<h2 id="' + name + '">' + header + '</h2>\n'); |
a640288875d9
build-www now creates pages for package in extra and nonfree as well
hauberg
parents:
2463
diff
changeset
|
280 |
a640288875d9
build-www now creates pages for package in extra and nonfree as well
hauberg
parents:
2463
diff
changeset
|
281 for i in range(0, len(packages)): |
a640288875d9
build-www now creates pages for package in extra and nonfree as well
hauberg
parents:
2463
diff
changeset
|
282 p = packages[i]; |
a640288875d9
build-www now creates pages for package in extra and nonfree as well
hauberg
parents:
2463
diff
changeset
|
283 packdir = main_dir + p; |
2558 | 284 if (os.path.isdir(packdir) and p != "CVS"): |
285 outdir = "./" + p; | |
286 try: | |
287 desc = handle_package(packdir, outdir, p); | |
288 archiv = desc['name'].lower() + '-' + desc['version'] + '.tar.gz'; | |
289 index.write('<div class="package">\n'); | |
290 index.write(' <b>' + desc['name'] + '</b>\n'); | |
291 index.write('<p>' + desc['description'][:100]); | |
292 if (len(desc['description']) > 100): | |
293 index.write('...'); | |
294 index.write('</p>\n'); | |
295 index.write('<p class="package_link">» <a href="' + outdir + '/index.html">details</a> | '); | |
2651
4ea46b848cf2
No longer have global OCTAVE_PACKAGE_PREFIX. Use the 'prefix' directive to pkg to replae it
adb014
parents:
2646
diff
changeset
|
296 index.write('<a href="__PACKAGE__/' + archiv + '?download">download</a></p>\n'); |
2558 | 297 index.write('</div>\n'); |
298 except Exception, e: | |
299 print("Skipping " + p); | |
300 print(e) | |
2468
a640288875d9
build-www now creates pages for package in extra and nonfree as well
hauberg
parents:
2463
diff
changeset
|
301 |
2461 | 302 index.write('__TRAILER__\n'); |
2429
768fc6540e8a
Added a basic script for creating webpages from DESCRIPTION files
hauberg
parents:
diff
changeset
|
303 index.close(); |
768fc6540e8a
Added a basic script for creating webpages from DESCRIPTION files
hauberg
parents:
diff
changeset
|
304 |
768fc6540e8a
Added a basic script for creating webpages from DESCRIPTION files
hauberg
parents:
diff
changeset
|
305 main(); |
768fc6540e8a
Added a basic script for creating webpages from DESCRIPTION files
hauberg
parents:
diff
changeset
|
306 |