1
1
#!/usr/bin/env python
3
# Author: Forest Bond <forest.bond@alittletooquiet.net>
3
# Author: Forest Bond <forest@alittletooquiet.net>
4
4
# This file is in the public domain.
6
6
import os, sys, commands, glob, inspect
19
19
sys.path.insert(0, modules_dir)
20
20
sys.path.insert(0, project_dir)
22
from tests.common import TEST_DIR, TEST_DATA_DIR
22
from pytagsfs.fs import UMOUNT_COMMAND
23
from tests.common import TEST_DATA_DIR
25
26
################################################################################
105
106
log.warn("failed to remove '%s'" % dirname)
107
108
def clean_test_data(self):
108
status, output = commands.getstatusoutput(
109
'test -x $(which fusermount) && which fusermount')
111
umount_cmd = '%s -u' % output.strip()
113
status, output = commands.getstatusoutput(
114
'test -x $(which umount) && which umount')
116
umount_cmd = output.strip()
118
raise AssertionError("can't find a umount command")
120
test_tree_root = os.path.join(TEST_DIR, 'test-trees')
122
dirs = os.listdir(test_tree_root)
110
dirs = os.listdir(TEST_DATA_DIR)
123
111
except (IOError, OSError):
125
"not cleaning '%s': failed to read directory" % test_tree_root)
113
"not cleaning '%s': failed to read directory" % TEST_DATA_DIR)
128
full_dir = os.path.join(test_tree_root, dir)
116
full_dir = os.path.join(TEST_DATA_DIR, dir)
129
117
mnt_dir = os.path.join(full_dir, 'mnt')
131
119
log.info("unmounting '%s'" % mnt_dir)
132
120
status, output = commands.getstatusoutput(
133
'%s %s' % (umount_cmd, mnt_dir))
121
UMOUNT_COMMAND % mnt_dir)
135
123
print >>sys.stderr, output
137
125
self.clean_dir(full_dir)
139
os.rmdir(test_tree_root)
141
127
self.clean_dir(TEST_DATA_DIR)
176
162
description = 'Build manual pages from docbook XML.'
177
163
user_options = []
178
164
man_build_dir = 'build/man'
165
stylesheet = find_docbook_manpage_stylesheet()
180
167
def initialize_options(self):
183
170
def finalize_options(self):
184
self.stylesheet = find_docbook_manpage_stylesheet()
185
171
if self.distribution.manpage_sources is not None:
186
172
self.docbook_files = [
187
173
os.path.abspath(p) for p in self.distribution.manpage_sources
191
177
def build_manpage_from_docbook(self, docbook_file):
178
assert self.stylesheet is not None, 'failed to find stylesheet'
192
180
command = self.xsltproc + [self.stylesheet, docbook_file]
193
181
orig_wd = os.getcwd()
194
182
os.chdir(self.man_build_dir)
198
186
os.chdir(orig_wd)
189
if self.stylesheet is None:
191
'Warning: missing docbook XSL stylesheets; '
192
'manpages will not be built.\n'
193
'Please install the docbook XSL stylesheets from '
194
'http://docbook.org/.'
201
197
manpage_sources = self.docbook_files
202
198
if manpage_sources:
203
199
if not os.path.exists(self.man_build_dir):
281
277
################################################################################
283
manpage_sources = ['pytagsfs.xml', 'pytags.xml']
288
s.replace('xml', '1'),
290
for s in manpage_sources
282
if build_manpages.stylesheet is not None:
283
manpage_sources = ['pytagsfs.xml', 'pytags.xml']
288
s.replace('xml', '1'),
290
for s in manpage_sources
292
data_files.append(('share/man/man1', manpages))
318
320
manpage_sources = manpage_sources,
319
321
release_file = 'release',
320
data_files = [('share/man/man1', manpages)],
322
data_files = data_files,