4 import rst_to_docbook
.options_trem
8 The configuration script gets the target from the command line. It creates a
9 file with the configuration variable, and a short script for the rest of
10 script to be able to read and locate he configuration files.
15 target
, processor
= get_target()
17 sys
.stderr
.write('Since you need an xslt processor to run this script, the configuration will now quit\n'
26 make_configuration_file(processor
)
30 This functions uses a module I wrote to parse options. If no options are
31 determined on the command line, the function returnst the default
37 'processor': [1, 'p'],
39 options_obj
= rst_to_docbook
.options_trem
.ParseOptions(sys
.argv
,
41 opt_dict
, args
= options_obj
.parse_options()
43 sys
.stderr
.write('invalid options for configure.py\n'
44 'use python configure --target <desired folder>'
45 ' --processor <xslt proccessor>'
49 target
= opt_dict
.get('target')
51 target
= default_target()
52 processor
= opt_dict
.get('processor')
53 processor
= determine_processor(processor
)
54 return target
, processor
57 sys
.stdout
.write('using default \'/etc\' for the configuration directory\n')
60 def determine_processor(processor
= None):
61 sys
.stdout
.write('determining xslt processor...\n')
64 if processor
== 'xalan':
65 file = 'test_files/simple.xml'
66 xsl_file
= 'test_files/simple.xsl'
68 command
= 'java org.apache.xalan.xslt.Process \
69 -Ts -in %s -xsl %s -out %s' % (file, xsl_file
, output
)
70 error
= os
.system(command
)
72 sys
.stderr
.write('xalan does not appear to be set up correctly '
74 'The command "java org.apache.xalan.xslt.Process" failed\n'
75 'Is the CLASSPATH set for xalan?\n'
76 'Configuraton will now quit\n'
81 elif processor
== '4suite':
83 from Ft
.Xml
import InputSource
84 from Ft
.Xml
.Xslt
.Processor
import Processor
87 sys
.stderr
.write('4suite does not appear to be set up correctly on your system\n'
88 'Could not find the Ft.Xml libraries\n'
89 'Script cannot work without an xslt procesor!\n'
92 elif processor
== 'xsltproc' or processor
== 'xmllint':
98 sys
.stderr
.write('You either choose xmllint as your processor, or xmllint was tested because not other\n'
99 'processor was found\n'
100 'However, the libraries "libxml2" and or "libxslt" cannot be found.\n'
104 sys
.stderr
.write('The processor "%s" is not a valid choice for this script\n' % processor
)
110 def make_var_file(target
):
111 write_obj
= open('var_file', 'w')
112 # write_obj.write('[global]\n')
113 write_obj
.write(target
)
116 def make_location(target
):
117 write_obj
= open('rst_to_docbook/location.py', 'w')
127 def make_configuration_file(processor
):
128 write_obj
= open('data/configure.xml', 'w')
131 <xslt-processor processor = "%s"/>
136 if __name__
== '__main__':