5 import docutils_nest
.options_trem
9 The configuration script gets the target from the command line. It creates a file with the configuration variable, and a short script for the rest of script to be able to read and locate he configuration files.
20 This functions uses a module I wrote to parse options. If no options are
21 determined on the command line, the function returnst the default
28 options_obj
= docutils_nest
.options_trem
.ParseOptions(sys
.argv
,
30 opt_dict
, args
= options_obj
.parse_options()
32 sys
.stderr
.write('invalid way to run configure:\n'
33 'python configure.py --target <directory of choice>'
36 target
= opt_dict
.get('target')
38 target
= default_target()
42 sys
.stdout
.write('using default /etc for configuration directory\n')
45 def make_var_file(target
):
46 write_obj
= open('var_file', 'w')
47 # write_obj.write('[global]\n')
48 write_obj
.write(target
)
51 def make_location(target
):
52 write_obj
= open('docutils_nest/location.py', 'w')
63 if __name__
== '__main__':
86 options_obj = options_trem.ParseOptions(sys.argv,
88 opt_dict, args = options_obj.parse_options()
90 sys.stdout.write('Will use the default configuration of /etc/nest_docutils\n')
91 return '/etc/docutils_nest'
92 target = opt_dict.get('target')
94 return '/etc/docutils_nest'
97 def change_setup(target):
98 read_obj = open('setup.py', 'r')
99 write_obj = open('temp', 'w')
102 line = read_obj.readline()
103 index = line.find('data_files=')
105 write_obj.write('data_files = [("%s", ["data/configure.xml"])],\n' % target)
107 write_obj.write(line)
110 read_obj = open('temp', 'r')
111 write_obj = open('setup.py', 'w')
114 line = read_obj.readline()
115 write_obj.write(line)
120 def change_script(target):
122 read_obj = open('docutils_nest/nest_docutils.py', 'r')
123 write_obj = open('temp', 'w')
126 line = read_obj.readline()
127 index = line.find('$configure$')
129 write_obj.write("ext_location = '%s' # $configure$" % \
132 write_obj.write(line)
135 read_obj = open('temp', 'r')
136 write_obj = open('docutils_nest/nest_docutils.py', 'w')
139 line = read_obj.readline()
140 write_obj.write(line)
144 if __name__ == '__main__':