Made --skip-pre to take a list of actions.
This commit is contained in:
parent
e4b94eec08
commit
7d02012dbc
|
|
@ -8,13 +8,11 @@ import sys
|
|||
from . import kiplot
|
||||
from . import config_reader
|
||||
from . import log
|
||||
from . import misc
|
||||
|
||||
|
||||
def main():
|
||||
|
||||
EXIT_BAD_ARGS = 1
|
||||
EXIT_BAD_CONFIG = 2
|
||||
|
||||
parser = argparse.ArgumentParser(
|
||||
description='Command-line Plotting for KiCad')
|
||||
parser.add_argument('target', nargs='*',
|
||||
|
|
@ -30,8 +28,8 @@ def main():
|
|||
help='Generate the outputs not listed as targets')
|
||||
group.add_argument('-q', '--quiet', action='store_true',
|
||||
help='remove information logs')
|
||||
parser.add_argument('-s', '--skip-pre', action='store_true',
|
||||
help='skip pre-flight actions')
|
||||
parser.add_argument('-s', '--skip-pre', nargs=1,
|
||||
help='skip pre-flight actions, comma separated list or `all`')
|
||||
group.add_argument('-v', '--verbose', action='store_true',
|
||||
help='show debugging information')
|
||||
|
||||
|
|
@ -42,11 +40,12 @@ def main():
|
|||
|
||||
if not os.path.isfile(args.board_file):
|
||||
logger.error("Board file not found: {}".format(args.board_file))
|
||||
sys.exit(misc.NO_PCB_FILE)
|
||||
|
||||
if not os.path.isfile(args.plot_config):
|
||||
logger.error("Plot config file not found: {}"
|
||||
.format(args.plot_config))
|
||||
sys.exit(EXIT_BAD_ARGS)
|
||||
sys.exit(misc.EXIT_BAD_ARGS)
|
||||
|
||||
cr = config_reader.CfgYamlReader()
|
||||
|
||||
|
|
@ -62,7 +61,7 @@ def main():
|
|||
|
||||
if errs:
|
||||
logger.error('Invalid config:\n\n' + "\n".join(errs))
|
||||
sys.exit(EXIT_BAD_CONFIG)
|
||||
sys.exit(misc.EXIT_BAD_CONFIG)
|
||||
|
||||
# Set up the plotter and do it
|
||||
plotter = kiplot.Plotter(cfg)
|
||||
|
|
|
|||
|
|
@ -49,10 +49,7 @@ class Plotter(object):
|
|||
|
||||
logger.debug("Board loaded")
|
||||
|
||||
if not skip_pre:
|
||||
self._preflight_checks(brd_file)
|
||||
else:
|
||||
logger.debug("Skipping pre-flight actions")
|
||||
self._preflight_checks(brd_file, skip_pre)
|
||||
|
||||
n = len(target)
|
||||
if n == 0 and invert:
|
||||
|
|
@ -84,8 +81,25 @@ class Plotter(object):
|
|||
logger.debug('Skipping %s output', op.name)
|
||||
|
||||
|
||||
def _preflight_checks(self, brd_file):
|
||||
def _preflight_checks(self, brd_file, skip_pre):
|
||||
logger.debug("Preflight checks")
|
||||
|
||||
if not skip_pre is None:
|
||||
if skip_pre[0] == 'all':
|
||||
logger.debug("Skipping all pre-flight actions")
|
||||
return
|
||||
else:
|
||||
skip_list = skip_pre[0].split(',')
|
||||
for skip in skip_list:
|
||||
if skip == 'all':
|
||||
logger.error('All can\'t be part of a list of actions to skip. Use `--skip all`')
|
||||
exit(misc.EXIT_BAD_ARGS)
|
||||
elif skip == 'run_drc':
|
||||
self.cfg.run_drc = False
|
||||
logger.debug('Skipping run_drc')
|
||||
else:
|
||||
logger.error('Unknown action to skip: '+skip)
|
||||
exit(misc.EXIT_BAD_ARGS)
|
||||
if self.cfg.run_drc:
|
||||
self._run_drc(brd_file, self.cfg.ignore_unconnected, self.cfg.check_zone_fills)
|
||||
|
||||
|
|
|
|||
|
|
@ -7,3 +7,8 @@ NO_PCBNEW_MODULE = 2
|
|||
USUPPORTED_OPTION = 3
|
||||
MISSING_TOOL = 4
|
||||
DRC_ERROR = 5
|
||||
EXIT_BAD_ARGS = 6
|
||||
EXIT_BAD_CONFIG = 7
|
||||
NO_PCB_FILE = 8
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue