3 import docutils_nest
.nested_inline
4 import docutils_nest
.read_config
5 import docutils_nest
.options_trem
6 import docutils_nest
.location
9 converst an XML file to nested tags
13 outer_dir
= docutils_nest
.location
.get_location()
14 doc_nest_dir
= os
.path
.join(outer_dir
, '.docutils_nest')
18 def __init__(self
, sys_string
):
19 self
.__sys
_string
= sys_string
21 def get_options(self
):
25 options_obj
= docutils_nest
.options_trem
.ParseOptions(
26 system_string
= self
.__sys
_string
,
27 options_dict
= options_dict
,
30 options
, arguments
= options_obj
.parse_options()
34 sys
.stderr
.write('Script will quit because of invalid options')
36 output
= options
.get('output')
39 sys
.stderr
.write('must provide output for script to work\n')
45 sys
.stderr
.write('must provide a file for script to work\n')
52 def __init__(self
, file):
56 config_obj
= docutils_nest
.read_config
.Configure(self
.__file
)
57 config_values
= config_obj
.read_configs()
68 self
.__output
= output
69 self
.__start
_role
= config_values
.get('start_role')
70 self
.__end
_role
= config_values
.get('end_role')
71 self
.__start
_group
= config_values
.get('start_group')
72 self
.__end
_group
= config_values
.get('end_group')
73 self
.__place
_of
_role
= config_values
.get('place_of_role')
74 self
.__tag
_name
= config_values
.get('tag_name')
75 self
.__warning
= config_values
.get('warning')
78 convert_obj
= docutils_nest
.nested_inline
.InlineBrackets(
80 output
= self
.__output
,
81 start_role
= self
.__start
_role
,
82 end_role
= self
.__end
_role
,
83 start_group
= self
.__start
_group
,
84 end_group
= self
.__end
_group
,
85 place
= self
.__place
_of
_role
,
86 tag_name
= self
.__tag
_name
,
87 warning
= self
.__warning
89 convert_obj
.make_tags()
96 def __init__(self
, file, output
):
98 self
.__output
= output
101 config_file
= os
.path
.join(doc_nest_dir
, 'configure.xml')
102 config_obj
= GetConfig(config_file
)
103 config_values
= config_obj
.get_config()
104 tags_obj
= MakeTags(self
.__file
, self
.__output
, config_values
)
107 if __name__
== '__main__':
109 # file = '/home/paul/lib/python/paul/restructure_tools/test_inline.xml'
110 # output = '/home/paul/paultemp/brackets_to_tags.temp.xml'
111 # nest_obj = NestDocutils(file, output)
112 # nest_obj.nest_tags()
114 options_obj
= GetOptions(sys
.argv
)
115 file, output
= options_obj
.get_options()
116 config_file
= os
.path
.join(doc_nest_dir
, 'configure.xml')
117 config_obj
= GetConfig(config_file
)
118 config_values
= config_obj
.get_config()
119 tags_obj
= MakeTags(file, output
, config_values
)
121 command
= 'xmlvalid -c -v %s' % output