Lines 12-29
Link Here
|
12 |
# |
12 |
# |
13 |
# |
13 |
# |
14 |
# Detailed usage: |
14 |
# Detailed usage: |
15 |
# dohtml <list-of-files> |
15 |
# dohtml <list-of-files> |
16 |
# - will install the files in the list of files (space-separated list) into |
16 |
# - will install the files in the list of files (space-separated list) into |
17 |
# /usr/share/doc/${PF}/html, provided the file ends in .html, .png, .jpg |
17 |
# /usr/share/doc/${PF}/html, provided the file ends in .css, .gif, .htm, |
18 |
# or .css |
18 |
# .html, .jpg, .js or .png |
19 |
# dohtml -r <list-of-files-and-directories> |
19 |
# dohtml -r <list-of-files-and-directories> |
20 |
# - will do as 'dohtml', but recurse into all directories, as long as the |
20 |
# - will do as 'dohtml', but recurse into all directories, as long as the |
21 |
# directory name is not CVS |
21 |
# directory name is not CVS |
22 |
# dohtml -A jpe,java [-r] <list-of-files[-and-directories]> |
22 |
# dohtml -A jpe,java [-r] <list-of-files[-and-directories]> |
23 |
# - will do as 'dohtml' but add .jpe,.java (default filter list is |
23 |
# - will do as 'dohtml' but add .jpe,.java (default filter list is |
24 |
# added to your list) |
24 |
# added to your list) |
25 |
# dohtml -a png,gif,html,htm [-r] <list-of-files[-and-directories]> |
25 |
# dohtml -a png,gif,html,htm [-r] <list-of-files[-and-directories]> |
26 |
# - will do as 'dohtml' but filter on .png,.gif,.html,.htm (default filter |
26 |
# - will do as 'dohtml' but filter on .png,.gif,.html,.htm (default filter |
27 |
# list is ignored) |
27 |
# list is ignored) |
28 |
# dohtml -x CVS,SCCS,RCS -r <list-of-files-and-directories> |
28 |
# dohtml -x CVS,SCCS,RCS -r <list-of-files-and-directories> |
29 |
# - will do as 'dohtml -r', but ignore directories named CVS, SCCS, RCS |
29 |
# - will do as 'dohtml -r', but ignore directories named CVS, SCCS, RCS |
Lines 34-39
Link Here
|
34 |
import sys |
34 |
import sys |
35 |
import types |
35 |
import types |
36 |
|
36 |
|
|
|
37 |
from output import EOutput |
38 |
|
37 |
def dodir(path): |
39 |
def dodir(path): |
38 |
os.system("install -d '%s'" % path) |
40 |
os.system("install -d '%s'" % path) |
39 |
|
41 |
|
Lines 48-68
Link Here
|
48 |
if dirname: fullpath = dirname + "/" + fullpath |
50 |
if dirname: fullpath = dirname + "/" + fullpath |
49 |
|
51 |
|
50 |
if options.DOCDESTTREE: |
52 |
if options.DOCDESTTREE: |
51 |
destdir = options.D + "usr/share/doc/" + options.PF + "/" + options.DOCDESTTREE + "/" + options.doc_prefix + "/" + prefix |
53 |
docdesttree = options.DOCDESTTREE |
52 |
else: |
54 |
else: |
53 |
destdir = options.D + "usr/share/doc/" + options.PF + "/html/" + options.doc_prefix + "/" + prefix |
55 |
docdesttree = 'html' |
|
|
56 |
destdir = options.D + '/'.join (('usr/share/doc', |
57 |
options.PF, |
58 |
docdesttree, |
59 |
options.doc_prefix, |
60 |
prefix)) |
54 |
|
61 |
|
55 |
if os.path.isfile(fullpath): |
62 |
if os.path.isfile(fullpath): |
56 |
ext = os.path.splitext(basename)[1] |
63 |
ext = os.path.splitext(basename)[1] |
57 |
if (len(ext) and ext[1:] in options.allowed_exts) or basename in options.allowed_files: |
64 |
if (len(ext) and ext[1:] in options.allowed_exts) or basename in options.allowed_files: |
58 |
dodir(destdir) |
65 |
dodir(destdir) |
59 |
dofile(fullpath, destdir + "/" + basename) |
66 |
dofile(fullpath, destdir + "/" + basename) |
60 |
elif options.recurse and os.path.isdir(fullpath) and \ |
67 |
elif os.path.isdir (fullpath) and basename not in options.disallowed_dirs: |
61 |
basename not in options.disallowed_dirs: |
68 |
if options.recurse: |
62 |
for i in os.listdir(fullpath): |
69 |
for i in os.listdir(fullpath): |
63 |
pfx = basename |
70 |
pfx = basename |
64 |
if prefix: pfx = prefix + "/" + pfx |
71 |
if prefix: pfx = prefix + "/" + pfx |
65 |
install(i, dirname, options, pfx) |
72 |
install(i, dirname, options, pfx) |
|
|
73 |
else: |
74 |
# bug #149745 |
75 |
EOutput().ewarn ('QA Notice: directory %s given to dohtml without recursion (option -r)' % fullpath) |
76 |
return False |
66 |
else: |
77 |
else: |
67 |
return False |
78 |
return False |
68 |
return True |
79 |
return True |
Lines 73-86
Link Here
|
73 |
self.PF = "" |
84 |
self.PF = "" |
74 |
self.D = "" |
85 |
self.D = "" |
75 |
self.DOCDESTTREE = "" |
86 |
self.DOCDESTTREE = "" |
76 |
|
87 |
|
77 |
if os.environ.has_key("PF"): |
88 |
if os.environ.has_key("PF"): |
78 |
self.PF = os.environ["PF"] |
89 |
self.PF = os.environ["PF"] |
79 |
if os.environ.has_key("D"): |
90 |
if os.environ.has_key("D"): |
80 |
self.D = os.environ["D"] |
91 |
self.D = os.environ["D"] |
81 |
if os.environ.has_key("DOCDESTTREE"): |
92 |
if os.environ.has_key("DOCDESTTREE"): |
82 |
self.DOCDESTTREE = os.environ["DOCDESTTREE"] |
93 |
self.DOCDESTTREE = os.environ["DOCDESTTREE"] |
83 |
|
94 |
|
84 |
self.allowed_exts = [ 'png', 'gif', 'html', 'htm', 'jpg', 'css', 'js' ] |
95 |
self.allowed_exts = [ 'png', 'gif', 'html', 'htm', 'jpg', 'css', 'js' ] |
85 |
self.allowed_files = [] |
96 |
self.allowed_files = [] |
86 |
self.disallowed_dirs = [ 'CVS' ] |
97 |
self.disallowed_dirs = [ 'CVS' ] |
Lines 92-105
Link Here
|
92 |
opts = OptionsClass() |
103 |
opts = OptionsClass() |
93 |
|
104 |
|
94 |
print "dohtml [-a .foo,.bar] [-A .foo,.bar] [-f foo,bar] [-x foo,bar]" |
105 |
print "dohtml [-a .foo,.bar] [-A .foo,.bar] [-f foo,bar] [-x foo,bar]" |
95 |
print " [-r] [-V] <file> [file ...]" |
106 |
print " [-r] [-V] <file> [file ...]" |
96 |
print |
107 |
print |
97 |
print " -a Set the list of allowed to those that are specified." |
108 |
print " -a Set the list of allowed to those that are specified." |
98 |
print " Default:", string.join(opts.allowed_exts, ",") |
109 |
print " Default:", string.join(opts.allowed_exts, ",") |
99 |
print " -A Extend the list of allowed file types." |
110 |
print " -A Extend the list of allowed file types." |
100 |
print " -f Set list of allowed extensionless file names." |
111 |
print " -f Set list of allowed extensionless file names." |
101 |
print " -x Set directories to be excluded from recursion." |
112 |
print " -x Set directories to be excluded from recursion." |
102 |
print " Default:", string.join(opts.disallowed_dirs, ",") |
113 |
print " Default:", string.join(opts.disallowed_dirs, ",") |
103 |
print " -r Install files and directories recursively." |
114 |
print " -r Install files and directories recursively." |
104 |
print " -V Be verbose." |
115 |
print " -V Be verbose." |
105 |
print |
116 |
print |
Lines 107-113
Link Here
|
107 |
def parse_args(): |
118 |
def parse_args(): |
108 |
options = OptionsClass() |
119 |
options = OptionsClass() |
109 |
args = [] |
120 |
args = [] |
110 |
|
121 |
|
111 |
x = 1 |
122 |
x = 1 |
112 |
while x < len(sys.argv): |
123 |
while x < len(sys.argv): |
113 |
arg = sys.argv[x] |
124 |
arg = sys.argv[x] |
Lines 139-145
Link Here
|
139 |
else: |
150 |
else: |
140 |
args.append(sys.argv[x]) |
151 |
args.append(sys.argv[x]) |
141 |
x += 1 |
152 |
x += 1 |
142 |
|
153 |
|
143 |
return (options, args) |
154 |
return (options, args) |
144 |
|
155 |
|
145 |
def main(): |
156 |
def main(): |
Lines 151-172
Link Here
|
151 |
|
162 |
|
152 |
if options.verbose: |
163 |
if options.verbose: |
153 |
print "Allowed extensions:", options.allowed_exts |
164 |
print "Allowed extensions:", options.allowed_exts |
154 |
print "Document prefix : '" + options.doc_prefix + "'" |
165 |
print "Document prefix : '%s'" % options.doc_prefix |
155 |
print "Allowed files :", options.allowed_files |
166 |
print "Allowed files :", options.allowed_files |
156 |
|
167 |
|
157 |
success = True |
168 |
success = True |
158 |
|
|
|
159 |
for x in args: |
169 |
for x in args: |
160 |
basename = os.path.basename(x) |
170 |
basename = os.path.basename(x) |
161 |
dirname = os.path.dirname(x) |
171 |
dirname = os.path.dirname(x) |
162 |
success = success and install(basename, dirname, options) |
172 |
# bug #149745, comment #1 |
163 |
|
173 |
success &= install (basename, dirname, options) |
164 |
if success: |
174 |
|
165 |
retcode = 0 |
175 |
sys.exit (int (not success)) # 0 True, 1 False |
166 |
else: |
|
|
167 |
retcode = 1 |
168 |
|
169 |
sys.exit(retcode) |
170 |
|
176 |
|
171 |
if __name__ == "__main__": |
177 |
if __name__ == "__main__": |
172 |
main() |
178 |
main() |