sys.stderr.write('The options "--level" must be a number.\n')
return_options['valid'] = 0
return return_options
None<EXCEPTION MATCH>ValueError
if 'dtd' in the_keys:
return_options['raw-dtd-path'] = options['dtd']
acceptable = [
'sdoc',
'raw',
'tei']
if 'format' in the_keys:
format = options['format']
if format not in acceptable:
sys.stderr.write("--format must take either 'sdoc' or 'tei'\n")
return_options['valid'] = 0
return return_options
return_options['format'] = options['format']
return_options['show-warnings'] = 0
if 'show-warnings' in the_keys:
return_options['show-warnings'] = 1
if 'no-font' in the_keys:
return_options['convert-symbol'] = 0
return_options['convert-zapf'] = 0
return_options['convert-wingdings'] = 0
if 'font' in the_keys:
return_options['convert-symbol'] = 1
return_options['convert-zapf'] = 1
return_options['convert-wingdings'] = 1
if 'symbol' in the_keys:
return_options['convert-symbol'] = 1
if 'no-symbol' in the_keys:
return_options['convert-symbol'] = 0
if 'wingdings' in the_keys:
return_options['convert-wingdings'] = 1
if 'no-wingdings' in the_keys:
return_options['convert-wingdings'] = 0
if 'zapf' in the_keys:
return_options['convert-zapf'] = 1
if 'no-zapf' in the_keys:
return_options['convert-zapf'] = 0
if 'caps' in the_keys:
return_options['convert-caps'] = 1
if 'no-caps' in the_keys:
return_options['convert-caps'] = 0
if 'no-dtd' in the_keys:
return_options['no-dtd'] = 1
else:
return_options['no-dtd'] = 0
return_options['no-ask'] = 0
if 'no-ask' in the_keys:
return_options['no-ask'] = 1
sys.stderr.write('You can also permanetly set the no-ask option in the rtf2xml file.\n')
if 'no-namespace' in the_keys:
return_options['no-namespace'] = 1
if 'headings-to-sections' in the_keys:
return_options['headings-to-sections'] = 1
elif 'no-headings-to-sections' in the_keys:
return_options['headings-to-sections'] = 0
if 'no-lists' in the_keys:
return_options['form-lists'] = 0
elif 'lists' in the_keys:
return_options['form-lists'] = 1
if 'group-styles' in the_keys:
return_options['group-styles'] = 1
elif 'no-group-styles' in the_keys:
return_options['group-styles'] = 0
if 'group-borders' in the_keys:
return_options['group-borders'] = 1
elif 'no-group-borders' in the_keys:
return_options['group-borders'] = 0
if 'empty-para' in the_keys:
return_options['empty-paragraphs'] = 1
elif 'no-empty-para' in the_keys:
return_options['empty-paragraphs'] = 0
if len(arguments) == 0:
sys.stderr.write('You must provide a file to convert.\n')
return_options['valid'] = 0
return return_options
if len(arguments) > 1:
sys.stderr.write('You can only convert one file at a time.\n')
return_options['valid'] = 0
else:
return_options['in-file'] = arguments[0]
smart_output = return_options.get('smart-output')
if smart_output == 'false':
smart_output = 0
if smart_output and not return_options['out-file']:
in_file = return_options['in-file']
(the_file_name, ext) = os.path.splitext(in_file)
if ext != '.rtf':
sys.stderr.write('Sorry, but this file does not have an "rtf" extension, so \nthe script will not attempt to convert it.\nIf it is in fact an rtf file, use the "-o" option.\n')