28
28
import glob
29
29
import re
30
30
from sys import exc_info as sys_exc_info
31
+ from sys import exit as sys_exit
31
32
from typing import Any , Dict , List , Optional , Tuple
32
33
import xml .etree .ElementTree as ET
33
34
import argparse
37
38
BASE_URL = "https://autotest.ardupilot.org/Parameters/"
38
39
39
40
PARAM_DEFINITION_XML_FILE = "apm.pdef.xml"
40
- LUA_PARAM_DEFINITION_XML_FILE = "22_inflight_magnetometer_fit_setup .pdef.xml"
41
+ LUA_PARAM_DEFINITION_XML_FILE = "24_inflight_magnetometer_fit_setup .pdef.xml"
41
42
42
43
# ArduPilot parameter names start with a capital letter and can have capital letters, numbers and _
43
44
PARAM_NAME_REGEX = r'^[A-Z][A-Z_0-9]*'
@@ -58,20 +59,20 @@ def arg_parser():
58
59
parser .add_argument ('-s' , '--sort' ,
59
60
choices = ['none' , 'missionplanner' , 'mavproxy' ],
60
61
default = 'none' ,
61
- help = 'Sort the parameters in the file. Defaults to not sorting .' ,
62
+ help = 'Sort the parameters in the file. Defaults to %(default)s .' ,
62
63
)
63
64
parser .add_argument ('-t' , '--vehicle-type' ,
64
65
choices = ['AP_Periph' , 'AntennaTracker' , 'ArduCopter' , 'ArduPlane' ,
65
66
'ArduSub' , 'Blimp' , 'Heli' , 'Rover' , 'SITL' ],
66
67
default = 'ArduCopter' ,
67
- help = 'The type of the vehicle. Defaults to ArduCopter ' ,
68
+ help = 'The type of the vehicle. Defaults to %(default)s. ' ,
68
69
)
69
70
parser .add_argument ('-m' , '--max-line-length' ,
70
71
type = int , default = 100 ,
71
- help = 'Maximum documentation line length. Defaults to %(default)s' ,
72
+ help = 'Maximum documentation line length. Defaults to %(default)s. ' ,
72
73
)
73
74
parser .add_argument ('--verbose' , action = 'store_true' ,
74
- help = 'Increase output verbosity, print ReadOnly parameter list. Defaults to %(default)s' ,
75
+ help = 'Increase output verbosity, print ReadOnly parameter list. Defaults to %(default)s. ' ,
75
76
)
76
77
parser .add_argument ('-v' , '--version' , action = 'version' , version = f'%(prog)s { VERSION } ' ,
77
78
help = 'Display version information and exit.' ,
@@ -313,12 +314,12 @@ def get_xml_data(base_url: str, directory: str, filename: str) -> ET.Element:
313
314
else :
314
315
# No locally cached file exists, get it from the internet
315
316
try :
316
- from requests import get as requests_get # pylint: disable=C0415
317
- from requests import exceptions as requests_exceptions # pylint: disable=C0415
318
- except ImportError :
317
+ from requests import get as requests_get # pylint: disable=import-outside-toplevel
318
+ from requests import exceptions as requests_exceptions # pylint: disable=import-outside-toplevel
319
+ except ImportError as exc :
319
320
logging .critical ("The requests package was not found" )
320
321
logging .critical ("Please install it by running 'pip install requests' in your terminal." )
321
- raise SystemExit ("requests package is not installed" ) # pylint: disable=W0707
322
+ raise SystemExit ("requests package is not installed" ) from exc
322
323
try :
323
324
# Send a GET request to the URL
324
325
response = requests_get (base_url + filename , timeout = 5 )
@@ -664,7 +665,7 @@ def main():
664
665
args .sort , param_default_dict , args .delete_documentation_annotations )
665
666
except Exception as exp : # pylint: disable=W0718
666
667
logging .fatal (exp )
667
- exit (1 ) # pylint: disable=R1722
668
+ sys_exit (1 )
668
669
669
670
670
671
if __name__ == "__main__" :
0 commit comments