2012-11-20 05:27:00 -04:00
|
|
|
#!/usr/bin/env python
|
2016-11-08 07:06:05 -04:00
|
|
|
from __future__ import print_function
|
2016-07-31 07:22:06 -03:00
|
|
|
import glob
|
|
|
|
import os
|
|
|
|
import re
|
|
|
|
import sys
|
|
|
|
from optparse import OptionParser
|
2012-07-04 20:44:53 -03:00
|
|
|
|
2016-07-31 07:22:06 -03:00
|
|
|
from param import (Library, Parameter, Vehicle, known_group_fields,
|
2017-05-02 07:36:14 -03:00
|
|
|
known_param_fields, required_param_fields, known_units)
|
2013-05-26 19:25:24 -03:00
|
|
|
from htmlemit import HtmlEmit
|
2016-03-17 02:04:03 -03:00
|
|
|
from rstemit import RSTEmit
|
2016-07-31 07:22:06 -03:00
|
|
|
from wikiemit import WikiEmit
|
|
|
|
from xmlemit import XmlEmit
|
2017-03-02 20:15:02 -04:00
|
|
|
from mdemit import MDEmit
|
2012-07-04 21:42:38 -03:00
|
|
|
|
2013-05-21 04:01:13 -03:00
|
|
|
parser = OptionParser("param_parse.py [options]")
|
|
|
|
parser.add_option("-v", "--verbose", dest='verbose', action='store_true', default=False, help="show debugging output")
|
2018-10-07 22:20:54 -03:00
|
|
|
parser.add_option("--vehicle", default='*', help="Vehicle type to generate for")
|
|
|
|
parser.add_option("--no-emit",
|
|
|
|
dest='emit_params',
|
|
|
|
action='store_false',
|
|
|
|
default=True,
|
|
|
|
help="don't emit parameter documention, just validate")
|
2018-12-06 05:07:51 -04:00
|
|
|
parser.add_option("--format",
|
|
|
|
dest='output_format',
|
|
|
|
action='store',
|
|
|
|
default='all',
|
|
|
|
choices=['all', 'html', 'rst', 'wiki', 'xml', 'edn', 'md'],
|
|
|
|
help="what output format to use")
|
2013-05-21 04:01:13 -03:00
|
|
|
(opts, args) = parser.parse_args()
|
|
|
|
|
|
|
|
|
2012-07-04 21:42:38 -03:00
|
|
|
# Regular expressions for parsing the parameter metadata
|
|
|
|
|
2017-09-27 22:18:23 -03:00
|
|
|
prog_param = re.compile(r"@Param: (\w+).*((?:\n[ \t]*// @(\w+)(?:{([^}]+)})?: (.*))+)(?:\n\n|\n[ \t]+[A-Z])", re.MULTILINE)
|
2012-07-04 21:42:38 -03:00
|
|
|
|
2017-08-25 10:34:35 -03:00
|
|
|
# match e.g @Value: 0=Unity, 1=Koala, 17=Liability
|
2013-05-21 04:01:13 -03:00
|
|
|
prog_param_fields = re.compile(r"[ \t]*// @(\w+): (.*)")
|
2018-01-28 21:02:22 -04:00
|
|
|
# match e.g @Value{Copter}: 0=Volcano, 1=Peppermint
|
2017-09-27 22:18:23 -03:00
|
|
|
prog_param_tagged_fields = re.compile(r"[ \t]*// @(\w+){([^}]+)}: (.*)")
|
2016-07-31 07:22:06 -03:00
|
|
|
|
2013-05-21 04:01:13 -03:00
|
|
|
prog_groups = re.compile(r"@Group: *(\w+).*((?:\n[ \t]*// @(Path): (\S+))+)", re.MULTILINE)
|
2016-07-31 07:22:06 -03:00
|
|
|
|
2012-07-04 20:44:53 -03:00
|
|
|
apm_path = os.path.join(os.path.dirname(os.path.realpath(__file__)), '../../../')
|
2015-05-30 02:55:24 -03:00
|
|
|
vehicle_paths = glob.glob(apm_path + "%s/Parameters.cpp" % opts.vehicle)
|
|
|
|
extension = 'cpp'
|
2015-05-20 22:42:32 -03:00
|
|
|
if len(vehicle_paths) == 0:
|
2015-05-30 02:55:24 -03:00
|
|
|
vehicle_paths = glob.glob(apm_path + "%s/Parameters.pde" % opts.vehicle)
|
|
|
|
extension = 'pde'
|
2012-11-20 05:37:02 -04:00
|
|
|
vehicle_paths.sort(reverse=True)
|
2012-07-04 20:44:53 -03:00
|
|
|
|
|
|
|
vehicles = []
|
|
|
|
libraries = []
|
|
|
|
|
2013-05-21 04:01:13 -03:00
|
|
|
error_count = 0
|
2018-09-19 07:33:24 -03:00
|
|
|
current_param = None
|
|
|
|
current_file = None
|
2013-05-21 04:01:13 -03:00
|
|
|
|
2016-07-31 07:22:06 -03:00
|
|
|
|
|
|
|
def debug(str_to_print):
|
|
|
|
"""Debug output if verbose is set."""
|
2013-05-21 04:01:13 -03:00
|
|
|
if opts.verbose:
|
2016-07-31 07:22:06 -03:00
|
|
|
print(str_to_print)
|
|
|
|
|
2013-05-21 04:01:13 -03:00
|
|
|
|
2016-07-31 07:22:06 -03:00
|
|
|
def error(str_to_print):
|
|
|
|
"""Show errors."""
|
2013-05-21 04:01:13 -03:00
|
|
|
global error_count
|
|
|
|
error_count += 1
|
2018-09-19 07:33:24 -03:00
|
|
|
if current_file is not None:
|
|
|
|
print("In %s" % current_file)
|
|
|
|
if current_param is not None:
|
|
|
|
print("At param %s" % current_param)
|
2016-07-31 07:22:06 -03:00
|
|
|
print(str_to_print)
|
2013-05-21 04:01:13 -03:00
|
|
|
|
2018-10-07 22:20:54 -03:00
|
|
|
|
2017-09-24 21:23:47 -03:00
|
|
|
truename_map = {
|
|
|
|
"APMrover2": "Rover",
|
|
|
|
"ArduSub": "Sub",
|
|
|
|
"ArduCopter": "Copter",
|
|
|
|
"ArduPlane": "Plane",
|
|
|
|
"AntennaTracker": "Tracker",
|
|
|
|
}
|
2012-07-04 20:44:53 -03:00
|
|
|
for vehicle_path in vehicle_paths:
|
|
|
|
name = os.path.basename(os.path.dirname(vehicle_path))
|
|
|
|
path = os.path.normpath(os.path.dirname(vehicle_path))
|
2017-09-24 21:23:47 -03:00
|
|
|
vehicles.append(Vehicle(name, path, truename_map[name]))
|
2013-05-21 04:01:13 -03:00
|
|
|
debug('Found vehicle type %s' % name)
|
2016-07-31 07:22:06 -03:00
|
|
|
|
2018-08-05 22:05:13 -03:00
|
|
|
if len(vehicles) > 1 or len(vehicles) == 0:
|
2017-08-25 10:34:35 -03:00
|
|
|
print("Single vehicle only, please")
|
|
|
|
sys.exit(1)
|
|
|
|
|
2012-07-04 20:44:53 -03:00
|
|
|
for vehicle in vehicles:
|
2013-05-21 04:01:13 -03:00
|
|
|
debug("===\n\n\nProcessing %s" % vehicle.name)
|
2018-09-19 07:33:24 -03:00
|
|
|
current_file = vehicle.path+'/Parameters.' + extension
|
2016-07-31 07:22:06 -03:00
|
|
|
|
2018-09-19 07:33:24 -03:00
|
|
|
f = open(current_file)
|
2012-07-04 20:44:53 -03:00
|
|
|
p_text = f.read()
|
2016-07-31 07:22:06 -03:00
|
|
|
f.close()
|
2012-07-04 20:44:53 -03:00
|
|
|
param_matches = prog_param.findall(p_text)
|
|
|
|
group_matches = prog_groups.findall(p_text)
|
2016-07-31 07:22:06 -03:00
|
|
|
|
2013-05-21 04:01:13 -03:00
|
|
|
debug(group_matches)
|
2012-07-04 20:44:53 -03:00
|
|
|
for group_match in group_matches:
|
2018-10-07 22:20:54 -03:00
|
|
|
lib = Library(group_match[0])
|
2012-07-04 21:42:38 -03:00
|
|
|
fields = prog_param_fields.findall(group_match[1])
|
|
|
|
for field in fields:
|
|
|
|
if field[0] in known_group_fields:
|
2018-10-07 22:20:54 -03:00
|
|
|
setattr(lib, field[0], field[1])
|
2012-07-04 21:42:38 -03:00
|
|
|
else:
|
2017-08-25 10:34:35 -03:00
|
|
|
error("group: unknown parameter metadata field '%s'" % field[0])
|
2018-10-07 22:20:54 -03:00
|
|
|
if not any(lib.name == parsed_l.name for parsed_l in libraries):
|
|
|
|
libraries.append(lib)
|
2016-07-31 07:22:06 -03:00
|
|
|
|
2012-07-04 20:44:53 -03:00
|
|
|
for param_match in param_matches:
|
2018-09-19 07:33:24 -03:00
|
|
|
p = Parameter(vehicle.name+":"+param_match[0], current_file)
|
2013-05-21 04:01:13 -03:00
|
|
|
debug(p.name + ' ')
|
2018-09-19 07:33:24 -03:00
|
|
|
current_param = p.name
|
2012-07-04 20:44:53 -03:00
|
|
|
field_text = param_match[1]
|
|
|
|
fields = prog_param_fields.findall(field_text)
|
2013-05-21 04:01:13 -03:00
|
|
|
field_list = []
|
2012-07-04 20:44:53 -03:00
|
|
|
for field in fields:
|
2013-05-21 04:01:13 -03:00
|
|
|
field_list.append(field[0])
|
2012-07-04 20:44:53 -03:00
|
|
|
if field[0] in known_param_fields:
|
2018-03-13 03:49:12 -03:00
|
|
|
value = re.sub('@PREFIX@', "", field[1])
|
|
|
|
setattr(p, field[0], value)
|
2012-07-04 20:44:53 -03:00
|
|
|
else:
|
2017-08-25 10:34:35 -03:00
|
|
|
error("param: unknown parameter metadata field '%s'" % field[0])
|
2013-05-21 04:01:13 -03:00
|
|
|
for req_field in required_param_fields:
|
2016-07-31 07:22:06 -03:00
|
|
|
if req_field not in field_list:
|
2013-05-21 04:01:13 -03:00
|
|
|
error("missing parameter metadata field '%s' in %s" % (req_field, field_text))
|
2016-07-31 07:22:06 -03:00
|
|
|
|
2012-07-04 20:44:53 -03:00
|
|
|
vehicle.params.append(p)
|
2018-09-19 07:33:24 -03:00
|
|
|
current_file = None
|
2013-05-21 04:01:13 -03:00
|
|
|
debug("Processed %u params" % len(vehicle.params))
|
2016-07-31 07:22:06 -03:00
|
|
|
|
2013-05-21 04:01:13 -03:00
|
|
|
debug("Found %u documented libraries" % len(libraries))
|
2012-07-04 20:44:53 -03:00
|
|
|
|
2017-02-05 22:16:37 -04:00
|
|
|
alllibs = libraries[:]
|
|
|
|
|
2017-08-25 10:34:35 -03:00
|
|
|
vehicle = vehicles[0]
|
|
|
|
|
2018-10-07 22:20:54 -03:00
|
|
|
|
2017-08-25 10:34:35 -03:00
|
|
|
def process_library(vehicle, library, pathprefix=None):
|
2017-02-05 22:16:37 -04:00
|
|
|
'''process one library'''
|
|
|
|
paths = library.Path.split(',')
|
|
|
|
for path in paths:
|
|
|
|
path = path.strip()
|
2018-09-19 07:33:24 -03:00
|
|
|
global current_file
|
|
|
|
current_file = path
|
2017-02-05 22:16:37 -04:00
|
|
|
debug("\n Processing file '%s'" % path)
|
|
|
|
if pathprefix is not None:
|
2018-10-07 22:20:54 -03:00
|
|
|
libraryfname = os.path.join(pathprefix, path)
|
2017-02-05 22:16:37 -04:00
|
|
|
elif path.find('/') == -1:
|
|
|
|
if len(vehicles) != 1:
|
|
|
|
print("Unable to handle multiple vehicles with .pde library")
|
|
|
|
continue
|
|
|
|
libraryfname = os.path.join(vehicles[0].path, path)
|
|
|
|
else:
|
|
|
|
libraryfname = os.path.normpath(os.path.join(apm_path + '/libraries/' + path))
|
|
|
|
if path and os.path.exists(libraryfname):
|
|
|
|
f = open(libraryfname)
|
|
|
|
p_text = f.read()
|
|
|
|
f.close()
|
|
|
|
else:
|
|
|
|
error("Path %s not found for library %s" % (path, library.name))
|
|
|
|
continue
|
|
|
|
|
2017-09-24 21:04:40 -03:00
|
|
|
param_matches = prog_param.findall(p_text)
|
2017-02-05 22:16:37 -04:00
|
|
|
debug("Found %u documented parameters" % len(param_matches))
|
|
|
|
for param_match in param_matches:
|
2018-09-19 07:33:24 -03:00
|
|
|
p = Parameter(library.name+param_match[0], current_file)
|
2017-02-05 22:16:37 -04:00
|
|
|
debug(p.name + ' ')
|
2018-09-19 07:33:24 -03:00
|
|
|
global current_param
|
|
|
|
current_param = p.name
|
2017-02-05 22:16:37 -04:00
|
|
|
field_text = param_match[1]
|
|
|
|
fields = prog_param_fields.findall(field_text)
|
2018-03-25 20:23:33 -03:00
|
|
|
non_vehicle_specific_values_seen = False
|
2017-02-05 22:16:37 -04:00
|
|
|
for field in fields:
|
|
|
|
if field[0] in known_param_fields:
|
2018-03-13 03:49:12 -03:00
|
|
|
value = re.sub('@PREFIX@', library.name, field[1])
|
|
|
|
setattr(p, field[0], value)
|
2018-03-25 20:23:33 -03:00
|
|
|
if field[0] == "Values":
|
|
|
|
non_vehicle_specific_values_seen = True
|
2017-02-05 22:16:37 -04:00
|
|
|
else:
|
2017-08-25 10:34:35 -03:00
|
|
|
error("param: unknown parameter metadata field %s" % field[0])
|
2017-09-24 21:41:25 -03:00
|
|
|
debug("matching %s" % field_text)
|
2017-08-25 10:34:35 -03:00
|
|
|
fields = prog_param_tagged_fields.findall(field_text)
|
2018-03-25 20:23:33 -03:00
|
|
|
this_vehicle_values_seen = False
|
2018-08-05 22:05:13 -03:00
|
|
|
this_vehicle_value = None
|
2018-03-25 20:23:33 -03:00
|
|
|
other_vehicle_values_seen = False
|
2017-08-25 10:34:35 -03:00
|
|
|
for field in fields:
|
|
|
|
only_for_vehicles = field[1].split(",")
|
2018-10-07 22:20:54 -03:00
|
|
|
only_for_vehicles = [x.rstrip().lstrip() for x in only_for_vehicles]
|
2017-09-27 22:18:23 -03:00
|
|
|
delta = set(only_for_vehicles) - set(truename_map.values())
|
|
|
|
if len(delta):
|
|
|
|
error("Unknown vehicles (%s)" % delta)
|
2018-10-07 22:20:54 -03:00
|
|
|
debug("field[0]=%s vehicle=%s truename=%s field[1]=%s only_for_vehicles=%s\n" %
|
|
|
|
(field[0], vehicle.name, vehicle.truename, field[1], str(only_for_vehicles)))
|
2018-08-05 22:05:13 -03:00
|
|
|
value = re.sub('@PREFIX@', library.name, field[2])
|
2018-03-25 20:23:33 -03:00
|
|
|
if field[0] == "Values":
|
|
|
|
if vehicle.truename in only_for_vehicles:
|
|
|
|
this_vehicle_values_seen = True
|
2018-08-05 22:05:13 -03:00
|
|
|
this_vehicle_value = value
|
2018-03-25 20:23:33 -03:00
|
|
|
if len(only_for_vehicles) > 1:
|
|
|
|
other_vehicle_values_seen = True
|
|
|
|
elif len(only_for_vehicles):
|
|
|
|
other_vehicle_values_seen = True
|
2017-08-25 10:34:35 -03:00
|
|
|
if field[0] in known_param_fields:
|
2018-03-13 03:49:12 -03:00
|
|
|
setattr(p, field[0], value)
|
2017-08-25 10:34:35 -03:00
|
|
|
else:
|
2018-03-25 20:23:33 -03:00
|
|
|
error("tagged param<: unknown parameter metadata field '%s'" % field[0])
|
2018-10-07 22:20:54 -03:00
|
|
|
if ((non_vehicle_specific_values_seen or not other_vehicle_values_seen) or this_vehicle_values_seen):
|
2018-08-05 22:05:13 -03:00
|
|
|
if this_vehicle_values_seen:
|
|
|
|
debug("Setting vehicle-specific value (%s)" % str(this_vehicle_value))
|
|
|
|
setattr(p, field[0], this_vehicle_value)
|
2018-10-07 22:20:54 -03:00
|
|
|
# debug("Appending (non_vehicle_specific_values_seen=%u "
|
|
|
|
# "other_vehicle_values_seen=%u this_vehicle_values_seen=%u)" %
|
|
|
|
# (non_vehicle_specific_values_seen, other_vehicle_values_seen, this_vehicle_values_seen))
|
2018-09-24 03:02:18 -03:00
|
|
|
p.path = path # Add path. Later deleted - only used for duplicates
|
2018-03-25 20:23:33 -03:00
|
|
|
library.params.append(p)
|
2017-02-05 22:16:37 -04:00
|
|
|
|
|
|
|
group_matches = prog_groups.findall(p_text)
|
|
|
|
debug("Found %u groups" % len(group_matches))
|
|
|
|
debug(group_matches)
|
|
|
|
for group_match in group_matches:
|
|
|
|
group = group_match[0]
|
|
|
|
debug("Group: %s" % group)
|
2018-10-07 22:20:54 -03:00
|
|
|
lib = Library(group)
|
2017-02-05 22:16:37 -04:00
|
|
|
fields = prog_param_fields.findall(group_match[1])
|
|
|
|
for field in fields:
|
|
|
|
if field[0] in known_group_fields:
|
2018-10-07 22:20:54 -03:00
|
|
|
setattr(lib, field[0], field[1])
|
2017-02-05 22:16:37 -04:00
|
|
|
else:
|
|
|
|
error("unknown parameter metadata field '%s'" % field[0])
|
2018-10-07 22:20:54 -03:00
|
|
|
if not any(lib.name == parsed_l.name for parsed_l in libraries):
|
|
|
|
lib.name = library.name + lib.name
|
|
|
|
debug("Group name: %s" % lib.name)
|
|
|
|
process_library(vehicle, lib, os.path.dirname(libraryfname))
|
|
|
|
alllibs.append(lib)
|
|
|
|
|
2018-09-19 07:33:24 -03:00
|
|
|
current_file = None
|
2017-02-05 22:16:37 -04:00
|
|
|
|
2012-07-04 20:44:53 -03:00
|
|
|
for library in libraries:
|
2013-05-21 04:01:13 -03:00
|
|
|
debug("===\n\n\nProcessing library %s" % library.name)
|
2016-07-31 07:22:06 -03:00
|
|
|
|
|
|
|
if hasattr(library, 'Path'):
|
2017-08-25 10:34:35 -03:00
|
|
|
process_library(vehicle, library)
|
2012-07-05 03:01:52 -03:00
|
|
|
else:
|
2013-05-21 04:01:13 -03:00
|
|
|
error("Skipped: no Path found")
|
2012-07-05 03:01:52 -03:00
|
|
|
|
2013-05-21 04:01:13 -03:00
|
|
|
debug("Processed %u documented parameters" % len(library.params))
|
2012-07-04 20:44:53 -03:00
|
|
|
|
2017-02-06 19:37:15 -04:00
|
|
|
# sort libraries by name
|
2018-10-07 22:20:54 -03:00
|
|
|
alllibs = sorted(alllibs, key=lambda x: x.name)
|
2017-02-05 22:16:37 -04:00
|
|
|
|
2017-02-06 19:37:15 -04:00
|
|
|
libraries = alllibs
|
2018-10-07 22:20:54 -03:00
|
|
|
|
|
|
|
|
2017-02-05 22:16:37 -04:00
|
|
|
def is_number(numberString):
|
|
|
|
try:
|
|
|
|
float(numberString)
|
|
|
|
return True
|
|
|
|
except ValueError:
|
|
|
|
return False
|
|
|
|
|
2018-10-07 22:20:54 -03:00
|
|
|
|
2017-02-05 22:16:37 -04:00
|
|
|
def validate(param):
|
|
|
|
"""
|
|
|
|
Validates the parameter meta data.
|
|
|
|
"""
|
2018-09-19 07:33:24 -03:00
|
|
|
global current_file
|
|
|
|
current_file = param.real_path
|
|
|
|
global current_param
|
|
|
|
current_param = param.name
|
2017-02-05 22:16:37 -04:00
|
|
|
# Validate values
|
|
|
|
if (hasattr(param, "Range")):
|
|
|
|
rangeValues = param.__dict__["Range"].split(" ")
|
|
|
|
if (len(rangeValues) != 2):
|
|
|
|
error("Invalid Range values for %s" % (param.name))
|
|
|
|
return
|
|
|
|
min_value = rangeValues[0]
|
|
|
|
max_value = rangeValues[1]
|
|
|
|
if not is_number(min_value):
|
|
|
|
error("Min value not number: %s %s" % (param.name, min_value))
|
|
|
|
return
|
|
|
|
if not is_number(max_value):
|
|
|
|
error("Max value not number: %s %s" % (param.name, max_value))
|
|
|
|
return
|
2017-05-02 07:36:14 -03:00
|
|
|
# Validate units
|
|
|
|
if (hasattr(param, "Units")):
|
|
|
|
if (param.__dict__["Units"] != "") and (param.__dict__["Units"] not in known_units):
|
|
|
|
error("unknown units field '%s'" % param.__dict__["Units"])
|
2015-12-11 19:03:07 -04:00
|
|
|
|
2018-10-07 22:20:54 -03:00
|
|
|
|
2017-02-05 22:16:37 -04:00
|
|
|
for vehicle in vehicles:
|
|
|
|
for param in vehicle.params:
|
|
|
|
validate(param)
|
2015-12-11 19:03:07 -04:00
|
|
|
|
2018-09-24 03:02:18 -03:00
|
|
|
# Find duplicate names in library and fix up path
|
|
|
|
for library in libraries:
|
|
|
|
param_names_seen = set()
|
|
|
|
param_names_duplicate = set()
|
|
|
|
# Find duplicates:
|
|
|
|
for param in library.params:
|
|
|
|
if param.name in param_names_seen: # is duplicate
|
|
|
|
param_names_duplicate.add(param.name)
|
|
|
|
param_names_seen.add(param.name)
|
|
|
|
# Fix up path for duplicates
|
|
|
|
for param in library.params:
|
|
|
|
if param.name in param_names_duplicate:
|
|
|
|
param.path = param.path.rsplit('/')[-1].rsplit('.')[0]
|
|
|
|
else:
|
|
|
|
# not a duplicate, so delete attribute.
|
|
|
|
delattr(param, "path")
|
|
|
|
|
2017-02-05 22:16:37 -04:00
|
|
|
for library in libraries:
|
|
|
|
for param in library.params:
|
|
|
|
validate(param)
|
2016-07-31 07:22:06 -03:00
|
|
|
|
2018-10-07 22:20:54 -03:00
|
|
|
|
2017-02-05 22:16:37 -04:00
|
|
|
def do_emit(emit):
|
|
|
|
emit.set_annotate_with_vehicle(len(vehicles) > 1)
|
|
|
|
for vehicle in vehicles:
|
2018-12-06 05:07:51 -04:00
|
|
|
emit.emit(vehicle)
|
2016-07-31 07:22:06 -03:00
|
|
|
|
2017-02-05 22:16:37 -04:00
|
|
|
emit.start_libraries()
|
2016-07-31 07:22:06 -03:00
|
|
|
|
2017-02-05 22:16:37 -04:00
|
|
|
for library in libraries:
|
|
|
|
if library.params:
|
2018-12-06 05:07:51 -04:00
|
|
|
emit.emit(library)
|
2016-07-31 07:22:06 -03:00
|
|
|
|
2017-02-05 22:16:37 -04:00
|
|
|
emit.close()
|
2016-07-31 07:22:06 -03:00
|
|
|
|
2018-10-07 22:20:54 -03:00
|
|
|
|
2017-07-17 15:54:40 -03:00
|
|
|
if opts.emit_params:
|
2018-12-06 05:07:51 -04:00
|
|
|
if opts.output_format == 'all' or opts.output_format == 'xml':
|
|
|
|
do_emit(XmlEmit())
|
|
|
|
if opts.output_format == 'all' or opts.output_format == 'wiki':
|
|
|
|
do_emit(WikiEmit())
|
|
|
|
if opts.output_format == 'all' or opts.output_format == 'html':
|
|
|
|
do_emit(HtmlEmit())
|
|
|
|
if opts.output_format == 'all' or opts.output_format == 'rst':
|
|
|
|
do_emit(RSTEmit())
|
|
|
|
if opts.output_format == 'all' or opts.output_format == 'md':
|
|
|
|
do_emit(MDEmit())
|
|
|
|
if opts.output_format == 'all' or opts.output_format == 'edn':
|
|
|
|
try:
|
|
|
|
from ednemit import EDNEmit
|
|
|
|
do_emit(EDNEmit())
|
|
|
|
except ImportError:
|
|
|
|
# if the user wanted edn only then don't hide any errors
|
|
|
|
if opts.output_format == 'edn':
|
|
|
|
raise
|
|
|
|
|
|
|
|
if opts.verbose:
|
|
|
|
print("Unable to emit EDN, install edn_format and pytz if edn is desired")
|
2012-07-04 20:44:53 -03:00
|
|
|
|
2013-05-21 04:01:13 -03:00
|
|
|
sys.exit(error_count)
|